From ba4d97ddc2133c905e668c2f916cf3b14be4e35d Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Sat, 5 Sep 2020 17:09:16 +0200 Subject: add sub instruction together with bench --- design/stack_machine.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'design') diff --git a/design/stack_machine.v b/design/stack_machine.v index d79a136..868a103 100644 --- a/design/stack_machine.v +++ b/design/stack_machine.v @@ -200,6 +200,11 @@ module stack_machine_new assign instr_add = !set_im && !use_im && stack_shrinks_by_1 && instruction[11:0] == 12'd0; + wire instr_sub; + assign instr_sub = !set_im && !use_im && stack_shrinks_by_1 && + instruction[11:0] == 12'd1; + + reg halt; /* Set once a halt instruction is encountered */ assign finished = halt; @@ -446,7 +451,10 @@ module stack_machine_new /* Instructions, that shrink stack */ if (instr_add && first_execution_tick) - r1 <= r1 + r0; + r1 <= r0 + r1; + + if (instr_sub && first_execution_tick) + r1 <= r0 - r1; end // case: STEP_EXECUTING endcase // case (step) end // else: !if(RST_I) -- cgit v1.2.3