summaryrefslogtreecommitdiffstats
path: root/tpu.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-07-25 02:29:54 +0200
committerLouis Burda <quent.burda@gmail.com>2023-07-25 02:29:54 +0200
commitd07257c9e92e8697915aaf40070c6228a5855104 (patch)
tree4551ee601ab2adee4d946db6fd65fae4be3590f5 /tpu.h
parente32b439cfe7ca72098b2ebe9e1e93f97b7c10ada (diff)
downloadtis100-d07257c9e92e8697915aaf40070c6228a5855104.tar.gz
tis100-d07257c9e92e8697915aaf40070c6228a5855104.zip
Validate jump target existence on tpu load
Diffstat (limited to 'tpu.h')
-rw-r--r--tpu.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/tpu.h b/tpu.h
index 98c9ad1..1fcb8d9 100644
--- a/tpu.h
+++ b/tpu.h
@@ -34,6 +34,11 @@ enum tpu_port_type {
PORT_IN = 0b01, PORT_OUT = 0b10, PORT_BIDI = 0b11
};
+union tpu_inst_op_val {
+ uint8_t lit;
+ char *label;
+};
+
struct label_map_link {
char *label;
size_t pc;
@@ -46,10 +51,7 @@ struct label_map {
struct tpu_inst_op {
enum tpu_inst_op_type type;
- union {
- uint8_t lit;
- char *label;
- };
+ union tpu_inst_op_val val;
};
struct tpu_inst {
@@ -116,9 +118,11 @@ struct tpu_inst *tpu_current_inst(struct tpu *tpu);
void tpu_init_ports(struct tpu *tpu, struct tpu_map *map);
void tpu_update_ports(struct tpu *tpu);
bool tpu_set_inst(struct tpu *tpu, uint8_t pc, enum tpu_inst_type inst,
- int op1, uint8_t op1_lit, int op2, uint8_t op2_lit);
+ int op1, union tpu_inst_op_val v1,
+ int op2, union tpu_inst_op_val v2);
bool tpu_add_inst(struct tpu *tpu, enum tpu_inst_type inst,
- int op1, uint8_t op1_lit, int op2, uint8_t op2_lit);
+ int op1, union tpu_inst_op_val v1,
+ int op2, union tpu_inst_op_val v2);
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);