add wave -radix hexadecimal /pipeline_tb/decode_st/instruction
add wave -radix hexadecimal /pipeline_tb/decode_st/instr_spl
+add wave -radix hexadecimal /pipeline_tb/decode_st/to_next_stage
add wave -radix hexadecimal /pipeline_tb/decode_st/reg1_mem_data
add wave -radix hexadecimal /pipeline_tb/decode_st/reg2_mem_data
add wave -radix hexadecimal /pipeline_tb/decode_st/rtw_rec
constant IMM_OPT : integer := 0; -- no sharing
constant SUB_OPT : integer := 1;
- constant LOG_OPT : integer := 1;
+ constant ARITH_OPT : integer := 1;
constant CARRY_OPT : integer := 2;
- constant LEFT_OPT : integer := 3;
+ constant RIGHT_OPT : integer := 3;
constant NO_PSW_OPT : integer := 4;--no sharing
constant NO_DST_OPT : integer := 5; --no sharing
reg_src2_addr : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
immediate : std_logic_vector(WORD_WIDTH-1 downto 0);
+-- immediate_set : std_logic;
displacement : std_logic_vector(DISPL_WIDTH-1 downto 0);
jmptype : std_logic_vector(1 downto 0);
- carry, sreg_update, high_low, fill, signext, bp, arith, left_right : std_logic;
+ high_low, fill, signext, bp: std_logic;
- op_detail : op_pot_t;
+ op_detail : op_opt_t;
+ op_group : op_info_t;
end record;
rtw_reg1 : std_logic;
rtw_reg2 : std_logic;
immediate : gp_register_t;
+ imm_set : std_logic;
end record;
reg_we : in std_logic;
--Data outputs
- reg1_rd_data : out gp_register_t;
- reg2_rd_data : out gp_register_t;
+-- reg1_rd_data : out gp_register_t;
+-- reg2_rd_data : out gp_register_t;
branch_prediction_res : out instruction_word_t;
- branch_prediction_bit : out std_logic
+ branch_prediction_bit : out std_logic;
+ to_next_stage : out dec_op
);
end component decode_stage;
--System input pins
sys_clk : in std_logic;
sys_res : in std_logic;
- reg1_rd_data : out gp_register_t;
- reg2_rd_data : out gp_register_t
+ to_next_stage : out dec_op
);
signal reg_w_addr_pin : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
signal reg_wr_data_pin : gp_register_t;
signal reg_we_pin : std_logic;
+
-- signal reg1_rd_data_pin : gp_register_t;
-- signal reg2_rd_data_pin : gp_register_t;
reg_we => reg_we_pin, --: in std_logic;
--Data outputs
- reg1_rd_data => reg1_rd_data, --: gp_register_t;
- reg2_rd_data => reg2_rd_data, --: gp_register_t;
branch_prediction_res => prediction_result_pin, --: instruction_word_t;
- branch_prediction_bit => branch_prediction_bit_pin --: std_logic
-
+ branch_prediction_bit => branch_prediction_bit_pin, --: std_logic
+ to_next_stage => to_next_stage
);
reg_we : in std_logic;
--Data outputs
- reg1_rd_data : out gp_register_t;
- reg2_rd_data : out gp_register_t;
+-- reg1_rd_data : out gp_register_t;
+-- reg2_rd_data : out gp_register_t;
branch_prediction_res : out instruction_word_t;
- branch_prediction_bit : out std_logic
+ branch_prediction_bit : out std_logic;
+
+ to_next_stage : out dec_op
);
signal instr_spl : instruction_rec;
signal rtw_rec, rtw_rec_nxt : read_through_write_rec;
-signal reg1_mem_data, reg2_mem_data : gp_register_t;
+signal reg1_mem_data, reg2_mem_data, reg1_rd_data, reg2_rd_data : gp_register_t;
+signal dec_op_inst, dec_op_inst_nxt : dec_op;
+
begin
rtw_rec.rtw_reg <= (others => '0');
rtw_rec.rtw_reg1 <= '0';
rtw_rec.rtw_reg2 <= '0';
+ rtw_rec.immediate <= (others => '0');
+ rtw_rec.imm_set <= '0';
+
+ dec_op_inst.condition <= (others => '0');
+ dec_op_inst.op_detail <= (others => '0');
+ 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');
+
+
elsif rising_edge(clk) then
rtw_rec <= rtw_rec_nxt;
+ dec_op_inst <= dec_op_inst_nxt;
end if;
end process;
-
-- type dec_op is record
-- condition : condition_t;
-- op_group : op_info_t;
--
-- end record;
-to_alu: process(instr_spl)
+-- output logic incl. bypassing reg-file
+output_next_stage: process(dec_op_inst, reg1_rd_data, reg2_rd_data)
begin
+ to_next_stage <= dec_op_inst;
+ to_next_stage.src1 <= reg1_rd_data;
+ to_next_stage.src2 <= reg2_rd_data;
+
+end process;
+
+
+-- fills output register
+to_next: process(instr_spl)
+
+begin
+ dec_op_inst_nxt.condition <= instr_spl.predicates;
+ dec_op_inst_nxt.op_detail <= instr_spl.op_detail;
+ dec_op_inst_nxt.brpr <= instr_spl.bp; --branch_prediction_bit;
+ dec_op_inst_nxt.src1 <= (others => '0');
+ 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');
end process;
else
reg2_rd_data <= reg2_mem_data;
end if;
+
+ if (rtw_rec.imm_set = '1') then
+ reg2_rd_data <= rtw_rec.immediate;
+ end if;
end process;
-- async process: checks forward condition
-forward: process(instr_spl, reg_w_addr, reg_wr_data)
+forward: process(instr_spl, reg_w_addr, reg_wr_data, reg_we)
begin
rtw_rec_nxt.rtw_reg <= reg_wr_data;
rtw_rec_nxt.rtw_reg1 <= '0';
rtw_rec_nxt.rtw_reg2 <= '0';
+ rtw_rec_nxt.immediate <= (others => '0');
+ rtw_rec_nxt.imm_set <= '0';
- rtw_rec_nxt.immediate <= instr_spl.immediate;
+ if (instr_spl.op_detail(IMM_OPT) = '1') then
+ rtw_rec_nxt.immediate <= instr_spl.immediate;
+ rtw_rec_nxt.imm_set <= '1';
+ end if;
if (reg_w_addr = instr_spl.reg_src1_addr) then
- rtw_rec_nxt.rtw_reg1 <= '1';
+ rtw_rec_nxt.rtw_reg1 <= ('1' and reg_we);
end if;
if (reg_w_addr = instr_spl.reg_src2_addr) then
- rtw_rec_nxt.rtw_reg2 <= '1';
+ rtw_rec_nxt.rtw_reg2 <= ('1' and reg_we);
end if;
end process;
instr_s.immediate := (others => '0');
instr_s.displacement := (others => '0');
instr_s.jmptype := (others => '0');
- instr_s.carry := '0';
- instr_s.sreg_update := '0';
instr_s.high_low := '0';
instr_s.fill := '0';
instr_s.signext := '0';
instr_s.bp := '0';
- instr_s.arith := '0';
instr_s.op_detail := (others => '0');
+ instr_s.op_group := ADDSUB_OP;
+
+-- type op_info_t is (ADDSUB_OP,AND_OP,OR_OP, XOR_OP,SHIFT_OP);
+
-- special function register operations missing
-- case opcode is
instr_s.reg_dest_addr := instruction(22 downto 19);
instr_s.reg_src1_addr := instruction(18 downto 15);
instr_s.reg_src2_addr := instruction(14 downto 11);
- instr_s.carry := instruction(1);
- instr_s.sreg_update := instruction(0);
instr_s.op_detail(NO_PSW_OPT) := instruction(0); --instr_s.sreg_update;
+ instr_s.op_group := ADDSUB_OP;
+
if (instr_s.opcode = "00000") then
instr_s.op_detail(CARRY_OPT) := instruction(1); --instr_s.carry;
end if;
instr_s.op_detail(SUB_OPT) := '1';
instr_s.op_detail(CARRY_OPT) := instruction(1); --instr_s.carry;
end if;
+
+ if (instr_s.opcode = "00100") then
+ instr_s.op_group := AND_OP;
+ end if;
+
+ if (instr_s.opcode = "00110") then
+ instr_s.op_group := OR_OP;
+ end if;
+
+ if (instr_s.opcode = "01000") then
+ instr_s.op_group := XOR_OP;
+ end if;
+
end if;
-- when "00001" => --sub
-- instr_s.reg_dest_addr := instruction(22 downto 19);
instr_s.reg_src1_addr := instruction(18 downto 15);
instr_s.immediate(11 downto 0) := instruction(14 downto 3);
instr_s.signext := instruction(2);
- instr_s.carry := instruction(1);
- instr_s.sreg_update := instruction(0);
if (instr_s.signext = '1' and instr_s.immediate(11) = '1') then
instr_s.immediate(31 downto 12) := (others => '1');
instr_s.op_detail(CARRY_OPT) := instruction(1);
instr_s.op_detail(NO_PSW_OPT) := instruction(0);
+ instr_s.op_group := ADDSUB_OP;
+
if (instr_s.opcode = "00011") then
instr_s.op_detail(SUB_OPT) := '1';
end if;
instr_s.immediate(15 downto 0) := instruction(18 downto 3);
instr_s.high_low := instruction(2);
instr_s.fill := instruction(1);
- instr_s.sreg_update := instruction(0);
if (instr_s.fill = '1') then
instr_s.immediate(31 downto 16) := (others => '1');
instr_s.op_detail(IMM_OPT) := '1';
instr_s.op_detail(NO_PSW_OPT) := instruction(0);
+
+ if (instr_s.opcode = "00111") then
+ instr_s.op_group := AND_OP;
+ end if;
+
+ if (instr_s.opcode = "00111") then
+ instr_s.op_group := OR_OP;
+ end if;
+
+ if (instr_s.opcode = "01001") then
+ instr_s.op_group := XOR_OP;
+ end if;
end if;
-- when "00111" => --orx
instr_s.reg_dest_addr := instruction(22 downto 19);
instr_s.reg_src1_addr := instruction(18 downto 15);
instr_s.immediate(4 downto 0) := instruction(14 downto 10);
- instr_s.left_right := instruction(3);
- instr_s.arith := instruction(2);
- instr_s.carry := instruction(1);
- instr_s.sreg_update := instruction(0);
instr_s.op_detail(RIGHT_OPT) := instruction(3);
instr_s.op_detail(NO_PSW_OPT) := instruction(0);
instr_s.op_detail(CARRY_OPT) := instruction(1);
instr_s.op_detail(ARITH_OPT) := instruction(2);
+ instr_s.op_detail(IMM_OPT) := '1';
+
+ instr_s.op_group := SHIFT_OP;
end if;
-- when "01011" => --stackop
begin
- logic <= op_detail(LOG_OPT);
- ls <= op_detail(LEFT_OPT);
+ logic <= op_detail(ARITH_OPT);
+ ls <= op_detail(RIGHT_OPT);
carry <= op_detail(CARRY_OPT);
calc: process(left_operand, right_operand, logic,ls, carry, alu_state)
signal reg_w_addr_pin : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
signal reg_wr_data_pin : gp_register_t;
signal reg_we_pin : std_logic;
- signal reg1_rd_data_pin : gp_register_t;
- signal reg2_rd_data_pin : gp_register_t;
-
+ signal to_next_stage_pin : dec_op;
begin
reg_we => reg_we_pin, --: in std_logic;
--Data outputs
- reg1_rd_data => reg1_rd_data_pin, --: gp_register_t;
- reg2_rd_data => reg2_rd_data_pin, --: gp_register_t;
branch_prediction_res => prediction_result_pin, --: instruction_word_t;
- branch_prediction_bit => branch_prediction_bit_pin --: std_logic
+ branch_prediction_bit => branch_prediction_bit_pin, --: std_logic
+ to_next_stage => to_next_stage_pin
);