diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-12-25 01:46:55 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-12-25 01:46:55 +0100 |
| commit | 5ff5bb25cc864e7fa06aa8fed0c4ec92e99f103a (patch) | |
| tree | 646a3a56d5e9d831e81d64c48a2e39e594cf0685 /tpu.h | |
| parent | 70d48f0db2ff618436df7c8c52ead5a0701fd7ab (diff) | |
| download | tis100-5ff5bb25cc864e7fa06aa8fed0c4ec92e99f103a.tar.gz tis100-5ff5bb25cc864e7fa06aa8fed0c4ec92e99f103a.zip | |
Make mode/state behaviour compatible with game
Diffstat (limited to 'tpu.h')
| -rw-r--r-- | tpu.h | 47 |
1 files changed, 32 insertions, 15 deletions
@@ -11,10 +11,9 @@ #define TPU_MAX_INST_LEN 18 #define TIS_MAX_IO_PORTS 36 -/* enum order is important ! */ - -enum tpu_status { - STATUS_IDLE, STATUS_RUN, STATUS_READ, STATUS_WRITE +/* what tpu will attempt next (order important) */ +enum tpu_mode { + MODE_IDLE, MODE_RUN, MODE_READ, MODE_WRITE }; enum tpu_inst_type { @@ -65,18 +64,26 @@ struct tpu_inst { }; struct tpu_port { - struct tpu *dst_tpu; + struct tpu *tpu; enum tpu_port_type type; + + /* NOTE: dont access dst_port during execution, + * values are transfered in post execution phase */ struct tpu_port *dst_port; - bool clr_post_run; - bool reading, writing; bool attached; - bool in_set, out_set; + int in, out; + bool avail, reading, writing; + + bool reset_in; }; struct tpu { - enum tpu_status status; + enum tpu_mode mode; + bool idle; + + bool disabled; + int x, y; struct tpu_port ports[4]; @@ -91,7 +98,7 @@ struct tpu { struct label_map label_map; struct tpu_inst insts[TPU_MAX_INST_CNT]; - int inst_cnt, label_cnt; + size_t inst_cnt, label_cnt; }; struct tpu_map_link { @@ -117,6 +124,16 @@ struct tis { struct tpu_map tpu_map; struct tpu_io_port *in_ports[TIS_MAX_IO_PORTS]; struct tpu_io_port *out_ports[TIS_MAX_IO_PORTS]; + size_t steps; + bool show_stats; + bool asm_init; +}; + +struct tis_stats { + size_t steps; + size_t blocks; + size_t insts; + float idle; }; void label_map_init(struct label_map *map); @@ -124,7 +141,7 @@ void label_map_deinit(struct label_map *map); bool label_map_add(struct label_map *map, const char *name, int pc); int label_map_get(struct label_map *map, const char *name); -void tpu_port_init(struct tpu_port *port); +void tpu_port_init(struct tpu_port *port, struct tpu *tpu); void tpu_port_deinit(struct tpu_port *port); void tpu_io_port_init(struct tpu_io_port *io_port, char c, @@ -142,9 +159,8 @@ bool tpu_set_inst(struct tpu *tpu, int pc, enum tpu_inst_type inst, struct tpu_inst *tpu_add_inst(struct tpu *tpu, enum tpu_inst_type inst, unsigned opcnt, struct tpu_inst_op op1, struct tpu_inst_op op2); void tpu_clear_ports(struct tpu *tpu); -enum tpu_status tpu_exec_mov(struct tpu *tpu, struct tpu_inst *inst); -enum tpu_status tpu_exec(struct tpu *tpu, struct tpu_inst *inst); -enum tpu_status tpu_step(struct tpu *tpu); +enum tpu_mode tpu_exec(struct tpu *tpu, struct tpu_inst *inst); +void tpu_step(struct tpu *tpu); void tpu_map_init(struct tpu_map *map); void tpu_map_deinit(struct tpu_map *map); @@ -155,8 +171,9 @@ void tis_init(struct tis *tis); void tis_deinit(struct tis *tis); bool tis_step(struct tis *tis); void tis_communicate(struct tis *tis); +struct tis_stats tis_gen_stats(struct tis *tis); extern const char *dir_reprs[]; -extern const char *status_reprs[]; +extern const char *mode_reprs[]; extern const char *inst_reprs[]; extern const char *op_reprs[]; |
