| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -6,70 +6,71 @@ library work;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					use work.common.all;
 | 
					 | 
					 | 
					 | 
					use work.common.all;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					entity fetch1 is
 | 
					 | 
					 | 
					 | 
					entity fetch1 is
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						generic(
 | 
					 | 
					 | 
					 | 
					    generic(
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							RESET_ADDRESS : std_logic_vector(63 downto 0) := (others => '0')
 | 
					 | 
					 | 
					 | 
						RESET_ADDRESS : std_logic_vector(63 downto 0) := (others => '0')
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						);
 | 
					 | 
					 | 
					 | 
						);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						port(
 | 
					 | 
					 | 
					 | 
					    port(
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							clk           : in std_ulogic;
 | 
					 | 
					 | 
					 | 
						clk           : in std_ulogic;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							rst           : in std_ulogic;
 | 
					 | 
					 | 
					 | 
						rst           : in std_ulogic;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							-- Control inputs:
 | 
					 | 
					 | 
					 | 
						-- Control inputs:
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							stall_in      : in std_ulogic;
 | 
					 | 
					 | 
					 | 
						stall_in      : in std_ulogic;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							flush_in      : in std_ulogic;
 | 
					 | 
					 | 
					 | 
						flush_in      : in std_ulogic;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							-- redirect from execution unit
 | 
					 | 
					 | 
					 | 
						-- redirect from execution unit
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							e_in          : in Execute1ToFetch1Type;
 | 
					 | 
					 | 
					 | 
						e_in          : in Execute1ToFetch1Type;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							-- fetch data out
 | 
					 | 
					 | 
					 | 
						-- fetch data out
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							f_out         : out Fetch1ToFetch2Type
 | 
					 | 
					 | 
					 | 
						f_out         : out Fetch1ToFetch2Type
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						);
 | 
					 | 
					 | 
					 | 
						);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					end entity fetch1;
 | 
					 | 
					 | 
					 | 
					end entity fetch1;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					architecture behaviour of fetch1 is
 | 
					 | 
					 | 
					 | 
					architecture behaviour of fetch1 is
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						type reg_internal_type is record
 | 
					 | 
					 | 
					 | 
					    type reg_internal_type is record
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							nia_next : std_ulogic_vector(63 downto 0);
 | 
					 | 
					 | 
					 | 
						nia_next : std_ulogic_vector(63 downto 0);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						end record;
 | 
					 | 
					 | 
					 | 
					    end record;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						signal r_int, rin_int : reg_internal_type;
 | 
					 | 
					 | 
					 | 
					    signal r_int, rin_int : reg_internal_type;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						signal r, rin : Fetch1ToFetch2Type;
 | 
					 | 
					 | 
					 | 
					    signal r, rin : Fetch1ToFetch2Type;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					begin
 | 
					 | 
					 | 
					 | 
					begin
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						regs : process(clk)
 | 
					 | 
					 | 
					 | 
					    regs : process(clk)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						begin
 | 
					 | 
					 | 
					 | 
					    begin
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if rising_edge(clk) then
 | 
					 | 
					 | 
					 | 
						if rising_edge(clk) then
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								r <= rin;
 | 
					 | 
					 | 
					 | 
						    r <= rin;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								r_int <= rin_int;
 | 
					 | 
					 | 
					 | 
						    r_int <= rin_int;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							end if;
 | 
					 | 
					 | 
					 | 
						end if;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						end process;
 | 
					 | 
					 | 
					 | 
					    end process;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						comb : process(all)
 | 
					 | 
					 | 
					 | 
					    comb : process(all)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							variable v     : Fetch1ToFetch2Type;
 | 
					 | 
					 | 
					 | 
						variable v     : Fetch1ToFetch2Type;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							variable v_int : reg_internal_type;
 | 
					 | 
					 | 
					 | 
						variable v_int : reg_internal_type;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						begin
 | 
					 | 
					 | 
					 | 
					    begin
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							v := r;
 | 
					 | 
					 | 
					 | 
						v := r;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							v_int := r_int;
 | 
					 | 
					 | 
					 | 
						v_int := r_int;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if stall_in = '0' then
 | 
					 | 
					 | 
					 | 
						if stall_in = '0' then
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								v.nia := r_int.nia_next;
 | 
					 | 
					 | 
					 | 
						    v.nia := r_int.nia_next;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								v_int.nia_next := std_logic_vector(unsigned(r_int.nia_next) + 4);
 | 
					 | 
					 | 
					 | 
						    v_int.nia_next := std_logic_vector(unsigned(r_int.nia_next) + 4);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							end if;
 | 
					 | 
					 | 
					 | 
						end if;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if e_in.redirect = '1' then
 | 
					 | 
					 | 
					 | 
						if e_in.redirect = '1' then
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								v.nia := e_in.redirect_nia;
 | 
					 | 
					 | 
					 | 
						    v.nia := e_in.redirect_nia;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								v_int.nia_next := std_logic_vector(unsigned(e_in.redirect_nia) + 4);
 | 
					 | 
					 | 
					 | 
						    v_int.nia_next := std_logic_vector(unsigned(e_in.redirect_nia) + 4);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							end if;
 | 
					 | 
					 | 
					 | 
						end if;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if rst = '1' then
 | 
					 | 
					 | 
					 | 
						if rst = '1' then
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								v.nia := RESET_ADDRESS;
 | 
					 | 
					 | 
					 | 
						    v.nia := RESET_ADDRESS;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								v_int.nia_next := std_logic_vector(unsigned(RESET_ADDRESS) + 4);
 | 
					 | 
					 | 
					 | 
						    v_int.nia_next := std_logic_vector(unsigned(RESET_ADDRESS) + 4);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							end if;
 | 
					 | 
					 | 
					 | 
						end if;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							-- Update registers
 | 
					 | 
					 | 
					 | 
						-- Update registers
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							rin <= v;
 | 
					 | 
					 | 
					 | 
						rin <= v;
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							rin_int <= v_int;
 | 
					 | 
					 | 
					 | 
						rin_int <= v_int;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							-- Update outputs
 | 
					 | 
					 | 
					 | 
						-- Update outputs
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							f_out <= r;
 | 
					 | 
					 | 
					 | 
						f_out <= r;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							report "fetch1 R:" & std_ulogic'image(e_in.redirect) & " v.nia:" & to_hstring(v.nia) & " f_out.nia:" & to_hstring(f_out.nia);
 | 
					 | 
					 | 
					 | 
						report "fetch1 R:" & std_ulogic'image(e_in.redirect) & " v.nia:" & to_hstring(v.nia) & " f_out.nia:" & to_hstring(f_out.nia);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						end process;
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    end process;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 
 | 
					 | 
					 | 
					 | 
					
 
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					end architecture behaviour;
 | 
					 | 
					 | 
					 | 
					end architecture behaviour;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
 
 |