From 7b64f3e297b913c73f11dee0503491dcf3fc9919 Mon Sep 17 00:00:00 2001 From: Raphael Jacquot Date: Fri, 15 Mar 2019 10:21:02 +0100 Subject: [PATCH] implement GOSUB (7xxx) --- saturn_inst_decoder.v | 4 ++-- saturn_regs_pc_rstk.v | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/saturn_inst_decoder.v b/saturn_inst_decoder.v index 44e22ff..b97b0d3 100644 --- a/saturn_inst_decoder.v +++ b/saturn_inst_decoder.v @@ -266,10 +266,10 @@ always @(posedge i_clk) begin 4'h1: block_1x <= 1'b1; 4'h2: block_2x <= 1'b1; 4'h3: block_3x <= 1'b1; - 4'h6: + 4'h6, 4'h7: begin o_instr_type <= `INSTR_TYPE_JUMP; - // o_push_pc <= i_nibble[1]; + o_push_pc <= i_nibble[0]; o_jump_length <= 3'd2; jump_counter <= 3'd0; o_instr_execute <= 1'b1; diff --git a/saturn_regs_pc_rstk.v b/saturn_regs_pc_rstk.v index 10fd277..dd91074 100644 --- a/saturn_regs_pc_rstk.v +++ b/saturn_regs_pc_rstk.v @@ -198,10 +198,11 @@ always @(posedge i_clk) begin */ if (i_phases[3] && do_jump_instr && !jump_decode) begin `ifdef SIM - $display("PC_RSTK %0d: [%d] start decode jump %0d | jump_base %5h", i_phase, i_cycle_ctr, i_jump_length, reg_PC); + $display("PC_RSTK %0d: [%d] start decode jump %0d | jump_base %5h", i_phase, i_cycle_ctr, + i_jump_length, i_push_pc? reg_PC + {{17{1'b0}},(i_jump_length + 3'd1)} : reg_PC); `endif jump_counter <= 3'd0; - jump_base <= reg_PC; + jump_base <= i_push_pc? reg_PC + {{17{1'b0}},(i_jump_length + 3'd1)} : reg_PC; jump_decode <= 1'b1; rstk_ptr_to_push_at <= (reg_rstk_ptr + 3'o1) & 3'o7; end