1
1
-- ================================================================================ --
2
2
-- NEORV32 SoC - Custom Functions Subsystem (CFS) --
3
3
-- -------------------------------------------------------------------------------- --
4
- -- Intended for tightly-coupled, application-specific custom co-processors. This --
5
- -- module provides up to 64x 32-bit memory-mapped interface registers, one CPU --
6
- -- interrupt request signal and custom IO conduits for processor-external or chip- --
7
- -- external interface. --
8
- -- -------------------------------------------------------------------------------- --
9
4
-- The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 --
10
5
-- Copyright (c) NEORV32 contributors. --
11
6
-- Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. --
@@ -23,8 +18,8 @@ use neorv32.neorv32_package.all;
23
18
entity neorv32_cfs is
24
19
generic (
25
20
CFS_CONFIG : std_ulogic_vector (31 downto 0 ); -- custom CFS configuration generic
26
- CFS_IN_SIZE : natural ; -- size of CFS input conduit in bits
27
- CFS_OUT_SIZE : natural -- size of CFS output conduit in bits
21
+ CFS_IN_SIZE : natural range 0 to 4096 ; -- size of CFS input conduit in bits
22
+ CFS_OUT_SIZE : natural range 0 to 4096 -- size of CFS output conduit in bits
28
23
);
29
24
port (
30
25
clk_i : in std_ulogic ; -- global clock line
@@ -34,8 +29,8 @@ entity neorv32_cfs is
34
29
clkgen_en_o : out std_ulogic ; -- enable clock generator
35
30
clkgen_i : in std_ulogic_vector (7 downto 0 ); -- "clock" inputs
36
31
irq_o : out std_ulogic ; -- interrupt request
37
- cfs_in_i : in std_ulogic_vector (CFS_IN_SIZE- 1 downto 0 ); -- custom inputs
38
- cfs_out_o : out std_ulogic_vector (CFS_OUT_SIZE- 1 downto 0 ) -- custom outputs
32
+ cfs_in_i : in std_ulogic_vector (CFS_IN_SIZE- 1 downto 0 ); -- custom inputs conduit
33
+ cfs_out_o : out std_ulogic_vector (CFS_OUT_SIZE- 1 downto 0 ) -- custom outputs conduit
39
34
);
40
35
end neorv32_cfs ;
41
36
71
66
-- -------------------------------------------------------------------------------------------
72
67
-- The CFS can be reset using the global rstn_i signal. This signal should be used as asynchronous reset and is active-low.
73
68
-- Note that rstn_i can be asserted by a processor-external reset, the on-chip debugger and also by the watchdog.
74
- --
75
- -- Most default peripheral devices of the NEORV32 do NOT use a dedicated hardware reset at all. Instead, these units are
76
- -- reset by writing ZERO to a specific "control register" located right at the beginning of the device's address space
77
- -- (so this register is cleared at first). The crt0 start-up code writes ZERO to every single address in the processor's
78
- -- IO space - including the CFS. Make sure that this initial clearing does not cause any unintended CFS actions.
79
69
80
70
81
71
-- Clock System ---------------------------------------------------------------------------
84
74
-- Actually, these signals should not be used as direct clock signals, but as *clock enable* signals.
85
75
-- clkgen_i is always synchronous to the main system clock (clk_i).
86
76
--
87
- -- The following clock dividers are available:
77
+ -- The following pre-scaled clock enabled are available:
88
78
-- > clkgen_i(clk_div2_c) -> MAIN_CLK/2
89
79
-- > clkgen_i(clk_div4_c) -> MAIN_CLK/4
90
80
-- > clkgen_i(clk_div8_c) -> MAIN_CLK/8
96
86
--
97
87
-- For instance, if you want to drive a clock process at MAIN_CLK/8 clock speed you can use the following construct:
98
88
--
99
- -- if (rstn_i = '0') then -- async and low-active reset (if required at all)
100
- -- ...
101
- -- elsif rising_edge(clk_i) then -- always use the main clock for all clock processes
89
+ -- if rising_edge(clk_i) then -- always use the main clock for all clock processes
102
90
-- if (clkgen_i(clk_div8_c) = '1') then -- the div8 "clock" is actually a clock enable
103
91
-- ...
104
92
-- end if;
107
95
-- The clkgen_i input clocks are available when at least one IO/peripheral device (for example UART0) requires the clocks
108
96
-- generated by the clock generator. The CFS can enable the clock generator by itself by setting the clkgen_en_o signal high.
109
97
-- The CFS cannot ensure to deactivate the clock generator by setting the clkgen_en_o signal low as other peripherals might
110
- -- still keep the generator activated. Make sure to deactivate the CFS's clkgen_en_o if no clocks are required in here to
111
- -- reduce dynamic power consumption.
98
+ -- still keep the generator activated. Make sure to deactivate the CFS's clkgen_en_o if no scaled clocks are required in here
99
+ -- to reduce dynamic power consumption.
112
100
113
101
clkgen_en_o <= '0' ; -- not used for this minimal example
114
102
0 commit comments