summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-12-25 01:56:01 +0100
committerLouis Burda <quent.burda@gmail.com>2023-12-25 01:56:01 +0100
commitf2ada47e6be185cc31c475c996c4ccf6735f7bb0 (patch)
treef39aa55ab0585c376d608dad922efe71f9d640a2
parent5ff5bb25cc864e7fa06aa8fed0c4ec92e99f103a (diff)
downloadtis100-f2ada47e6be185cc31c475c996c4ccf6735f7bb0.tar.gz
tis100-f2ada47e6be185cc31c475c996c4ccf6735f7bb0.zip
fixup! Make mode/state behaviour compatible with game
-rw-r--r--test.sh1
-rw-r--r--tis100.c4
-rw-r--r--tpu.c14
-rw-r--r--tpu.h2
4 files changed, 13 insertions, 8 deletions
diff --git a/test.sh b/test.sh
index 63ed635..4a511e2 100644
--- a/test.sh
+++ b/test.sh
@@ -28,3 +28,4 @@ for f in test/*.asm; do
[ $bad -ne 0 ] && echo "$f"
fi
done
+:
diff --git a/tis100.c b/tis100.c
index b79567a..ce2cb75 100644
--- a/tis100.c
+++ b/tis100.c
@@ -58,8 +58,8 @@ main(int argc, const char **argv)
stats = tis_gen_stats(&tis);
printf("=== stats ===\n");
printf(" cycles: %zu\n", stats.steps);
- printf(" blocks: %zu\n", stats.blocks);
- printf(" insts: %zu\n", stats.blocks);
+ printf(" nodes: %zu\n", stats.nodes);
+ printf(" insts: %zu\n", stats.nodes);
printf(" idle: %2.1f%%\n", stats.idle * 100);
printf("=============\n");
}
diff --git a/tpu.c b/tpu.c
index 459db24..2736e1c 100644
--- a/tpu.c
+++ b/tpu.c
@@ -386,6 +386,8 @@ tpu_port_write(struct tpu *tpu, enum tpu_port_dir dir, int lit)
port->writing = true;
port->out = lit;
+ /* port writing never succeeds right away, only after
+ * value was read in tpu_update is tpu->idle/mode fixed up */
return true;
}
@@ -477,10 +479,12 @@ tpu_exec(struct tpu *tpu, struct tpu_inst *inst)
return MODE_READ;
}
}
- /* tpu->idle/mode fixed up via tpu->reset_in if value is read */
- if (!tpu_exec_put(tpu, &inst->ops[1], lit))
+ if (!tpu_exec_put(tpu, &inst->ops[1], lit)) {
tpu->idle = true;
- return MODE_WRITE;
+ return MODE_WRITE;
+ }
+ tpu->pc += 1;
+ return MODE_RUN;
case INST_SWP:
lit = tpu->acc;
tpu->acc = tpu->bak;
@@ -751,7 +755,7 @@ tis_gen_stats(struct tis *tis)
int i;
stats.steps = tis->steps;
- stats.blocks = 0;
+ stats.nodes = 0;
stats.insts = 0;
stats.idle = 0;
@@ -763,7 +767,7 @@ tis_gen_stats(struct tis *tis)
stats.insts += link->tpu->inst_cnt;
idle_steps += link->tpu->idle_steps;
all_steps += link->tpu->steps;
- stats.blocks += (link->tpu->inst_cnt > 0);
+ stats.nodes += (link->tpu->inst_cnt > 0);
}
}
diff --git a/tpu.h b/tpu.h
index d34c2c7..8e42c90 100644
--- a/tpu.h
+++ b/tpu.h
@@ -131,7 +131,7 @@ struct tis {
struct tis_stats {
size_t steps;
- size_t blocks;
+ size_t nodes;
size_t insts;
float idle;
};