Skip to content

Commit

Permalink
[rtl/core] fixed mtime_o low word to high word overflow inconsistency #…
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed Jun 4, 2021
1 parent a5e4ab2 commit f46fedf
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions rtl/core/neorv32_top.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,25 @@ begin
mtime_irq <= mtime_irq_i; -- use external machine timer interrupt
end generate;

-- system time output --
mtime_o <= mtime_time when (IO_MTIME_EN = true) else (others => '0');

-- system time output LO --
mtime_sync: process(clk_i)
begin
if rising_edge(clk_i) then
-- buffer low word one clock cycle to compensate for MTIME's 1-cycle delay
-- when overflowing from low-word to high-word -> only relevant for processor-external devices
-- processor-internal devices (= the CPU) do not care about this delay offset as 64-bit MTIME.TIME
-- cannot be accessed within a single cycle
if (IO_MTIME_EN = true) then
mtime_o(31 downto 0) <= mtime_time(31 downto 0);
else
mtime_o(31 downto 0) <= (others => '0');
end if;
end if;
end process mtime_sync;

-- system time output HI --
mtime_o(63 downto 32) <= mtime_time(63 downto 32) when (IO_MTIME_EN = true) else (others => '0');


-- Primary Universal Asynchronous Receiver/Transmitter (UART0) ----------------------------
Expand Down

0 comments on commit f46fedf

Please sign in to comment.