2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
7 PIPELINE_DEPTH : natural := 2
12 gpr_write_valid_in : in std_ulogic;
13 gpr_write_in : in std_ulogic_vector(4 downto 0);
14 gpr_read_valid_in : in std_ulogic;
15 gpr_read_in : in std_ulogic_vector(4 downto 0);
17 stall_out : out std_ulogic
19 end entity gpr_hazard;
20 architecture behaviour of gpr_hazard is
21 type pipeline_entry_type is record
23 gpr : std_ulogic_vector(4 downto 0);
25 constant pipeline_entry_init : pipeline_entry_type := (valid => '0', gpr => (others => '0'));
27 type pipeline_t is array(0 to PIPELINE_DEPTH-1) of pipeline_entry_type;
28 constant pipeline_t_init : pipeline_t := (others => pipeline_entry_init);
30 signal r, rin : pipeline_t := pipeline_t_init;
32 gpr_hazard0: process(clk)
34 if rising_edge(clk) then
39 gpr_hazard1: process(all)
40 variable v : pipeline_t;
45 loop_0: for i in 0 to PIPELINE_DEPTH-1 loop
46 if ((r(i).valid = gpr_read_valid_in) and r(i).gpr = gpr_read_in) then
51 v(0).valid := gpr_write_valid_in;
52 v(0).gpr := gpr_write_in;
53 loop_1: for i in 0 to PIPELINE_DEPTH-2 loop
54 -- propagate to next slot
58 -- asynchronous output
59 if gpr_read_valid_in = '0' then