Line 43... |
Line 43... |
library neorv32;
|
library neorv32;
|
use neorv32.neorv32_package.all;
|
use neorv32.neorv32_package.all;
|
|
|
entity neorv32_cfs is
|
entity neorv32_cfs is
|
generic (
|
generic (
|
CFS_CONFIG : std_ulogic_vector(31 downto 0) := x"00000000" -- custom CFS configuration conduit generic
|
CFS_CONFIG : std_ulogic_vector(31 downto 0); -- custom CFS configuration generic
|
|
CFS_IN_SIZE : positive := 32; -- size of CFS input conduit in bits
|
|
CFS_OUT_SIZE : positive := 32 -- size of CFS output conduit in bits
|
);
|
);
|
port (
|
port (
|
-- host access --
|
-- host access --
|
clk_i : in std_ulogic; -- global clock line
|
clk_i : in std_ulogic; -- global clock line
|
rstn_i : in std_ulogic; -- global reset line, low-active, use as async
|
rstn_i : in std_ulogic; -- global reset line, low-active, use as async
|
Line 64... |
Line 66... |
sleep_i : in std_ulogic; -- set if cpu is in sleep mode
|
sleep_i : in std_ulogic; -- set if cpu is in sleep mode
|
-- interrupt --
|
-- interrupt --
|
irq_o : out std_ulogic; -- interrupt request
|
irq_o : out std_ulogic; -- interrupt request
|
irq_ack_i : in std_ulogic; -- interrupt acknowledge
|
irq_ack_i : in std_ulogic; -- interrupt acknowledge
|
-- custom io (conduits) --
|
-- custom io (conduits) --
|
cfs_in_i : in std_ulogic_vector(31 downto 0); -- custom inputs
|
cfs_in_i : in std_ulogic_vector(CFS_IN_SIZE-1 downto 0); -- custom inputs
|
cfs_out_o : out std_ulogic_vector(31 downto 0) -- custom outputs
|
cfs_out_o : out std_ulogic_vector(CFS_OUT_SIZE-1 downto 0) -- custom outputs
|
);
|
);
|
end neorv32_cfs;
|
end neorv32_cfs;
|
|
|
architecture neorv32_cfs_rtl of neorv32_cfs is
|
architecture neorv32_cfs_rtl of neorv32_cfs is
|
|
|
Line 98... |
Line 100... |
addr <= cfs_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
|
addr <= cfs_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
|
wren <= acc_en and wren_i; -- full 32-bit word write enable
|
wren <= acc_en and wren_i; -- full 32-bit word write enable
|
rden <= acc_en and rden_i; -- the read access is always a full 32-bit word wide; if required, the byte/half-word select/masking is done in the CPU
|
rden <= acc_en and rden_i; -- the read access is always a full 32-bit word wide; if required, the byte/half-word select/masking is done in the CPU
|
|
|
|
|
-- CFS Generic ----------------------------------------------------------------------------
|
-- CFS Generics ---------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- In its default version, the CFS provides a single generic: CFS_CONFIG. This generic can be set using the processor top's IO_CFS_CONFIG generic.
|
-- In its default version, the CFS provides the configuration generics. single generic:
|
-- It is intended as a "conduit" to propagate custom implementation option from the top down to this entiy.
|
-- CFS_IN_SIZE configures the size (in bits) of the CFS input conduit cfs_in_i
|
|
-- CFS_OUT_SIZE configures the size (in bits) of the CFS output conduit cfs_out_o
|
|
-- CFS_CONFIG is a blank 32-bit generic. It is intended as a "generic conduit" to propagate custom configuration flags from the top entity down to this entiy.
|
|
|
|
|
-- CFS IOs --------------------------------------------------------------------------------
|
-- CFS IOs --------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- By default, the CFS provides two IO signals (cfs_in_i and cfs_out_o) that are available at the processor top entity.
|
-- By default, the CFS provides two IO signals (cfs_in_i and cfs_out_o) that are available at the processor top entity.
|
Line 204... |
Line 208... |
-- ack_o <= rden; -- use this construct if your CFS is read-only
|
-- ack_o <= rden; -- use this construct if your CFS is read-only
|
-- ack_o <= wren; -- use this construct if your CFS is write-only
|
-- ack_o <= wren; -- use this construct if your CFS is write-only
|
-- ack_o <= ... -- or define the ACK by yourself (example: some registers are read-only, some others can only be written, ...)
|
-- ack_o <= ... -- or define the ACK by yourself (example: some registers are read-only, some others can only be written, ...)
|
|
|
-- write access --
|
-- write access --
|
for i in 0 to 3 loop -- iterate over all 4 bytes in a word
|
for i in 0 to 3 loop
|
if (wren = '1') then -- word-wide write-access only!
|
if (wren = '1') then -- word-wide write-access only!
|
case addr is -- make sure to use the internal 'addr' signal for the read/write interface
|
case addr is -- make sure to use the internal 'addr' signal for the read/write interface
|
when cfs_reg0_addr_c => cfs_reg_wr(0) <= data_i; -- for example: control register
|
when cfs_reg0_addr_c => cfs_reg_wr(0) <= data_i; -- for example: control register
|
when cfs_reg1_addr_c => cfs_reg_wr(1) <= data_i; -- for example: data in/out fifo
|
when cfs_reg1_addr_c => cfs_reg_wr(1) <= data_i; -- for example: data in/out fifo
|
when cfs_reg2_addr_c => cfs_reg_wr(2) <= data_i; -- for example: command fifo
|
when cfs_reg2_addr_c => cfs_reg_wr(2) <= data_i; -- for example: command fifo
|