Line 4... |
Line 4... |
-- # Allows to access a single peripheral bus ("p_bus") by two controller busses. Controller port #
|
-- # Allows to access a single peripheral bus ("p_bus") by two controller busses. Controller port #
|
-- # A ("ca_bus") has priority over controller port B ("cb_bus"). #
|
-- # A ("ca_bus") has priority over controller port B ("cb_bus"). #
|
-- # ********************************************************************************************* #
|
-- # ********************************************************************************************* #
|
-- # BSD 3-Clause License #
|
-- # BSD 3-Clause License #
|
-- # #
|
-- # #
|
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved. #
|
-- # #
|
-- # #
|
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
-- # permitted provided that the following conditions are met: #
|
-- # permitted provided that the following conditions are met: #
|
-- # #
|
-- # #
|
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
Line 88... |
Line 88... |
);
|
);
|
end neorv32_busswitch;
|
end neorv32_busswitch;
|
|
|
architecture neorv32_busswitch_rtl of neorv32_busswitch is
|
architecture neorv32_busswitch_rtl of neorv32_busswitch is
|
|
|
-- access buffer --
|
|
signal ca_rd_req_buf : std_ulogic;
|
|
signal ca_wr_req_buf : std_ulogic;
|
|
signal cb_rd_req_buf : std_ulogic;
|
|
signal cb_wr_req_buf : std_ulogic;
|
|
|
|
-- access requests --
|
-- access requests --
|
signal ca_req_current : std_ulogic;
|
signal ca_rd_req_buf, ca_wr_req_buf : std_ulogic;
|
signal cb_req_current : std_ulogic;
|
signal cb_rd_req_buf, cb_wr_req_buf : std_ulogic;
|
signal ca_req_buffered : std_ulogic;
|
signal ca_req_current, ca_req_buffered : std_ulogic;
|
signal cb_req_buffered : std_ulogic;
|
signal cb_req_current, cb_req_buffered : std_ulogic;
|
|
|
-- internal bus lines --
|
-- internal bus lines --
|
signal ca_bus_ack : std_ulogic;
|
signal ca_bus_ack, cb_bus_ack : std_ulogic;
|
signal cb_bus_ack : std_ulogic;
|
signal ca_bus_err, cb_bus_err : std_ulogic;
|
signal ca_bus_err : std_ulogic;
|
signal p_bus_we, p_bus_re : std_ulogic;
|
signal cb_bus_err : std_ulogic;
|
|
signal p_bus_we : std_ulogic;
|
|
signal p_bus_re : std_ulogic;
|
|
|
|
-- access arbiter --
|
-- access arbiter --
|
type arbiter_state_t is (IDLE, BUSY, RETIRE, BUSY_SWITCHED, RETIRE_SWITCHED);
|
type arbiter_state_t is (IDLE, BUSY, RETIRE, BUSY_SWITCHED, RETIRE_SWITCHED);
|
type arbiter_t is record
|
type arbiter_t is record
|
state : arbiter_state_t;
|
state : arbiter_state_t;
|
Line 240... |
Line 231... |
p_bus_src_o <= '1'; -- access from port B
|
p_bus_src_o <= '1'; -- access from port B
|
arbiter.bus_sel <= '1';
|
arbiter.bus_sel <= '1';
|
if (cb_bus_cancel_i = '1') or -- controller cancels access
|
if (cb_bus_cancel_i = '1') or -- controller cancels access
|
(p_bus_err_i = '1') or -- peripheral cancels access
|
(p_bus_err_i = '1') or -- peripheral cancels access
|
(p_bus_ack_i = '1') then -- normal termination
|
(p_bus_ack_i = '1') then -- normal termination
|
|
if (ca_req_buffered = '1') or (ca_req_current = '1') then -- any request from A?
|
|
arbiter.state_nxt <= RETIRE;
|
|
else
|
arbiter.state_nxt <= IDLE;
|
arbiter.state_nxt <= IDLE;
|
end if;
|
end if;
|
|
end if;
|
|
|
when RETIRE_SWITCHED => -- retire pending switched access
|
when RETIRE_SWITCHED => -- retire pending switched access
|
-- ------------------------------------------------------------
|
-- ------------------------------------------------------------
|
p_bus_src_o <= '1'; -- access from port B
|
p_bus_src_o <= '1'; -- access from port B
|
arbiter.bus_sel <= '1';
|
arbiter.bus_sel <= '1';
|