static branch incl prediction rc1
[calu.git] / cpu / src / decode_stage_b.vhd
index fbaf0101d7804730f7ff60632e9fdae7f44dc765..dc5e389b7527bf11aad11cbd5580728b0a08669a 100644 (file)
@@ -57,15 +57,17 @@ begin
                rtw_rec.immediate <= (others => '0');
                rtw_rec.imm_set <= '0';
 
-               dec_op_inst.condition <= (others => '0');
+               dec_op_inst.condition <= (others => '1');
                dec_op_inst.op_detail <= (others => '0');
+               dec_op_inst.op_group <= ADDSUB_OP;
                dec_op_inst.brpr <= '0'; --branch_prediction_bit;
                dec_op_inst.src1 <= (others => '0');
                dec_op_inst.src2 <= (others => '0');
                dec_op_inst.saddr1 <= (others => '0');
                dec_op_inst.saddr2 <= (others => '0');
                dec_op_inst.daddr <= (others => '0');
-
+               dec_op_inst.displacement <= (others => '0');
+               dec_op_inst.prog_cnt <= (others => '0');
 
        elsif rising_edge(clk) then
                rtw_rec <= rtw_rec_nxt;
@@ -91,7 +93,7 @@ end process;
 --     end record;
 
 -- output logic incl. bypassing reg-file
-output_next_stage: process(dec_op_inst, reg1_rd_data, reg2_rd_data)
+output_next_stage: process(dec_op_inst, reg1_rd_data, reg2_rd_data, nop)
 
 begin
 
@@ -99,6 +101,10 @@ begin
        to_next_stage.src1 <= reg1_rd_data;
        to_next_stage.src2 <= reg2_rd_data;
 
+       if (nop = '1') then
+               to_next_stage.condition <= "1111";
+       end if;
+
 end process;
 
 
@@ -113,21 +119,24 @@ begin
        dec_op_inst_nxt.src2 <= (others => '0');
        dec_op_inst_nxt.saddr1 <= instr_spl.reg_src1_addr;
        dec_op_inst_nxt.saddr2 <= instr_spl.reg_src2_addr;
-       dec_op_inst_nxt.daddr <= (others => '0');
+       dec_op_inst_nxt.daddr <= instr_spl.reg_dest_addr; --(others => '0');
+       dec_op_inst_nxt.op_group <= instr_spl.op_group;
+       dec_op_inst_nxt.displacement <= instr_spl.displacement;
+       dec_op_inst_nxt.prog_cnt <= prog_cnt;
 
 end process;
 
 -- async process: decides between memory and read-through-write buffer on output
-output: process(rtw_rec, reg1_mem_data, reg2_mem_data)
+output: process(rtw_rec, rtw_rec_nxt, reg1_mem_data, reg2_mem_data)
 
 begin
-       if (rtw_rec.rtw_reg1 = '1') then
+       if ((rtw_rec.rtw_reg1) = '1') then
                reg1_rd_data <= rtw_rec.rtw_reg;
        else
                reg1_rd_data <= reg1_mem_data;
        end if;
 
-       if (rtw_rec.rtw_reg2 = '1') then
+       if ((rtw_rec.rtw_reg2) = '1') then
                reg2_rd_data <= rtw_rec.rtw_reg;
        else
                reg2_rd_data <= reg2_mem_data;
@@ -136,6 +145,7 @@ begin
        if (rtw_rec.imm_set = '1') then
                reg2_rd_data <= rtw_rec.immediate;
        end if;
+
 end process;
 
 
@@ -149,6 +159,9 @@ begin
        rtw_rec_nxt.rtw_reg2 <= '0';
        rtw_rec_nxt.immediate <= (others => '0');
        rtw_rec_nxt.imm_set <= '0';
+--- ???? wieso
+       rtw_rec_nxt.reg1_addr <= instr_spl.reg_src1_addr;
+       rtw_rec_nxt.reg2_addr <= instr_spl.reg_src2_addr;
 
        if (instr_spl.op_detail(IMM_OPT) = '1') then
                rtw_rec_nxt.immediate <= instr_spl.immediate;
@@ -175,7 +188,7 @@ begin
        branch_prediction_bit <= '0';
 
        if ((instr_spl.opcode = "10110" or instr_spl.opcode = "10111") and instr_spl.bp = '1') then
-               branch_prediction_res <= instr_spl.immediate;   --both 32 bit
+               branch_prediction_res <= std_logic_vector(unsigned(instr_spl.immediate) + unsigned(prog_cnt));  --both 32 bit
                branch_prediction_bit <= '1';
        end if;