summaryrefslogtreecommitdiffstats
path: root/tpu.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-12-25 03:28:35 +0100
committerLouis Burda <quent.burda@gmail.com>2023-12-25 03:28:49 +0100
commitee7820e1cfde69c16130a43c8b7e7df1724afb9e (patch)
tree85975e9a535862e3cddaf3beb5989bfd8307bd2f /tpu.c
parentae4a7b241a033627ed136b2ef66922034cfbeae1 (diff)
downloadtis100-ee7820e1cfde69c16130a43c8b7e7df1724afb9e.tar.gz
tis100-ee7820e1cfde69c16130a43c8b7e7df1724afb9e.zip
Calculate steps needed by tick of last output event
Diffstat (limited to 'tpu.c')
-rw-r--r--tpu.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/tpu.c b/tpu.c
index aac59ed..13db28d 100644
--- a/tpu.c
+++ b/tpu.c
@@ -181,6 +181,7 @@ tpu_io_port_init(struct tpu_io_port *io_port, char c, enum tpu_port_dir dir,
enum tpu_port_type type, int x, int y)
{
tpu_port_init(&io_port->port, NULL);
+ io_port->io_step = 0;
io_port->type = type;
io_port->file = NULL;
io_port->dir = dir;
@@ -673,7 +674,6 @@ tis_step(struct tis *tis)
tis_communicate(tis);
- running = false;
for (i = 0; i < TPU_MAP_BUCKETS; i++) {
link = tis->tpu_map.buckets[i];
for (; link; link = link->next)
@@ -682,15 +682,15 @@ tis_step(struct tis *tis)
for (i = 0; i < TPU_MAP_BUCKETS; i++) {
link = tis->tpu_map.buckets[i];
- for (; link; link = link->next) {
+ for (; link; link = link->next)
tpu_update(link->tpu);
- running |= !link->tpu->idle;
- }
}
+ running = false;
for (i = 0; i < TPU_MAP_BUCKETS; i++) {
link = tis->tpu_map.buckets[i];
for (; link; link = link->next) {
+ running |= !link->tpu->idle;
if (link->tpu->pc < link->tpu->inst_cnt) {
link->tpu->steps += 1;
if (link->tpu->idle)
@@ -732,6 +732,7 @@ tis_communicate(struct tis *tis)
die("communicate: invalid input '%s'", buf);
io_port->port.out = val;
io_port->port.writing = true;
+ io_port->io_step = tis->steps;
break;
}
}
@@ -745,6 +746,7 @@ tis_communicate(struct tis *tis)
fprintf(io_port->file, "%i\n", io_port->port.in);
io_port->port.reset_in = true;
tpu_port_update(&io_port->port);
+ io_port->io_step = tis->steps;
}
}
@@ -757,11 +759,18 @@ tis_gen_stats(struct tis *tis)
size_t all_steps;
int i;
- stats.steps = tis->steps;
+ stats.steps = 0;
stats.nodes = 0;
stats.insts = 0;
stats.idle = 0;
+ for (i = 0; i < TIS_MAX_IO_PORTS; i++) {
+ if (tis->out_ports[i] && tis->out_ports[i]->io_step > 0) {
+ stats.steps = MAX(stats.steps, tis->out_ports[i]->io_step + 1);
+ }
+ }
+ if (!stats.steps) stats.steps = tis->steps;
+
all_steps = 0;
idle_steps = 0;
for (i = 0; i < TPU_MAP_BUCKETS; i++) {