-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
50 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
-- | ||
-- Authors: Niklaus Leuenberger <[email protected]> | ||
-- | ||
-- Version: 0.3 | ||
-- Version: 0.4 | ||
-- | ||
-- Entity: neorv32_wb_gateway | ||
-- | ||
|
@@ -17,6 +17,8 @@ | |
-- allow bus to be locked by lr/sc atomic ops | ||
-- 0.3, 2023-09-30, leuen4 | ||
-- reduce latency, immediately forward request | ||
-- 0.4, 2024-01-01, leuen4 | ||
-- update to new neorv32 stb and rw bus signals | ||
-- ============================================================================= | ||
|
||
LIBRARY ieee; | ||
|
@@ -46,54 +48,51 @@ END ENTITY neorv32_wb_gateway; | |
|
||
ARCHITECTURE no_target_specific OF neorv32_wb_gateway IS | ||
|
||
-- Register for pending bus access (rden_i or wren_i was asserted). | ||
SIGNAL pending_read : STD_ULOGIC; -- set on read request | ||
SIGNAL pending_write : STD_ULOGIC; -- set on write request | ||
-- Registers for bus access state. | ||
SIGNAL pending_request : STD_ULOGIC; -- a request is pending | ||
SIGNAL pending_atomic : STD_ULOGIC; -- lr/sc pair in progress | ||
SIGNAL active_request : STD_ULOGIC; -- a request is currently active | ||
SIGNAL active_request : STD_ULOGIC; -- a request is currently in progress | ||
|
||
BEGIN | ||
|
||
-- CPU specific bus asserts rden_i and wren_i for one clock only. Wishbone | ||
-- requires cyc & stb signals to be active for the whole transaction. Safe | ||
-- the pending state of an access and output that as cyc signal. | ||
-- CPU specific bus asserts stb_i for one clock only. Wishbone requires cyc | ||
-- & stb signals to be active for the whole transaction. Safe the pending | ||
-- state of an access and output that as cyc signal. | ||
proc_request : PROCESS (clk_i) IS | ||
BEGIN | ||
IF rising_edge(clk_i) THEN | ||
IF rstn_i = '0' THEN | ||
pending_read <= '0'; | ||
pending_write <= '0'; | ||
pending_request <= '0'; | ||
pending_atomic <= '0'; | ||
ELSE | ||
-- Start a request on either re or we assertion. Request is | ||
-- pending until either ack or err was returned. | ||
IF req_i.re = '1' THEN | ||
pending_read <= '1'; | ||
ELSIF req_i.we = '1' THEN | ||
pending_write <= '1'; | ||
-- Start a request on stb assertion. Request is pending until | ||
-- either ack or err was returned. | ||
IF req_i.stb = '1' THEN | ||
pending_request <= '1'; | ||
ELSIF (wb_master_i.ack OR wb_master_i.err) = '1' THEN | ||
pending_read <= '0'; | ||
pending_write <= '0'; | ||
pending_request <= '0'; | ||
END IF; | ||
-- Mark request as atomic read/write pair if rvso bit is set. | ||
-- Atomic request is reset on next re or we assertion. | ||
IF pending_atomic = '0' AND (req_i.re AND req_i.rvso) = '1' THEN | ||
-- Lock on to slave during atomic read/write access from lr/sc | ||
-- instruction pairs. Mark current req only as atomic if its a | ||
-- lr (rvso = 1, rw = 0). Otherwise a spurious single sc would | ||
-- lock the bus. Atomic request is reset on next stb assertion. | ||
IF pending_atomic = '0' AND (req_i.stb AND (NOT req_i.rw) AND req_i.rvso) = '1' THEN | ||
pending_atomic <= '1'; | ||
ELSIF pending_atomic = '1' AND (req_i.re OR req_i.we) = '1' THEN | ||
ELSIF pending_atomic = '1' AND req_i.stb = '1' THEN | ||
pending_atomic <= '0'; | ||
END IF; | ||
END IF; | ||
END IF; | ||
END PROCESS proc_request; | ||
|
||
-- A request of active if the current cycle has a request, or a previous | ||
-- A request is active if the current cycle has a strobe, or a previous | ||
-- request was not fullfulled yet. | ||
active_request <= req_i.re OR req_i.we OR pending_read OR pending_write; | ||
active_request <= req_i.stb OR pending_request; | ||
|
||
-- Map CPU bus to Wishbone. | ||
wb_master_o.cyc <= active_request OR pending_atomic; -- hold on to slave if atomic access | ||
wb_master_o.stb <= active_request; | ||
wb_master_o.we <= pending_write; | ||
wb_master_o.we <= req_i.rw; | ||
wb_master_o.sel <= req_i.ben; | ||
wb_master_o.adr <= req_i.addr; | ||
wb_master_o.dat <= req_i.data; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters