aboutsummaryrefslogtreecommitdiff
path: root/design
diff options
context:
space:
mode:
Diffstat (limited to 'design')
-rw-r--r--design/stack_machine.v45
1 files changed, 38 insertions, 7 deletions
diff --git a/design/stack_machine.v b/design/stack_machine.v
index 54eae5e..91e808b 100644
--- a/design/stack_machine.v
+++ b/design/stack_machine.v
@@ -206,10 +206,18 @@ module stack_machine_new
assign instr_tee = !set_im && !use_im && stack_grows &&
instruction[11:0] == 12'd0;
+ wire instr_get_frame;
+ assign instr_get_frame = !set_im && !use_im && stack_grows &&
+ instruction[11:0] == 12'd1;
+
wire instr_const;
assign instr_const = use_im && stack_grows &&
instruction[11:7] == 5'd0;
+ wire instr_call;
+ assign instr_call = use_im && stack_grows &&
+ instruction[11:7] == 5'd1;
+
/* Instructions, that shrink stack */
wire instr_add;
assign instr_add = !set_im && !use_im && stack_shrinks_by_1 &&
@@ -227,6 +235,14 @@ module stack_machine_new
assign instr_mul = !set_im && !use_im && stack_shrinks_by_1 &&
instruction[11:0] == 12'd3;
+ wire instr_drop;
+ assign instr_drop = !set_im && !use_im && stack_shrinks_by_1 &&
+ instruction[11:0] == 12'd4;
+
+ wire instr_ret;
+ assign instr_ret = !set_im && !use_im && stack_shrinks_by_1 &&
+ instruction[11:0] == 12'b000010000000;
+
wire instr_cond_jump;
assign instr_cond_jump = use_im && stack_shrinks_by_1 &&
instruction[11:7] == 5'd1;
@@ -366,8 +382,6 @@ module stack_machine_new
I_CYC_O <= 1;
D_CYC_O <= 0;
- D_STB_O <= 0;
- D_WE_O <= 0;
end
if (first_execution_tick) begin
@@ -434,8 +448,9 @@ module stack_machine_new
<= {stack_transfer_unrequested[0], 1'b0};
end
- if (load_store_unrequested ||
- stack_transfer_unrequested[0]) begin
+ if (stack_transfer_unrequested[0] ||
+ (load_store_unrequested &&
+ stack_transfer_unrequested[1])) begin
if (stack_shrinks) begin
`SET_SP(sp + 4);
D_ADR_O <= sp;
@@ -443,7 +458,7 @@ module stack_machine_new
D_SEL_O <= 4'b1111;
D_STB_O <= 1;
D_WE_O <= 0;
- end else if (stack_grows) begin
+ end else /* if (stack_grows) */ begin
`SET_SP(sp - 4);
D_ADR_O <= sp - 4;
D_DAT_O <= stack_put_value;
@@ -451,13 +466,13 @@ module stack_machine_new
D_STB_O <= 1;
D_WE_O <= 1;
end
- end else begin // if (load_store_unrequested ||...
+ end else begin // if (stack_transfer_unrequested[0] ||...
D_ADR_O <= 21'bx;
D_DAT_O <= 32'bx;
D_SEL_O <= 4'bx;
D_STB_O <= 0;
D_WE_O <= 0;
- end // else: !if(load_store_unrequested ||...
+ end // else: !if(stack_transfer_unrequested[0] ||...
end // if (data_request_happens)
if (data_command_completes) begin
@@ -521,9 +536,17 @@ module stack_machine_new
if (instr_tee)
r1 <= r1;
+ if (instr_get_frame && first_execution_tick)
+ r1 <= sp;
+
if (instr_const && first_execution_tick)
r1 <= im_effective;
+ if (instr_call && first_execution_tick) begin
+ r1 <= pc;
+ `SET_PC(im_effective);
+ end
+
/* Instructions, that shrink stack */
if (instr_add && arithmetic_uncompleted)
r1 <= r0 + r1;
@@ -537,12 +560,20 @@ module stack_machine_new
if (instr_mul && arithmetic_uncompleted)
r1 <= r0 * r1;
+ if (instr_drop && arithmetic_uncompleted)
+ r1 <= r0;
+
if (instr_cond_jump && arithmetic_uncompleted) begin
r1 <= r0;
if (r1)
`SET_PC(im_effective);
end
+
+ if (instr_ret && arithmetic_uncompleted) begin
+ r1 <= r0;
+ `SET_PC(r1);
+ end
end // case: STEP_EXECUTING
endcase // case (step)
end // else: !if(RST_I)