3 use IEEE.std_logic_1164.all;
4 use IEEE.numeric_std.all;
8 use work.common_pkg.all;
12 architecture behav of decode_stage is
14 signal instr_spl : instruction_rec;
16 signal rtw_rec, rtw_rec_nxt : read_through_write_rec;
17 signal reg1_mem_data, reg2_mem_data : gp_register_t;
22 register_ram : r2_w_ram
31 instr_spl.reg_src1_addr,
32 instr_spl.reg_src2_addr,
40 decoder_inst : decoder
47 -- sync process for read through write registers
48 syn: process(clk, reset)
52 if (reset = RESET_VALUE) then
53 rtw_rec.rtw_reg <= (others => '0');
54 rtw_rec.rtw_reg1 <= '0';
55 rtw_rec.rtw_reg2 <= '0';
56 elsif rising_edge(clk) then
57 rtw_rec <= rtw_rec_nxt;
63 -- async process: decides between memory and read-through-write buffer on output
64 output: process(rtw_rec, reg1_mem_data, reg2_mem_data)
67 if (rtw_rec.rtw_reg1 = '1') then
68 reg1_rd_data <= rtw_rec.rtw_reg;
70 reg1_rd_data <= reg1_mem_data;
73 if (rtw_rec.rtw_reg2 = '1') then
74 reg2_rd_data <= rtw_rec.rtw_reg;
76 reg2_rd_data <= reg2_mem_data;
81 -- async process: checks forward condition
82 forward: process(instr_spl, reg_w_addr, reg_wr_data)
86 rtw_rec_nxt.rtw_reg <= reg_wr_data;
87 rtw_rec_nxt.rtw_reg1 <= '0';
88 rtw_rec_nxt.rtw_reg2 <= '0';
90 if (reg_w_addr = instr_spl.reg_src1_addr) then
91 rtw_rec_nxt.rtw_reg1 <= '1';
94 if (reg_w_addr = instr_spl.reg_src2_addr) then
95 rtw_rec_nxt.rtw_reg2 <= '1';
101 -- async process: calculates branch prediction
102 br_pred: process(instr_spl)
106 branch_prediction_res <= (others => '0');
107 branch_prediction_bit <= '0';
109 if ((instr_spl.opcode = "10110" or instr_spl.opcode = "10111") and instr_spl.bp = '1') then
110 branch_prediction_res <= instr_spl.immediate; --both 32 bit
111 branch_prediction_bit <= '1';