Line 80... |
Line 80... |
signal mtime_lo : std_ulogic_vector(31 downto 0);
|
signal mtime_lo : std_ulogic_vector(31 downto 0);
|
signal mtime_lo_nxt : std_ulogic_vector(32 downto 0);
|
signal mtime_lo_nxt : std_ulogic_vector(32 downto 0);
|
signal mtime_lo_ovfl : std_ulogic_vector(00 downto 0);
|
signal mtime_lo_ovfl : std_ulogic_vector(00 downto 0);
|
signal mtime_hi : std_ulogic_vector(31 downto 0);
|
signal mtime_hi : std_ulogic_vector(31 downto 0);
|
|
|
-- comparator and IRQ trigger --
|
-- comparators --
|
signal cmp_lo : std_ulogic;
|
signal cmp_lo_ge : std_ulogic;
|
signal cmp_lo_ff : std_ulogic;
|
signal cmp_lo_ge_ff : std_ulogic;
|
signal cmp_hi : std_ulogic;
|
signal cmp_hi_eq : std_ulogic;
|
signal cmp_match_ff : std_ulogic;
|
signal cmp_hi_gt : std_ulogic;
|
|
|
begin
|
begin
|
|
|
-- Access Control -------------------------------------------------------------------------
|
-- Access Control -------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
Line 111... |
Line 111... |
mtimecmp_hi <= data_i;
|
mtimecmp_hi <= data_i;
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
-- mtime access buffer --
|
-- mtime access buffer --
|
-- wdata_buf <= data_i; -- not required, CPU wdata is stable until transfer is acknowledged
|
-- wdata_buf <= data_i; -- not required, CPU wdata (=data_i) is stable until transfer is acknowledged
|
mtime_lo_we <= wren and bool_to_ulogic_f(boolean(addr = mtime_time_lo_addr_c));
|
mtime_lo_we <= wren and bool_to_ulogic_f(boolean(addr = mtime_time_lo_addr_c));
|
mtime_hi_we <= wren and bool_to_ulogic_f(boolean(addr = mtime_time_hi_addr_c));
|
mtime_hi_we <= wren and bool_to_ulogic_f(boolean(addr = mtime_time_hi_addr_c));
|
|
|
-- mtime low --
|
-- mtime low --
|
if (mtime_lo_we = '1') then -- write access
|
if (mtime_lo_we = '1') then -- write access
|
Line 159... |
Line 159... |
end if;
|
end if;
|
end if;
|
end if;
|
end process rd_access;
|
end process rd_access;
|
|
|
-- system time output for cpu --
|
-- system time output for cpu --
|
time_o <= mtime_hi & mtime_lo;
|
time_o <= mtime_hi & mtime_lo; -- NOTE: low and high words are not synchronized here!
|
|
|
|
|
-- Comparator -----------------------------------------------------------------------------
|
-- Comparator -----------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
cmp_sync: process(clk_i)
|
cmp_sync: process(clk_i)
|
begin
|
begin
|
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
cmp_lo_ff <= cmp_lo;
|
cmp_lo_ge_ff <= cmp_lo_ge;
|
cmp_match_ff <= cmp_lo_ff and cmp_hi;
|
irq_o <= cmp_hi_gt or (cmp_hi_eq and cmp_lo_ge_ff);
|
irq_o <= cmp_lo_ff and cmp_hi and (not cmp_match_ff);
|
|
end if;
|
end if;
|
end process cmp_sync;
|
end process cmp_sync;
|
|
|
-- test words --
|
-- sub-word comparators --
|
cmp_lo <= '1' when (unsigned(mtime_lo) >= unsigned(mtimecmp_lo)) else '0';
|
cmp_lo_ge <= '1' when (unsigned(mtime_lo) >= unsigned(mtimecmp_lo)) else '0'; -- low-word: greater than or equal
|
cmp_hi <= '1' when (unsigned(mtime_hi) >= unsigned(mtimecmp_hi)) else '0';
|
cmp_hi_eq <= '1' when (unsigned(mtime_hi) = unsigned(mtimecmp_hi)) else '0'; -- high-word: equal
|
|
cmp_hi_gt <= '1' when (unsigned(mtime_hi) > unsigned(mtimecmp_hi)) else '0'; -- high-word: greater than
|
|
|
|
|
end neorv32_mtime_rtl;
|
end neorv32_mtime_rtl;
|
|
|
No newline at end of file
|
No newline at end of file
|