From 7a61f213fb9be8ab7f9bd0fb33940b21fa143b05 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Sat, 3 Oct 2020 21:45:24 +0200 Subject: fixes, conditional if-not jump and translation of if-else instruction from wasm --- design/stack_machine.v | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'design') 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 -- cgit v1.2.3