3 use IEEE.std_logic_1164.all;
4 use IEEE.numeric_std.all;
8 use work.common_pkg.all;
11 architecture behav of decode_stage is
13 signal instr_spl : instruction_rec;
15 signal rtw_rec, rtw_rec_nxt : read_through_write_rec;
16 signal reg1_mem_data, reg2_mem_data : gp_register_t;
21 register_ram : r2_w_ram
30 instr_spl.reg_src1_addr,
31 instr_spl.reg_src2_addr,
39 decoder_inst : decoder
46 -- sync process for read through write registers
47 syn: process(clk, reset)
51 if (reset = RESET_VALUE) then
52 rtw_rec.rtw_reg <= (others => '0');
53 rtw_rec.rtw_reg1 <= '0';
54 rtw_rec.rtw_reg2 <= '0';
55 elsif rising_edge(clk) then
56 rtw_rec <= rtw_rec_nxt;
62 -- type dec_op is record
63 -- condition : condition_t;
64 -- op_group : op_info_t;
65 -- op_detail : op_opt_t;
68 -- src1 : gp_register_t;
69 -- src2 : gp_register_t;
71 -- saddr1 : gp_addr_t;
72 -- saddr2 : gp_addr_t;
78 to_alu: process(instr_spl)
85 -- async process: decides between memory and read-through-write buffer on output
86 output: process(rtw_rec, reg1_mem_data, reg2_mem_data)
89 if (rtw_rec.rtw_reg1 = '1') then
90 reg1_rd_data <= rtw_rec.rtw_reg;
92 reg1_rd_data <= reg1_mem_data;
95 if (rtw_rec.rtw_reg2 = '1') then
96 reg2_rd_data <= rtw_rec.rtw_reg;
98 reg2_rd_data <= reg2_mem_data;
103 -- async process: checks forward condition
104 forward: process(instr_spl, reg_w_addr, reg_wr_data)
108 rtw_rec_nxt.rtw_reg <= reg_wr_data;
109 rtw_rec_nxt.rtw_reg1 <= '0';
110 rtw_rec_nxt.rtw_reg2 <= '0';
112 rtw_rec_nxt.immediate <= instr_spl.immediate;
114 if (reg_w_addr = instr_spl.reg_src1_addr) then
115 rtw_rec_nxt.rtw_reg1 <= '1';
118 if (reg_w_addr = instr_spl.reg_src2_addr) then
119 rtw_rec_nxt.rtw_reg2 <= '1';
125 -- async process: calculates branch prediction
126 br_pred: process(instr_spl)
130 branch_prediction_res <= (others => '0');
131 branch_prediction_bit <= '0';
133 if ((instr_spl.opcode = "10110" or instr_spl.opcode = "10111") and instr_spl.bp = '1') then
134 branch_prediction_res <= instr_spl.immediate; --both 32 bit
135 branch_prediction_bit <= '1';