aboutsummaryrefslogtreecommitdiff
path: root/design
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-10-03 21:45:24 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-10-05 10:13:38 +0200
commit7a61f213fb9be8ab7f9bd0fb33940b21fa143b05 (patch)
tree1bd5beab68c778d4d3a2543cf3661bfcb23445c2 /design
parentc548c0ce5b2e7ca2784257966ebdd386e1f31218 (diff)
downloadAGH-engineering-thesis-7a61f213fb9be8ab7f9bd0fb33940b21fa143b05.tar.gz
AGH-engineering-thesis-7a61f213fb9be8ab7f9bd0fb33940b21fa143b05.zip
fixes, conditional if-not jump and translation of if-else instruction from wasm
Diffstat (limited to 'design')
-rw-r--r--design/stack_machine.v12
1 files changed, 9 insertions, 3 deletions
diff --git a/design/stack_machine.v b/design/stack_machine.v
index 91e808b..5e6e0d6 100644
--- a/design/stack_machine.v
+++ b/design/stack_machine.v
@@ -247,6 +247,10 @@ module stack_machine_new
assign instr_cond_jump = use_im && stack_shrinks_by_1 &&
instruction[11:7] == 5'd1;
+ wire instr_cond_jump_n;
+ assign instr_cond_jump_n = use_im && stack_shrinks_by_1 &&
+ instruction[11:7] == 5'd2;
+
reg halt; /* Set once a halt instruction is encountered */
assign finished = halt;
@@ -314,7 +318,7 @@ module stack_machine_new
always @ (posedge CLK_I) begin
if (RST_I) begin
`SET_PC(0);
- `SET_SP(21'h0FFFFF);
+ `SET_SP(21'h0FFFFC);
I_STB_O <= 0;
I_CYC_O <= 0;
@@ -563,10 +567,12 @@ module stack_machine_new
if (instr_drop && arithmetic_uncompleted)
r1 <= r0;
- if (instr_cond_jump && arithmetic_uncompleted) begin
+ if ((instr_cond_jump || instr_cond_jump_n) &&
+ arithmetic_uncompleted) begin
r1 <= r0;
- if (r1)
+ if ((r1 && instr_cond_jump) ||
+ (!r1 && instr_cond_jump_n))
`SET_PC(im_effective);
end