Line 1... |
Line 1... |
-- #################################################################################################
|
-- #################################################################################################
|
-- # << NEORV32 - Bus Interface Unit >> #
|
-- # << NEORV32 - Bus Interface Unit >> #
|
-- # ********************************************************************************************* #
|
-- # ********************************************************************************************* #
|
-- # This unit connects the CPU to the memory/IO system. #
|
-- # Instruction and data bus interfaces. #
|
-- # ********************************************************************************************* #
|
-- # ********************************************************************************************* #
|
-- # BSD 3-Clause License #
|
-- # BSD 3-Clause License #
|
-- # #
|
-- # #
|
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
-- # #
|
-- # #
|
Line 49... |
Line 49... |
port (
|
port (
|
-- global control --
|
-- global control --
|
clk_i : in std_ulogic; -- global clock, rising edge
|
clk_i : in std_ulogic; -- global clock, rising edge
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
-- data input --
|
-- cpu instruction fetch interface --
|
wdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- write data
|
fetch_pc_i : in std_ulogic_vector(data_width_c-1 downto 0); -- PC for instruction fetch
|
pc_i : in std_ulogic_vector(data_width_c-1 downto 0); -- current PC
|
|
alu_i : in std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
|
|
-- data output --
|
|
instr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- instruction
|
instr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- instruction
|
|
i_wait_o : out std_ulogic; -- wait for fetch to complete
|
|
--
|
|
ma_instr_o : out std_ulogic; -- misaligned instruction address
|
|
be_instr_o : out std_ulogic; -- bus error on instruction access
|
|
-- cpu data access interface --
|
|
addr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- ALU result -> access address
|
|
wdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- write data
|
rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- read data
|
rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- read data
|
-- status --
|
|
mar_o : out std_ulogic_vector(data_width_c-1 downto 0); -- current memory address register
|
mar_o : out std_ulogic_vector(data_width_c-1 downto 0); -- current memory address register
|
ma_instr_o : out std_ulogic; -- misaligned instruction address
|
d_wait_o : out std_ulogic; -- wait for access to complete
|
|
--
|
ma_load_o : out std_ulogic; -- misaligned load data address
|
ma_load_o : out std_ulogic; -- misaligned load data address
|
ma_store_o : out std_ulogic; -- misaligned store data address
|
ma_store_o : out std_ulogic; -- misaligned store data address
|
be_instr_o : out std_ulogic; -- bus error on instruction access
|
|
be_load_o : out std_ulogic; -- bus error on load data access
|
be_load_o : out std_ulogic; -- bus error on load data access
|
be_store_o : out std_ulogic; -- bus error on store data access
|
be_store_o : out std_ulogic; -- bus error on store data access
|
bus_wait_o : out std_ulogic; -- wait for bus operation to finish
|
-- instruction bus --
|
bus_busy_o : out std_ulogic; -- bus unit is busy
|
i_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
-- bus system --
|
i_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
i_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
i_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
i_bus_we_o : out std_ulogic; -- write enable
|
bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
i_bus_re_o : out std_ulogic; -- read enable
|
bus_we_o : out std_ulogic; -- write enable
|
i_bus_cancel_o : out std_ulogic; -- cancel current bus transaction
|
bus_re_o : out std_ulogic; -- read enable
|
i_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
bus_cancel_o : out std_ulogic; -- cancel current bus transaction
|
i_bus_err_i : in std_ulogic; -- bus transfer error
|
bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
i_bus_fence_o : out std_ulogic; -- fence operation
|
bus_err_i : in std_ulogic -- bus transfer error
|
-- data bus --
|
|
d_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
|
d_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
|
d_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
|
d_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
|
d_bus_we_o : out std_ulogic; -- write enable
|
|
d_bus_re_o : out std_ulogic; -- read enable
|
|
d_bus_cancel_o : out std_ulogic; -- cancel current bus transaction
|
|
d_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
|
d_bus_err_i : in std_ulogic; -- bus transfer error
|
|
d_bus_fence_o : out std_ulogic -- fence operation
|
);
|
);
|
end neorv32_cpu_bus;
|
end neorv32_cpu_bus;
|
|
|
architecture neorv32_cpu_bus_rtl of neorv32_cpu_bus is
|
architecture neorv32_cpu_bus_rtl of neorv32_cpu_bus is
|
|
|
-- interface registers --
|
-- data interface registers --
|
signal mar, mdo, mdi : std_ulogic_vector(data_width_c-1 downto 0);
|
signal mar, mdo, mdi : std_ulogic_vector(data_width_c-1 downto 0);
|
|
|
-- bus request controller --
|
-- data access --
|
signal bus_busy : std_ulogic;
|
signal d_bus_wdata : std_ulogic_vector(data_width_c-1 downto 0); -- write data
|
signal bus_if_req : std_ulogic;
|
signal d_bus_rdata : std_ulogic_vector(data_width_c-1 downto 0); -- read data
|
signal bus_rd_req : std_ulogic;
|
signal d_bus_ben : std_ulogic_vector(3 downto 0); -- write data byte enable
|
signal bus_wr_req : std_ulogic;
|
|
signal access_err : std_ulogic;
|
|
signal align_err : std_ulogic;
|
|
signal bus_timeout : std_ulogic_vector(index_size_f(MEM_EXT_TIMEOUT)-1 downto 0);
|
|
|
|
-- misaligned access? --
|
-- misaligned access? --
|
signal misaligned_data, misaligned_instr : std_ulogic;
|
signal d_misaligned, i_misaligned : std_ulogic;
|
|
|
|
-- bus arbiter --
|
|
type bus_arbiter_t is record
|
|
rd_req : std_ulogic; -- read access in progress
|
|
wr_req : std_ulogic; -- write access in progress
|
|
err_align : std_ulogic; -- alignment error
|
|
err_bus : std_ulogic; -- bus access error
|
|
timeout : std_ulogic_vector(index_size_f(MEM_EXT_TIMEOUT)-1 downto 0);
|
|
end record;
|
|
signal i_arbiter, d_arbiter : bus_arbiter_t;
|
|
|
begin
|
begin
|
|
|
-- Address and Control --------------------------------------------------------------------
|
-- Data Interface: Access Address ---------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
mem_adr_reg: process(rstn_i, clk_i)
|
mem_adr_reg: process(rstn_i, clk_i)
|
begin
|
begin
|
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
if (ctrl_i(ctrl_bus_mar_we_c) = '1') then
|
if (ctrl_i(ctrl_bus_mar_we_c) = '1') then
|
mar <= alu_i;
|
mar <= addr_i;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process mem_adr_reg;
|
end process mem_adr_reg;
|
|
|
-- address output --
|
-- read-back for exception controller --
|
bus_addr_o <= pc_i when ((bus_if_req or ctrl_i(ctrl_bus_if_c)) = '1') else mar; -- is instruction fetch? keep output at PC as long as IF request is active
|
|
mar_o <= mar;
|
mar_o <= mar;
|
|
|
-- write request output --
|
-- alignment check --
|
bus_we_o <= ctrl_i(ctrl_bus_wr_c) and (not misaligned_data);
|
misaligned_d_check: process(mar, ctrl_i)
|
|
begin
|
-- read request output (also used for instruction fetch) --
|
-- check data access --
|
bus_re_o <= (ctrl_i(ctrl_bus_rd_c) and (not misaligned_data)) or (ctrl_i(ctrl_bus_if_c) and (not misaligned_instr)); -- FIXME i_reg and misaligned
|
d_misaligned <= '0'; -- default
|
|
case ctrl_i(ctrl_bus_size_msb_c downto ctrl_bus_size_lsb_c) is -- data size
|
|
when "00" => -- byte
|
|
d_misaligned <= '0';
|
|
when "01" => -- half-word
|
|
if (mar(0) /= '0') then
|
|
d_misaligned <= '1';
|
|
end if;
|
|
when others => -- word
|
|
if (mar(1 downto 0) /= "00") then
|
|
d_misaligned <= '1';
|
|
end if;
|
|
end case;
|
|
end process misaligned_d_check;
|
|
|
|
|
-- Write Data -----------------------------------------------------------------------------
|
-- Data Interface: Write Data -------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
mem_do_reg: process(clk_i)
|
mem_do_reg: process(clk_i)
|
begin
|
begin
|
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
if (ctrl_i(ctrl_bus_mdo_we_c) = '1') then
|
if (ctrl_i(ctrl_bus_mdo_we_c) = '1') then
|
Line 136... |
Line 167... |
-- byte enable and output data alignment --
|
-- byte enable and output data alignment --
|
byte_enable: process(mar, mdo, ctrl_i)
|
byte_enable: process(mar, mdo, ctrl_i)
|
begin
|
begin
|
case ctrl_i(ctrl_bus_size_msb_c downto ctrl_bus_size_lsb_c) is -- data size
|
case ctrl_i(ctrl_bus_size_msb_c downto ctrl_bus_size_lsb_c) is -- data size
|
when "00" => -- byte
|
when "00" => -- byte
|
bus_wdata_o(07 downto 00) <= mdo(07 downto 00);
|
d_bus_wdata(07 downto 00) <= mdo(07 downto 00);
|
bus_wdata_o(15 downto 08) <= mdo(07 downto 00);
|
d_bus_wdata(15 downto 08) <= mdo(07 downto 00);
|
bus_wdata_o(23 downto 16) <= mdo(07 downto 00);
|
d_bus_wdata(23 downto 16) <= mdo(07 downto 00);
|
bus_wdata_o(31 downto 24) <= mdo(07 downto 00);
|
d_bus_wdata(31 downto 24) <= mdo(07 downto 00);
|
bus_ben_o <= (others => '0');
|
d_bus_ben <= (others => '0');
|
bus_ben_o(to_integer(unsigned(mar(1 downto 0)))) <= '1';
|
d_bus_ben(to_integer(unsigned(mar(1 downto 0)))) <= '1';
|
when "01" => -- half-word
|
when "01" => -- half-word
|
bus_wdata_o(31 downto 16) <= mdo(15 downto 00);
|
d_bus_wdata(31 downto 16) <= mdo(15 downto 00);
|
bus_wdata_o(15 downto 00) <= mdo(15 downto 00);
|
d_bus_wdata(15 downto 00) <= mdo(15 downto 00);
|
if (mar(1) = '0') then
|
if (mar(1) = '0') then
|
bus_ben_o <= "0011"; -- low half-word
|
d_bus_ben <= "0011"; -- low half-word
|
else
|
else
|
bus_ben_o <= "1100"; -- high half-word
|
d_bus_ben <= "1100"; -- high half-word
|
end if;
|
end if;
|
when others => -- word
|
when others => -- word
|
bus_wdata_o <= mdo;
|
d_bus_wdata <= mdo;
|
bus_ben_o <= "1111"; -- full word
|
d_bus_ben <= "1111"; -- full word
|
end case;
|
end case;
|
end process byte_enable;
|
end process byte_enable;
|
|
|
|
|
-- Read Data ------------------------------------------------------------------------------
|
-- Data Interface: Read Data --------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
mem_out_buf: process(clk_i)
|
mem_out_buf: process(clk_i)
|
begin
|
begin
|
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
-- memory data in register (MDI) --
|
-- memory data in register (MDI) --
|
if (ctrl_i(ctrl_bus_mdi_we_c) = '1') then
|
if (ctrl_i(ctrl_bus_mdi_we_c) = '1') then
|
mdi <= bus_rdata_i;
|
mdi <= d_bus_rdata;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process mem_out_buf;
|
end process mem_out_buf;
|
|
|
-- instruction output --
|
-- input data alignment and sign extension --
|
instr_o <= bus_rdata_i;
|
|
|
|
-- input data align and sign extension --
|
|
read_align: process(mdi, mar, ctrl_i)
|
read_align: process(mdi, mar, ctrl_i)
|
variable signed_v : std_ulogic;
|
variable signed_v : std_ulogic;
|
begin
|
begin
|
signed_v := not ctrl_i(ctrl_bus_unsigned_c);
|
signed_v := not ctrl_i(ctrl_bus_unsigned_c);
|
case ctrl_i(ctrl_bus_size_msb_c downto ctrl_bus_size_lsb_c) is -- data size
|
case ctrl_i(ctrl_bus_size_msb_c downto ctrl_bus_size_lsb_c) is -- data size
|
Line 207... |
Line 235... |
rdata_o <= mdi; -- full word
|
rdata_o <= mdi; -- full word
|
end case;
|
end case;
|
end process read_align;
|
end process read_align;
|
|
|
|
|
-- Bus Status Controller ------------------------------------------------------------------
|
-- Instruction Interface: Check for Misaligned Access -------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
bus_ctrl: process(rstn_i, clk_i)
|
misaligned_i_check: process(ctrl_i, fetch_pc_i)
|
begin
|
begin
|
if (rstn_i = '0') then
|
-- check instruction access --
|
bus_busy <= '0';
|
i_misaligned <= '0'; -- default
|
bus_if_req <= '0';
|
if (CPU_EXTENSION_RISCV_C = true) then -- 16-bit and 32-bit instruction accesses
|
bus_rd_req <= '0';
|
i_misaligned <= '0'; -- no alignment exceptions possible
|
bus_wr_req <= '0';
|
else -- 32-bit instruction accesses only
|
access_err <= '0';
|
if (fetch_pc_i(1) = '1') then -- PC(0) is always zero
|
align_err <= '0';
|
i_misaligned <= '1';
|
bus_timeout <= (others => '0');
|
|
elsif rising_edge(clk_i) then
|
|
if (bus_busy = '0') or (ctrl_i(ctrl_bus_reset_c) = '1') then -- wait for new request or reset
|
|
bus_busy <= ctrl_i(ctrl_bus_if_c) or ctrl_i(ctrl_bus_rd_c) or ctrl_i(ctrl_bus_wr_c); -- any request at all?
|
|
bus_if_req <= ctrl_i(ctrl_bus_if_c); -- instruction fetch
|
|
bus_rd_req <= ctrl_i(ctrl_bus_rd_c); -- store access
|
|
bus_wr_req <= ctrl_i(ctrl_bus_wr_c); -- load access
|
|
bus_timeout <= std_ulogic_vector(to_unsigned(MEM_EXT_TIMEOUT, index_size_f(MEM_EXT_TIMEOUT)));
|
|
access_err <= '0';
|
|
align_err <= '0';
|
|
else -- bus transfer in progress
|
|
bus_timeout <= std_ulogic_vector(unsigned(bus_timeout) - 1);
|
|
align_err <= (align_err or misaligned_data or misaligned_instr) and (not ctrl_i(ctrl_bus_exc_ack_c));
|
|
access_err <= (access_err or (not or_all_f(bus_timeout)) or bus_err_i) and (not ctrl_i(ctrl_bus_exc_ack_c));
|
|
if (align_err = '1') or (access_err = '1') then
|
|
if (ctrl_i(ctrl_bus_exc_ack_c) = '1') then -- wait for controller to ack exception
|
|
bus_if_req <= '0';
|
|
bus_rd_req <= '0';
|
|
bus_wr_req <= '0';
|
|
bus_busy <= '0';
|
|
end if;
|
|
elsif (bus_ack_i = '1') then -- normal termination
|
|
bus_if_req <= '0';
|
|
bus_rd_req <= '0';
|
|
bus_wr_req <= '0';
|
|
bus_busy <= '0';
|
|
end if;
|
|
end if;
|
end if;
|
end if;
|
end if;
|
end process bus_ctrl;
|
end process misaligned_i_check;
|
|
|
-- output bus access error to controller --
|
|
be_instr_o <= bus_if_req and access_err;
|
|
be_load_o <= bus_rd_req and access_err;
|
|
be_store_o <= bus_wr_req and access_err;
|
|
|
|
-- output alignment error to controller --
|
|
ma_instr_o <= bus_if_req and align_err;
|
|
ma_load_o <= bus_rd_req and align_err;
|
|
ma_store_o <= bus_wr_req and align_err;
|
|
|
|
-- terminate bus access --
|
|
bus_cancel_o <= (bus_busy and (align_err or access_err)) or ctrl_i(ctrl_bus_reset_c);
|
|
|
|
-- wait for bus --
|
|
bus_busy_o <= bus_busy;
|
|
bus_wait_o <= bus_busy and (not bus_ack_i); -- FIXME: 'async' ack
|
|
|
|
|
|
-- Check for Misaligned Access ------------------------------------------------------------
|
-- Instruction Fetch Arbiter --------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
misaligned_d_check: process(mar, ctrl_i)
|
ifetch_arbiter: process(rstn_i, clk_i)
|
begin
|
begin
|
-- check data access --
|
if (rstn_i = '0') then
|
misaligned_data <= '0'; -- default
|
i_arbiter.rd_req <= '0';
|
case ctrl_i(ctrl_bus_size_msb_c downto ctrl_bus_size_lsb_c) is -- data size
|
i_arbiter.wr_req <= '0';
|
when "00" => -- byte
|
i_arbiter.err_align <= '0';
|
misaligned_data <= '0';
|
i_arbiter.err_bus <= '0';
|
when "01" => -- half-word
|
i_arbiter.timeout <= (others => '0');
|
if (mar(0) /= '0') then
|
elsif rising_edge(clk_i) then
|
misaligned_data <= '1';
|
i_arbiter.wr_req <= '0'; -- instruction fetch is read-only
|
|
|
|
-- instruction fetch request --
|
|
if (i_arbiter.rd_req = '0') then -- idle
|
|
i_arbiter.rd_req <= ctrl_i(ctrl_bus_if_c);
|
|
i_arbiter.err_align <= i_misaligned;
|
|
i_arbiter.err_bus <= '0';
|
|
i_arbiter.timeout <= std_ulogic_vector(to_unsigned(MEM_EXT_TIMEOUT, index_size_f(MEM_EXT_TIMEOUT)));
|
|
else -- in progress
|
|
i_arbiter.timeout <= std_ulogic_vector(unsigned(i_arbiter.timeout) - 1);
|
|
i_arbiter.err_align <= (i_arbiter.err_align or i_misaligned) and (not ctrl_i(ctrl_bus_ierr_ack_c));
|
|
i_arbiter.err_bus <= (i_arbiter.err_bus or (not or_all_f(i_arbiter.timeout)) or i_bus_err_i) and (not ctrl_i(ctrl_bus_ierr_ack_c));
|
|
if (i_arbiter.err_align = '1') or (i_arbiter.err_bus = '1') then -- any error?
|
|
if (ctrl_i(ctrl_bus_ierr_ack_c) = '1') then -- wait for controller to acknowledge error
|
|
i_arbiter.rd_req <= '0';
|
end if;
|
end if;
|
when others => -- word
|
elsif (i_bus_ack_i = '1') then -- wait for normal termination
|
if (mar(1 downto 0) /= "00") then
|
i_arbiter.rd_req <= '0';
|
misaligned_data <= '1';
|
|
end if;
|
end if;
|
end case;
|
end if;
|
end process misaligned_d_check;
|
|
|
-- cancel bus access --
|
|
i_bus_cancel_o <= i_arbiter.rd_req and ctrl_i(ctrl_bus_ierr_ack_c);
|
|
end if;
|
|
end process ifetch_arbiter;
|
|
|
misaligned_i_check: process(ctrl_i, pc_i)
|
|
|
-- wait for bus transaction to finish --
|
|
i_wait_o <= i_arbiter.rd_req and (not i_bus_ack_i);
|
|
|
|
-- output instruction fetch error to controller --
|
|
ma_instr_o <= i_arbiter.err_align;
|
|
be_instr_o <= i_arbiter.err_bus;
|
|
|
|
-- instruction bus (read-only) --
|
|
i_bus_addr_o <= fetch_pc_i;
|
|
i_bus_wdata_o <= (others => '0');
|
|
i_bus_ben_o <= (others => '0');
|
|
i_bus_we_o <= '0';
|
|
i_bus_re_o <= ctrl_i(ctrl_bus_if_c) and (not i_misaligned); -- no actual read when misaligned
|
|
i_bus_fence_o <= ctrl_i(ctrl_bus_fencei_c);
|
|
instr_o <= i_bus_rdata_i;
|
|
|
|
|
|
-- Data Access Arbiter --------------------------------------------------------------------
|
|
-- -------------------------------------------------------------------------------------------
|
|
data_access_arbiter: process(rstn_i, clk_i)
|
begin
|
begin
|
-- check instruction access --
|
if (rstn_i = '0') then
|
misaligned_instr <= '0'; -- default
|
d_arbiter.rd_req <= '0';
|
if (CPU_EXTENSION_RISCV_C = true) then -- 16-bit and 32-bit instruction accesses
|
d_arbiter.wr_req <= '0';
|
misaligned_instr <= '0'; -- no alignment exceptions possible
|
d_arbiter.err_align <= '0';
|
else -- 32-bit instruction accesses only
|
d_arbiter.err_bus <= '0';
|
if (pc_i(1) = '1') then -- PC(0) is always zero
|
d_arbiter.timeout <= (others => '0');
|
misaligned_instr <= '1';
|
elsif rising_edge(clk_i) then
|
|
|
|
-- data access request --
|
|
if (d_arbiter.wr_req = '0') and (d_arbiter.rd_req = '0') then -- idle
|
|
d_arbiter.wr_req <= ctrl_i(ctrl_bus_wr_c);
|
|
d_arbiter.rd_req <= ctrl_i(ctrl_bus_rd_c);
|
|
d_arbiter.err_align <= d_misaligned;
|
|
d_arbiter.err_bus <= '0';
|
|
d_arbiter.timeout <= std_ulogic_vector(to_unsigned(MEM_EXT_TIMEOUT, index_size_f(MEM_EXT_TIMEOUT)));
|
|
else -- in progress
|
|
d_arbiter.timeout <= std_ulogic_vector(unsigned(d_arbiter.timeout) - 1);
|
|
d_arbiter.err_align <= (d_arbiter.err_align or d_misaligned) and (not ctrl_i(ctrl_bus_derr_ack_c));
|
|
d_arbiter.err_bus <= (d_arbiter.err_bus or (not or_all_f(d_arbiter.timeout)) or d_bus_err_i) and (not ctrl_i(ctrl_bus_derr_ack_c));
|
|
if (d_arbiter.err_align = '1') or (d_arbiter.err_bus = '1') then -- any error?
|
|
if (ctrl_i(ctrl_bus_derr_ack_c) = '1') then -- wait for controller to acknowledge error
|
|
d_arbiter.wr_req <= '0';
|
|
d_arbiter.rd_req <= '0';
|
|
end if;
|
|
elsif (d_bus_ack_i = '1') then -- wait for normal termination
|
|
d_arbiter.wr_req <= '0';
|
|
d_arbiter.rd_req <= '0';
|
end if;
|
end if;
|
end if;
|
end if;
|
end process misaligned_i_check;
|
|
|
-- cancel bus access --
|
|
d_bus_cancel_o <= (d_arbiter.wr_req or d_arbiter.rd_req) and ctrl_i(ctrl_bus_derr_ack_c);
|
|
end if;
|
|
end process data_access_arbiter;
|
|
|
|
|
|
-- wait for bus transaction to finish --
|
|
d_wait_o <= (d_arbiter.wr_req or d_arbiter.rd_req) and (not d_bus_ack_i);
|
|
|
|
-- output data access error to controller --
|
|
ma_load_o <= d_arbiter.rd_req and d_arbiter.err_align;
|
|
be_load_o <= d_arbiter.rd_req and d_arbiter.err_bus;
|
|
ma_store_o <= d_arbiter.wr_req and d_arbiter.err_align;
|
|
be_store_o <= d_arbiter.wr_req and d_arbiter.err_bus;
|
|
|
|
-- data bus --
|
|
d_bus_addr_o <= mar;
|
|
d_bus_wdata_o <= d_bus_wdata;
|
|
d_bus_ben_o <= d_bus_ben;
|
|
d_bus_we_o <= ctrl_i(ctrl_bus_wr_c) and (not d_misaligned); -- no actual write when misaligned
|
|
d_bus_re_o <= ctrl_i(ctrl_bus_rd_c) and (not d_misaligned); -- no actual read when misaligned
|
|
d_bus_fence_o <= ctrl_i(ctrl_bus_fence_c);
|
|
d_bus_rdata <= d_bus_rdata_i;
|
|
|
|
|
end neorv32_cpu_bus_rtl;
|
end neorv32_cpu_bus_rtl;
|
|
|
No newline at end of file
|
No newline at end of file
|