From 8b5b3095a033e5361ef075fb03ae0ca62073e564 Mon Sep 17 00:00:00 2001 From: yannickreiss Date: Thu, 8 Aug 2024 06:28:36 +0200 Subject: [PATCH] Reset in program counter matched with clock --- src/cpu.vhd | 7 +++---- src/pc.vhd | 32 ++++++++++++++------------------ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/cpu.vhd b/src/cpu.vhd index 92d158d..6af8e1a 100644 --- a/src/cpu.vhd +++ b/src/cpu.vhd @@ -327,10 +327,9 @@ begin when stEXEC => s_cycle_cnt <= stWB; when others => s_cycle_cnt <= stIF; end case; - else - if falling_edge(reset) then - s_cycle_cnt <= stIF; - end if; + end if; + if falling_edge(reset) then + s_cycle_cnt <= stIF; end if; end process pc_cycle_control; diff --git a/src/pc.vhd b/src/pc.vhd index 61c0479..640f471 100644 --- a/src/pc.vhd +++ b/src/pc.vhd @@ -26,26 +26,22 @@ architecture pro_count of pc is signal addr_out : ram_addr_t := (others => '0'); signal addr_out_plus : ram_addr_t := (others => '0'); begin - process (clk) - begin - if rising_edge(clk) then - if en_pc = "1" then - -- count - if doJump = "1" then - addr_out <= addr_calc; - -- jump - else - addr_out <= addr_out_plus; - end if; - end if; - end if; - end process; - - process (reset) + process (clk, reset) begin if falling_edge(reset) then - addr_out <= (others => '0'); - addr_out_plus <= (others => '0'); + addr_out <= (others => '0'); + else + if rising_edge(clk) then + if en_pc = "1" then + -- count + if doJump = "1" then + addr_out <= addr_calc; + -- jump + else + addr_out <= addr_out_plus; + end if; + end if; + end if; end if; end process;