aboutsummaryrefslogtreecommitdiff
path: root/design/stack_machine.v
diff options
context:
space:
mode:
Diffstat (limited to 'design/stack_machine.v')
-rw-r--r--design/stack_machine.v28
1 files changed, 21 insertions, 7 deletions
diff --git a/design/stack_machine.v b/design/stack_machine.v
index 04b1285..d79a136 100644
--- a/design/stack_machine.v
+++ b/design/stack_machine.v
@@ -118,6 +118,9 @@ module stack_machine_new
wire stack_shrinks;
assign stack_shrinks = instruction[13] == 1'b1 && !set_im;
+ wire stack_shrinks_by_1;
+ assign stack_shrinks_by_1 = stack_shrinks && instruction[12] == 1'b1;
+
wire stack_shrinks_by_2;
assign stack_shrinks_by_2 = stack_shrinks && instruction[12] == 1'b0;
@@ -193,7 +196,9 @@ module stack_machine_new
instruction[11:7] == 5'd0;
/* Instructions, that shrink stack */
- /* none now */
+ wire instr_add;
+ assign instr_add = !set_im && !use_im && stack_shrinks_by_1 &&
+ instruction[11:0] == 12'd0;
reg halt; /* Set once a halt instruction is encountered */
assign finished = halt;
@@ -279,9 +284,6 @@ module stack_machine_new
STEP_EXECUTING : begin
first_execution_tick <= 0;
- if (instr_halt)
- halt <= 1;
-
if (((stack_grows || stack_shrinks || load || store) &&
first_execution_tick) ||
(load_store_uncompleted &&
@@ -425,14 +427,26 @@ module stack_machine_new
else
im <= 32'bx;
- if (instr_const && first_execution_tick)
- r1 <= im_effective;
+ /* Instructions, that do not change stack size */
+ if (instr_halt)
+ halt <= 1;
- if (instr_tee)
+ if (instr_nop)
r1 <= r1;
if (instr_set_sp)
`SET_SP(im_effective);
+
+ /* Instructions, that grow stack */
+ if (instr_tee)
+ r1 <= r1;
+
+ if (instr_const && first_execution_tick)
+ r1 <= im_effective;
+
+ /* Instructions, that shrink stack */
+ if (instr_add && first_execution_tick)
+ r1 <= r1 + r0;
end // case: STEP_EXECUTING
endcase // case (step)
end // else: !if(RST_I)