ldih/l
[calu.git] / cpu / src / core_top.vhd
index 730f6ce7af51d6670b9105f823ac83f2b472a177..14c04c382aa483d59ed24908373b27496eb8f95b 100644 (file)
@@ -10,7 +10,7 @@ entity core_top is
 
        port(
                --System input pins
-                  sys_res : in std_logic;
+                  sys_res_unsync : in std_logic;
                        sys_clk : in std_logic;
 --                     result : out gp_register_t;
 --                     reg_wr_data : out gp_register_t
@@ -28,6 +28,9 @@ end core_top;
 
 architecture behav of core_top is
 
+               constant SYNC_STAGES : integer := 2;
+               constant RESET_VALUE : std_logic := '0';
+
                signal jump_result : instruction_addr_t;
                signal jump_result_pin : instruction_addr_t;
                signal prediction_result_pin : instruction_addr_t;
@@ -59,9 +62,12 @@ architecture behav of core_top is
                 signal gpm_in_pin : extmod_rec;
                 signal gpm_out_pin : gp_register_t;
                 signal nop_pin : std_logic;
+                
+                signal sys_res : std_logic;
 
                 signal vers, vers_nxt : exec2wb_rec;
 
+                signal sync : std_logic_vector(1 to SYNC_STAGES);
 begin
 
        fetch_st : fetch_stage
@@ -162,12 +168,20 @@ begin
                        vers.dmem_write_en <= '0';
                        vers.hword <= '0';
                        vers.byte_s <= '0';
+                       sync <= (others => '0');
        elsif rising_edge(sys_clk) then
                vers <= vers_nxt;
+               
+               sync(1) <= sys_res_unsync xor RESET_VALUE;
+               for i in 2 to SYNC_STAGES loop
+                       sync(i) <= sync(i - 1);
+               end loop;
+               
        end if;
        
 end process;
 
+sys_res <= sync(SYNC_STAGES);
                
 --init : process(all)