1 |
2 |
zero_gravi |
-- #################################################################################################
|
2 |
|
|
-- # << NEORV32 - Main VHDL package file >> #
|
3 |
|
|
-- # ********************************************************************************************* #
|
4 |
|
|
-- # BSD 3-Clause License #
|
5 |
|
|
-- # #
|
6 |
42 |
zero_gravi |
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved. #
|
7 |
2 |
zero_gravi |
-- # #
|
8 |
|
|
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
9 |
|
|
-- # permitted provided that the following conditions are met: #
|
10 |
|
|
-- # #
|
11 |
|
|
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
12 |
|
|
-- # conditions and the following disclaimer. #
|
13 |
|
|
-- # #
|
14 |
|
|
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
|
15 |
|
|
-- # conditions and the following disclaimer in the documentation and/or other materials #
|
16 |
|
|
-- # provided with the distribution. #
|
17 |
|
|
-- # #
|
18 |
|
|
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
|
19 |
|
|
-- # endorse or promote products derived from this software without specific prior written #
|
20 |
|
|
-- # permission. #
|
21 |
|
|
-- # #
|
22 |
|
|
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
|
23 |
|
|
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
|
24 |
|
|
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
|
25 |
|
|
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
|
26 |
|
|
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
|
27 |
|
|
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
|
28 |
|
|
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
|
29 |
|
|
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
|
30 |
|
|
-- # OF THE POSSIBILITY OF SUCH DAMAGE. #
|
31 |
|
|
-- # ********************************************************************************************* #
|
32 |
|
|
-- # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
33 |
|
|
-- #################################################################################################
|
34 |
|
|
|
35 |
|
|
library ieee;
|
36 |
|
|
use ieee.std_logic_1164.all;
|
37 |
|
|
use ieee.numeric_std.all;
|
38 |
|
|
|
39 |
|
|
package neorv32_package is
|
40 |
|
|
|
41 |
36 |
zero_gravi |
-- Architecture Configuration -------------------------------------------------------------
|
42 |
|
|
-- -------------------------------------------------------------------------------------------
|
43 |
40 |
zero_gravi |
-- address space --
|
44 |
|
|
constant ispace_base_c : std_ulogic_vector(31 downto 0) := x"00000000"; -- default instruction memory address space base address
|
45 |
|
|
constant dspace_base_c : std_ulogic_vector(31 downto 0) := x"80000000"; -- default data memory address space base address
|
46 |
36 |
zero_gravi |
|
47 |
40 |
zero_gravi |
-- CPU core --
|
48 |
66 |
zero_gravi |
constant dedicated_reset_c : boolean := false; -- use dedicated hardware reset value for UNCRITICAL registers (FALSE=reset value is irrelevant (might simplify HW), default; TRUE=defined LOW reset value)
|
49 |
56 |
zero_gravi |
constant cp_timeout_en_c : boolean := false; -- auto-terminate pending co-processor operations after 256 cycles (for debugging only), default = false
|
50 |
40 |
zero_gravi |
|
51 |
54 |
zero_gravi |
-- "critical" number of implemented PMP regions --
|
52 |
|
|
-- if more PMP regions (> pmp_num_regions_critical_c) are defined, another register stage is automatically inserted into the memory interfaces
|
53 |
|
|
-- increasing instruction fetch & data access latency by +1 cycle but also reducing critical path length
|
54 |
|
|
constant pmp_num_regions_critical_c : natural := 8; -- default=8
|
55 |
47 |
zero_gravi |
|
56 |
57 |
zero_gravi |
-- "response time window" for processor-internal memories and IO devices
|
57 |
|
|
constant max_proc_int_response_time_c : natural := 15; -- cycles after which an *unacknowledged* internal bus access will timeout and trigger a bus fault exception (min 2)
|
58 |
|
|
|
59 |
59 |
zero_gravi |
-- jtag tap - identifier --
|
60 |
|
|
constant jtag_tap_idcode_version_c : std_ulogic_vector(03 downto 0) := x"0"; -- version
|
61 |
|
|
constant jtag_tap_idcode_partid_c : std_ulogic_vector(15 downto 0) := x"cafe"; -- part number
|
62 |
|
|
constant jtag_tap_idcode_manid_c : std_ulogic_vector(10 downto 0) := "00000000000"; -- manufacturer id
|
63 |
|
|
|
64 |
61 |
zero_gravi |
-- Architecture Constants (do not modify!) ------------------------------------------------
|
65 |
|
|
-- -------------------------------------------------------------------------------------------
|
66 |
62 |
zero_gravi |
constant data_width_c : natural := 32; -- native data path width - do not change!
|
67 |
67 |
zero_gravi |
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01060301"; -- no touchy!
|
68 |
62 |
zero_gravi |
constant archid_c : natural := 19; -- official NEORV32 architecture ID - hands off!
|
69 |
61 |
zero_gravi |
|
70 |
|
|
-- External Interface Types ---------------------------------------------------------------
|
71 |
|
|
-- -------------------------------------------------------------------------------------------
|
72 |
|
|
type sdata_8x32_t is array (0 to 7) of std_ulogic_vector(31 downto 0);
|
73 |
|
|
type sdata_8x32r_t is array (0 to 7) of std_logic_vector(31 downto 0); -- resolved type
|
74 |
|
|
|
75 |
|
|
-- Internal Interface Types ---------------------------------------------------------------
|
76 |
|
|
-- -------------------------------------------------------------------------------------------
|
77 |
|
|
type pmp_ctrl_if_t is array (0 to 63) of std_ulogic_vector(07 downto 0);
|
78 |
|
|
type pmp_addr_if_t is array (0 to 63) of std_ulogic_vector(33 downto 0);
|
79 |
|
|
type cp_data_if_t is array (0 to 3) of std_ulogic_vector(data_width_c-1 downto 0);
|
80 |
|
|
|
81 |
|
|
-- Internal Memory Types Configuration Types ----------------------------------------------
|
82 |
|
|
-- -------------------------------------------------------------------------------------------
|
83 |
|
|
type mem32_t is array (natural range <>) of std_ulogic_vector(31 downto 0); -- memory with 32-bit entries
|
84 |
|
|
type mem8_t is array (natural range <>) of std_ulogic_vector(07 downto 0); -- memory with 8-bit entries
|
85 |
|
|
|
86 |
12 |
zero_gravi |
-- Helper Functions -----------------------------------------------------------------------
|
87 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
88 |
|
|
function index_size_f(input : natural) return natural;
|
89 |
|
|
function cond_sel_natural_f(cond : boolean; val_t : natural; val_f : natural) return natural;
|
90 |
56 |
zero_gravi |
function cond_sel_int_f(cond : boolean; val_t : integer; val_f : integer) return integer;
|
91 |
2 |
zero_gravi |
function cond_sel_stdulogicvector_f(cond : boolean; val_t : std_ulogic_vector; val_f : std_ulogic_vector) return std_ulogic_vector;
|
92 |
56 |
zero_gravi |
function cond_sel_stdulogic_f(cond : boolean; val_t : std_ulogic; val_f : std_ulogic) return std_ulogic;
|
93 |
50 |
zero_gravi |
function cond_sel_string_f(cond : boolean; val_t : string; val_f : string) return string;
|
94 |
2 |
zero_gravi |
function bool_to_ulogic_f(cond : boolean) return std_ulogic;
|
95 |
60 |
zero_gravi |
function or_reduce_f(a : std_ulogic_vector) return std_ulogic;
|
96 |
|
|
function and_reduce_f(a : std_ulogic_vector) return std_ulogic;
|
97 |
|
|
function xor_reduce_f(a : std_ulogic_vector) return std_ulogic;
|
98 |
6 |
zero_gravi |
function to_hexchar_f(input : std_ulogic_vector(3 downto 0)) return character;
|
99 |
40 |
zero_gravi |
function hexchar_to_stdulogicvector_f(input : character) return std_ulogic_vector;
|
100 |
32 |
zero_gravi |
function bit_rev_f(input : std_ulogic_vector) return std_ulogic_vector;
|
101 |
36 |
zero_gravi |
function is_power_of_two_f(input : natural) return boolean;
|
102 |
40 |
zero_gravi |
function bswap32_f(input : std_ulogic_vector) return std_ulogic_vector;
|
103 |
62 |
zero_gravi |
function char_to_lower_f(ch : character) return character;
|
104 |
61 |
zero_gravi |
function str_equal_f(str0 : string; str1 : string) return boolean;
|
105 |
63 |
zero_gravi |
function popcount_f(input : std_ulogic_vector) return natural;
|
106 |
|
|
function leading_zeros_f(input : std_ulogic_vector) return natural;
|
107 |
61 |
zero_gravi |
impure function mem32_init_f(init : mem32_t; depth : natural) return mem32_t;
|
108 |
2 |
zero_gravi |
|
109 |
61 |
zero_gravi |
-- Internal (auto-generated) Configurations -----------------------------------------------
|
110 |
56 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
111 |
61 |
zero_gravi |
constant def_rst_val_c : std_ulogic := cond_sel_stdulogic_f(dedicated_reset_c, '0', '-');
|
112 |
56 |
zero_gravi |
|
113 |
23 |
zero_gravi |
-- Processor-Internal Address Space Layout ------------------------------------------------
|
114 |
|
|
-- -------------------------------------------------------------------------------------------
|
115 |
34 |
zero_gravi |
-- Internal Instruction Memory (IMEM) and Date Memory (DMEM) --
|
116 |
39 |
zero_gravi |
constant imem_base_c : std_ulogic_vector(data_width_c-1 downto 0) := ispace_base_c; -- internal instruction memory base address
|
117 |
|
|
constant dmem_base_c : std_ulogic_vector(data_width_c-1 downto 0) := dspace_base_c; -- internal data memory base address
|
118 |
42 |
zero_gravi |
--> internal data/instruction memory sizes are configured via top's generics
|
119 |
2 |
zero_gravi |
|
120 |
64 |
zero_gravi |
-- !!! IMPORTANT: The base address of each component/module has to be aligned to the !!!
|
121 |
|
|
-- !!! total size of the module's occupied address space. The occupied address space !!!
|
122 |
|
|
-- !!! has to be a power of two (minimum 4 bytes). Address spaces must not overlap. !!!
|
123 |
|
|
|
124 |
23 |
zero_gravi |
-- Internal Bootloader ROM --
|
125 |
61 |
zero_gravi |
-- Actual bootloader size is determined during runtime via the length of the bootloader initialization image
|
126 |
56 |
zero_gravi |
constant boot_rom_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffff0000"; -- bootloader base address, fixed!
|
127 |
61 |
zero_gravi |
constant boot_rom_max_size_c : natural := 32*1024; -- max module's address space size in bytes, fixed!
|
128 |
23 |
zero_gravi |
|
129 |
59 |
zero_gravi |
-- On-Chip Debugger: Debug Module --
|
130 |
|
|
constant dm_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffff800"; -- base address, fixed!
|
131 |
61 |
zero_gravi |
constant dm_size_c : natural := 4*32*4; -- debug ROM address space size in bytes, fixed
|
132 |
59 |
zero_gravi |
constant dm_code_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffff800";
|
133 |
|
|
constant dm_pbuf_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffff880";
|
134 |
|
|
constant dm_data_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffff900";
|
135 |
|
|
constant dm_sreg_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffff980";
|
136 |
|
|
|
137 |
2 |
zero_gravi |
-- IO: Peripheral Devices ("IO") Area --
|
138 |
|
|
-- Control register(s) (including the device-enable) should be located at the base address of each device
|
139 |
60 |
zero_gravi |
constant io_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe00";
|
140 |
61 |
zero_gravi |
constant io_size_c : natural := 512; -- IO address space size in bytes, fixed!
|
141 |
2 |
zero_gravi |
|
142 |
47 |
zero_gravi |
-- Custom Functions Subsystem (CFS) --
|
143 |
60 |
zero_gravi |
constant cfs_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe00"; -- base address
|
144 |
61 |
zero_gravi |
constant cfs_size_c : natural := 32*4; -- module's address space in bytes
|
145 |
60 |
zero_gravi |
constant cfs_reg0_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe00";
|
146 |
|
|
constant cfs_reg1_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe04";
|
147 |
|
|
constant cfs_reg2_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe08";
|
148 |
|
|
constant cfs_reg3_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe0c";
|
149 |
|
|
constant cfs_reg4_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe10";
|
150 |
|
|
constant cfs_reg5_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe14";
|
151 |
|
|
constant cfs_reg6_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe18";
|
152 |
|
|
constant cfs_reg7_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe1c";
|
153 |
|
|
constant cfs_reg8_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe20";
|
154 |
|
|
constant cfs_reg9_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe24";
|
155 |
|
|
constant cfs_reg10_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe28";
|
156 |
|
|
constant cfs_reg11_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe2c";
|
157 |
|
|
constant cfs_reg12_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe30";
|
158 |
|
|
constant cfs_reg13_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe34";
|
159 |
|
|
constant cfs_reg14_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe38";
|
160 |
|
|
constant cfs_reg15_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe3c";
|
161 |
|
|
constant cfs_reg16_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe40";
|
162 |
|
|
constant cfs_reg17_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe44";
|
163 |
|
|
constant cfs_reg18_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe48";
|
164 |
|
|
constant cfs_reg19_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe4c";
|
165 |
|
|
constant cfs_reg20_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe50";
|
166 |
|
|
constant cfs_reg21_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe54";
|
167 |
|
|
constant cfs_reg22_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe58";
|
168 |
|
|
constant cfs_reg23_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe5c";
|
169 |
|
|
constant cfs_reg24_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe60";
|
170 |
|
|
constant cfs_reg25_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe64";
|
171 |
|
|
constant cfs_reg26_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe68";
|
172 |
|
|
constant cfs_reg27_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe6c";
|
173 |
|
|
constant cfs_reg28_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe70";
|
174 |
|
|
constant cfs_reg29_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe74";
|
175 |
|
|
constant cfs_reg30_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe78";
|
176 |
|
|
constant cfs_reg31_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe7c";
|
177 |
47 |
zero_gravi |
|
178 |
60 |
zero_gravi |
-- Pulse-Width Modulation Controller (PWM) --
|
179 |
|
|
constant pwm_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe80"; -- base address
|
180 |
61 |
zero_gravi |
constant pwm_size_c : natural := 16*4; -- module's address space size in bytes
|
181 |
60 |
zero_gravi |
constant pwm_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe80";
|
182 |
|
|
constant pwm_duty0_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe84";
|
183 |
|
|
constant pwm_duty1_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe88";
|
184 |
|
|
constant pwm_duty2_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe8c";
|
185 |
|
|
constant pwm_duty3_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe90";
|
186 |
|
|
constant pwm_duty4_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe94";
|
187 |
|
|
constant pwm_duty5_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe98";
|
188 |
|
|
constant pwm_duty6_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffe9c";
|
189 |
|
|
constant pwm_duty7_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffea0";
|
190 |
|
|
constant pwm_duty8_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffea4";
|
191 |
|
|
constant pwm_duty9_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffea8";
|
192 |
|
|
constant pwm_duty10_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffeac";
|
193 |
|
|
constant pwm_duty11_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffeb0";
|
194 |
|
|
constant pwm_duty12_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffeb4";
|
195 |
|
|
constant pwm_duty13_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffeb8";
|
196 |
|
|
constant pwm_duty14_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffebc";
|
197 |
|
|
|
198 |
63 |
zero_gravi |
-- Stream Link Interface (SLINK) --
|
199 |
61 |
zero_gravi |
constant slink_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"fffffec0"; -- base address
|
200 |
|
|
constant slink_size_c : natural := 16*4; -- module's address space size in bytes
|
201 |
60 |
zero_gravi |
|
202 |
|
|
-- reserved --
|
203 |
|
|
--constant reserved_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff00"; -- base address
|
204 |
63 |
zero_gravi |
--constant reserved_size_c : natural := 16*4; -- module's address space size in bytes
|
205 |
60 |
zero_gravi |
|
206 |
63 |
zero_gravi |
-- reserved --
|
207 |
|
|
--constant reserved_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff40"; -- base address
|
208 |
|
|
--constant reserved_size_c : natural := 8*4; -- module's address space size in bytes
|
209 |
|
|
|
210 |
67 |
zero_gravi |
-- General Purpose Timer (GPTMR) --
|
211 |
|
|
constant gptmr_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff60"; -- base address
|
212 |
|
|
constant gptmr_size_c : natural := 4*4; -- module's address space size in bytes
|
213 |
|
|
constant gptmr_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff60";
|
214 |
|
|
constant gptmr_thres_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff64";
|
215 |
|
|
constant gptmr_count_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff68";
|
216 |
|
|
--constant gptmr_reserve_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff6c";
|
217 |
63 |
zero_gravi |
|
218 |
|
|
-- reserved --
|
219 |
|
|
--constant reserved_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff70"; -- base address
|
220 |
|
|
--constant reserved_size_c : natural := 2*4; -- module's address space size in bytes
|
221 |
|
|
|
222 |
|
|
-- reserved --
|
223 |
|
|
--constant reserved_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff78"; -- base address
|
224 |
66 |
zero_gravi |
--constant reserved_size_c : natural := 1*4; -- module's address space size in bytes
|
225 |
63 |
zero_gravi |
|
226 |
66 |
zero_gravi |
-- Bus Access Monitor (BUSKEEPER) --
|
227 |
|
|
constant buskeeper_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff7c"; -- base address
|
228 |
|
|
constant buskeeper_size_c : natural := 1*4; -- module's address space size in bytes
|
229 |
|
|
|
230 |
61 |
zero_gravi |
-- External Interrupt Controller (XIRQ) --
|
231 |
|
|
constant xirq_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff80"; -- base address
|
232 |
|
|
constant xirq_size_c : natural := 4*4; -- module's address space size in bytes
|
233 |
|
|
constant xirq_enable_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff80";
|
234 |
|
|
constant xirq_pending_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff84";
|
235 |
|
|
constant xirq_source_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff88";
|
236 |
62 |
zero_gravi |
--constant xirq_reserved_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff8c";
|
237 |
2 |
zero_gravi |
|
238 |
|
|
-- Machine System Timer (MTIME) --
|
239 |
56 |
zero_gravi |
constant mtime_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff90"; -- base address
|
240 |
61 |
zero_gravi |
constant mtime_size_c : natural := 4*4; -- module's address space size in bytes
|
241 |
56 |
zero_gravi |
constant mtime_time_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff90";
|
242 |
|
|
constant mtime_time_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff94";
|
243 |
|
|
constant mtime_cmp_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff98";
|
244 |
|
|
constant mtime_cmp_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff9c";
|
245 |
2 |
zero_gravi |
|
246 |
58 |
zero_gravi |
-- Primary Universal Asynchronous Receiver/Transmitter (UART0) --
|
247 |
56 |
zero_gravi |
constant uart0_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa0"; -- base address
|
248 |
61 |
zero_gravi |
constant uart0_size_c : natural := 2*4; -- module's address space size in bytes
|
249 |
56 |
zero_gravi |
constant uart0_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa0";
|
250 |
|
|
constant uart0_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa4";
|
251 |
2 |
zero_gravi |
|
252 |
|
|
-- Serial Peripheral Interface (SPI) --
|
253 |
56 |
zero_gravi |
constant spi_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa8"; -- base address
|
254 |
61 |
zero_gravi |
constant spi_size_c : natural := 2*4; -- module's address space size in bytes
|
255 |
56 |
zero_gravi |
constant spi_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa8";
|
256 |
|
|
constant spi_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffac";
|
257 |
2 |
zero_gravi |
|
258 |
|
|
-- Two Wire Interface (TWI) --
|
259 |
56 |
zero_gravi |
constant twi_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffb0"; -- base address
|
260 |
61 |
zero_gravi |
constant twi_size_c : natural := 2*4; -- module's address space size in bytes
|
261 |
56 |
zero_gravi |
constant twi_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffb0";
|
262 |
|
|
constant twi_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffb4";
|
263 |
2 |
zero_gravi |
|
264 |
61 |
zero_gravi |
-- True Random Number Generator (TRNG) --
|
265 |
|
|
constant trng_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffb8"; -- base address
|
266 |
|
|
constant trng_size_c : natural := 1*4; -- module's address space size in bytes
|
267 |
|
|
constant trng_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffb8";
|
268 |
|
|
|
269 |
|
|
-- Watch Dog Timer (WDT) --
|
270 |
|
|
constant wdt_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffbc"; -- base address
|
271 |
|
|
constant wdt_size_c : natural := 1*4; -- module's address space size in bytes
|
272 |
|
|
constant wdt_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffbc";
|
273 |
|
|
|
274 |
63 |
zero_gravi |
-- General Purpose Input/Output Controller (GPIO) --
|
275 |
61 |
zero_gravi |
constant gpio_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc0"; -- base address
|
276 |
|
|
constant gpio_size_c : natural := 4*4; -- module's address space size in bytes
|
277 |
|
|
constant gpio_in_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc0";
|
278 |
|
|
constant gpio_in_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc4";
|
279 |
|
|
constant gpio_out_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc8";
|
280 |
|
|
constant gpio_out_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffcc";
|
281 |
2 |
zero_gravi |
|
282 |
58 |
zero_gravi |
-- Secondary Universal Asynchronous Receiver/Transmitter (UART1) --
|
283 |
56 |
zero_gravi |
constant uart1_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd0"; -- base address
|
284 |
61 |
zero_gravi |
constant uart1_size_c : natural := 2*4; -- module's address space size in bytes
|
285 |
56 |
zero_gravi |
constant uart1_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd0";
|
286 |
|
|
constant uart1_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd4";
|
287 |
50 |
zero_gravi |
|
288 |
52 |
zero_gravi |
-- Smart LED (WS2811/WS2812) Interface (NEOLED) --
|
289 |
56 |
zero_gravi |
constant neoled_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd8"; -- base address
|
290 |
61 |
zero_gravi |
constant neoled_size_c : natural := 2*4; -- module's address space size in bytes
|
291 |
56 |
zero_gravi |
constant neoled_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd8";
|
292 |
|
|
constant neoled_data_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffdc";
|
293 |
12 |
zero_gravi |
|
294 |
23 |
zero_gravi |
-- System Information Memory (SYSINFO) --
|
295 |
56 |
zero_gravi |
constant sysinfo_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffe0"; -- base address
|
296 |
61 |
zero_gravi |
constant sysinfo_size_c : natural := 8*4; -- module's address space size in bytes
|
297 |
12 |
zero_gravi |
|
298 |
59 |
zero_gravi |
-- Main CPU Control Bus -------------------------------------------------------------------
|
299 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
300 |
|
|
-- register file --
|
301 |
49 |
zero_gravi |
constant ctrl_rf_in_mux_c : natural := 0; -- input source select lsb (0=MEM, 1=ALU)
|
302 |
|
|
constant ctrl_rf_rs1_adr0_c : natural := 1; -- source register 1 address bit 0
|
303 |
|
|
constant ctrl_rf_rs1_adr1_c : natural := 2; -- source register 1 address bit 1
|
304 |
|
|
constant ctrl_rf_rs1_adr2_c : natural := 3; -- source register 1 address bit 2
|
305 |
|
|
constant ctrl_rf_rs1_adr3_c : natural := 4; -- source register 1 address bit 3
|
306 |
|
|
constant ctrl_rf_rs1_adr4_c : natural := 5; -- source register 1 address bit 4
|
307 |
|
|
constant ctrl_rf_rs2_adr0_c : natural := 6; -- source register 2 address bit 0
|
308 |
|
|
constant ctrl_rf_rs2_adr1_c : natural := 7; -- source register 2 address bit 1
|
309 |
|
|
constant ctrl_rf_rs2_adr2_c : natural := 8; -- source register 2 address bit 2
|
310 |
|
|
constant ctrl_rf_rs2_adr3_c : natural := 9; -- source register 2 address bit 3
|
311 |
|
|
constant ctrl_rf_rs2_adr4_c : natural := 10; -- source register 2 address bit 4
|
312 |
58 |
zero_gravi |
constant ctrl_rf_rd_adr0_c : natural := 11; -- destination register address bit 0
|
313 |
|
|
constant ctrl_rf_rd_adr1_c : natural := 12; -- destination register address bit 1
|
314 |
|
|
constant ctrl_rf_rd_adr2_c : natural := 13; -- destination register address bit 2
|
315 |
|
|
constant ctrl_rf_rd_adr3_c : natural := 14; -- destination register address bit 3
|
316 |
|
|
constant ctrl_rf_rd_adr4_c : natural := 15; -- destination register address bit 4
|
317 |
49 |
zero_gravi |
constant ctrl_rf_wb_en_c : natural := 16; -- write back enable
|
318 |
2 |
zero_gravi |
-- alu --
|
319 |
62 |
zero_gravi |
constant ctrl_alu_arith_c : natural := 17; -- ALU arithmetic command
|
320 |
|
|
constant ctrl_alu_logic0_c : natural := 18; -- ALU logic command bit 0
|
321 |
|
|
constant ctrl_alu_logic1_c : natural := 19; -- ALU logic command bit 1
|
322 |
|
|
constant ctrl_alu_func0_c : natural := 20; -- ALU function select command bit 0
|
323 |
|
|
constant ctrl_alu_func1_c : natural := 21; -- ALU function select command bit 1
|
324 |
|
|
constant ctrl_alu_addsub_c : natural := 22; -- 0=ADD, 1=SUB
|
325 |
|
|
constant ctrl_alu_opa_mux_c : natural := 23; -- operand A select (0=rs1, 1=PC)
|
326 |
|
|
constant ctrl_alu_opb_mux_c : natural := 24; -- operand B select (0=rs2, 1=IMM)
|
327 |
|
|
constant ctrl_alu_unsigned_c : natural := 25; -- is unsigned ALU operation
|
328 |
|
|
constant ctrl_alu_shift_dir_c : natural := 26; -- shift direction (0=left, 1=right)
|
329 |
|
|
constant ctrl_alu_shift_ar_c : natural := 27; -- is arithmetic shift
|
330 |
|
|
constant ctrl_alu_frm0_c : natural := 28; -- FPU rounding mode bit 0
|
331 |
|
|
constant ctrl_alu_frm1_c : natural := 29; -- FPU rounding mode bit 1
|
332 |
|
|
constant ctrl_alu_frm2_c : natural := 30; -- FPU rounding mode bit 2
|
333 |
2 |
zero_gravi |
-- bus interface --
|
334 |
62 |
zero_gravi |
constant ctrl_bus_size_lsb_c : natural := 31; -- transfer size lsb (00=byte, 01=half-word)
|
335 |
|
|
constant ctrl_bus_size_msb_c : natural := 32; -- transfer size msb (10=word, 11=?)
|
336 |
|
|
constant ctrl_bus_rd_c : natural := 33; -- read data request
|
337 |
|
|
constant ctrl_bus_wr_c : natural := 34; -- write data request
|
338 |
|
|
constant ctrl_bus_if_c : natural := 35; -- instruction fetch request
|
339 |
|
|
constant ctrl_bus_mo_we_c : natural := 36; -- memory address and data output register write enable
|
340 |
|
|
constant ctrl_bus_mi_we_c : natural := 37; -- memory data input register write enable
|
341 |
|
|
constant ctrl_bus_unsigned_c : natural := 38; -- is unsigned load
|
342 |
|
|
constant ctrl_bus_ierr_ack_c : natural := 39; -- acknowledge instruction fetch bus exceptions
|
343 |
|
|
constant ctrl_bus_derr_ack_c : natural := 40; -- acknowledge data access bus exceptions
|
344 |
|
|
constant ctrl_bus_fence_c : natural := 41; -- executed fence operation
|
345 |
|
|
constant ctrl_bus_fencei_c : natural := 42; -- executed fencei operation
|
346 |
|
|
constant ctrl_bus_lock_c : natural := 43; -- make atomic/exclusive access lock
|
347 |
|
|
constant ctrl_bus_de_lock_c : natural := 44; -- remove atomic/exclusive access
|
348 |
|
|
constant ctrl_bus_ch_lock_c : natural := 45; -- evaluate atomic/exclusive lock (SC operation)
|
349 |
26 |
zero_gravi |
-- co-processors --
|
350 |
62 |
zero_gravi |
constant ctrl_cp_id_lsb_c : natural := 46; -- cp select ID lsb
|
351 |
|
|
constant ctrl_cp_id_msb_c : natural := 47; -- cp select ID msb
|
352 |
44 |
zero_gravi |
-- instruction's control blocks (used by cpu co-processors) --
|
353 |
62 |
zero_gravi |
constant ctrl_ir_funct3_0_c : natural := 48; -- funct3 bit 0
|
354 |
|
|
constant ctrl_ir_funct3_1_c : natural := 49; -- funct3 bit 1
|
355 |
|
|
constant ctrl_ir_funct3_2_c : natural := 50; -- funct3 bit 2
|
356 |
|
|
constant ctrl_ir_funct12_0_c : natural := 51; -- funct12 bit 0
|
357 |
|
|
constant ctrl_ir_funct12_1_c : natural := 52; -- funct12 bit 1
|
358 |
|
|
constant ctrl_ir_funct12_2_c : natural := 53; -- funct12 bit 2
|
359 |
|
|
constant ctrl_ir_funct12_3_c : natural := 54; -- funct12 bit 3
|
360 |
|
|
constant ctrl_ir_funct12_4_c : natural := 55; -- funct12 bit 4
|
361 |
|
|
constant ctrl_ir_funct12_5_c : natural := 56; -- funct12 bit 5
|
362 |
|
|
constant ctrl_ir_funct12_6_c : natural := 57; -- funct12 bit 6
|
363 |
|
|
constant ctrl_ir_funct12_7_c : natural := 58; -- funct12 bit 7
|
364 |
|
|
constant ctrl_ir_funct12_8_c : natural := 59; -- funct12 bit 8
|
365 |
|
|
constant ctrl_ir_funct12_9_c : natural := 60; -- funct12 bit 9
|
366 |
|
|
constant ctrl_ir_funct12_10_c : natural := 61; -- funct12 bit 10
|
367 |
|
|
constant ctrl_ir_funct12_11_c : natural := 62; -- funct12 bit 11
|
368 |
|
|
constant ctrl_ir_opcode7_0_c : natural := 63; -- opcode7 bit 0
|
369 |
|
|
constant ctrl_ir_opcode7_1_c : natural := 64; -- opcode7 bit 1
|
370 |
|
|
constant ctrl_ir_opcode7_2_c : natural := 65; -- opcode7 bit 2
|
371 |
|
|
constant ctrl_ir_opcode7_3_c : natural := 66; -- opcode7 bit 3
|
372 |
|
|
constant ctrl_ir_opcode7_4_c : natural := 67; -- opcode7 bit 4
|
373 |
|
|
constant ctrl_ir_opcode7_5_c : natural := 68; -- opcode7 bit 5
|
374 |
|
|
constant ctrl_ir_opcode7_6_c : natural := 69; -- opcode7 bit 6
|
375 |
47 |
zero_gravi |
-- CPU status --
|
376 |
62 |
zero_gravi |
constant ctrl_priv_lvl_lsb_c : natural := 70; -- privilege level lsb
|
377 |
|
|
constant ctrl_priv_lvl_msb_c : natural := 71; -- privilege level msb
|
378 |
|
|
constant ctrl_sleep_c : natural := 72; -- set when CPU is in sleep mode
|
379 |
|
|
constant ctrl_trap_c : natural := 73; -- set when CPU is entering trap execution
|
380 |
|
|
constant ctrl_debug_running_c : natural := 74; -- CPU is in debug mode when set
|
381 |
2 |
zero_gravi |
-- control bus size --
|
382 |
62 |
zero_gravi |
constant ctrl_width_c : natural := 75; -- control bus size
|
383 |
2 |
zero_gravi |
|
384 |
47 |
zero_gravi |
-- Comparator Bus -------------------------------------------------------------------------
|
385 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
386 |
47 |
zero_gravi |
constant cmp_equal_c : natural := 0;
|
387 |
|
|
constant cmp_less_c : natural := 1; -- for signed and unsigned comparisons
|
388 |
2 |
zero_gravi |
|
389 |
|
|
-- RISC-V Opcode Layout -------------------------------------------------------------------
|
390 |
|
|
-- -------------------------------------------------------------------------------------------
|
391 |
|
|
constant instr_opcode_lsb_c : natural := 0; -- opcode bit 0
|
392 |
|
|
constant instr_opcode_msb_c : natural := 6; -- opcode bit 6
|
393 |
|
|
constant instr_rd_lsb_c : natural := 7; -- destination register address bit 0
|
394 |
|
|
constant instr_rd_msb_c : natural := 11; -- destination register address bit 4
|
395 |
|
|
constant instr_funct3_lsb_c : natural := 12; -- funct3 bit 0
|
396 |
|
|
constant instr_funct3_msb_c : natural := 14; -- funct3 bit 2
|
397 |
|
|
constant instr_rs1_lsb_c : natural := 15; -- source register 1 address bit 0
|
398 |
|
|
constant instr_rs1_msb_c : natural := 19; -- source register 1 address bit 4
|
399 |
|
|
constant instr_rs2_lsb_c : natural := 20; -- source register 2 address bit 0
|
400 |
|
|
constant instr_rs2_msb_c : natural := 24; -- source register 2 address bit 4
|
401 |
|
|
constant instr_funct7_lsb_c : natural := 25; -- funct7 bit 0
|
402 |
|
|
constant instr_funct7_msb_c : natural := 31; -- funct7 bit 6
|
403 |
|
|
constant instr_funct12_lsb_c : natural := 20; -- funct12 bit 0
|
404 |
|
|
constant instr_funct12_msb_c : natural := 31; -- funct12 bit 11
|
405 |
|
|
constant instr_imm12_lsb_c : natural := 20; -- immediate12 bit 0
|
406 |
|
|
constant instr_imm12_msb_c : natural := 31; -- immediate12 bit 11
|
407 |
|
|
constant instr_imm20_lsb_c : natural := 12; -- immediate20 bit 0
|
408 |
|
|
constant instr_imm20_msb_c : natural := 31; -- immediate20 bit 21
|
409 |
|
|
constant instr_csr_id_lsb_c : natural := 20; -- csr select bit 0
|
410 |
|
|
constant instr_csr_id_msb_c : natural := 31; -- csr select bit 11
|
411 |
39 |
zero_gravi |
constant instr_funct5_lsb_c : natural := 27; -- funct5 select bit 0
|
412 |
|
|
constant instr_funct5_msb_c : natural := 31; -- funct5 select bit 4
|
413 |
2 |
zero_gravi |
|
414 |
|
|
-- RISC-V Opcodes -------------------------------------------------------------------------
|
415 |
|
|
-- -------------------------------------------------------------------------------------------
|
416 |
|
|
-- alu --
|
417 |
|
|
constant opcode_lui_c : std_ulogic_vector(6 downto 0) := "0110111"; -- load upper immediate
|
418 |
|
|
constant opcode_auipc_c : std_ulogic_vector(6 downto 0) := "0010111"; -- add upper immediate to PC
|
419 |
|
|
constant opcode_alui_c : std_ulogic_vector(6 downto 0) := "0010011"; -- ALU operation with immediate (operation via funct3 and funct7)
|
420 |
|
|
constant opcode_alu_c : std_ulogic_vector(6 downto 0) := "0110011"; -- ALU operation (operation via funct3 and funct7)
|
421 |
|
|
-- control flow --
|
422 |
|
|
constant opcode_jal_c : std_ulogic_vector(6 downto 0) := "1101111"; -- jump and link
|
423 |
29 |
zero_gravi |
constant opcode_jalr_c : std_ulogic_vector(6 downto 0) := "1100111"; -- jump and link with register
|
424 |
2 |
zero_gravi |
constant opcode_branch_c : std_ulogic_vector(6 downto 0) := "1100011"; -- branch (condition set via funct3)
|
425 |
|
|
-- memory access --
|
426 |
|
|
constant opcode_load_c : std_ulogic_vector(6 downto 0) := "0000011"; -- load (data type via funct3)
|
427 |
|
|
constant opcode_store_c : std_ulogic_vector(6 downto 0) := "0100011"; -- store (data type via funct3)
|
428 |
|
|
-- system/csr --
|
429 |
8 |
zero_gravi |
constant opcode_fence_c : std_ulogic_vector(6 downto 0) := "0001111"; -- fence / fence.i
|
430 |
2 |
zero_gravi |
constant opcode_syscsr_c : std_ulogic_vector(6 downto 0) := "1110011"; -- system/csr access (type via funct3)
|
431 |
52 |
zero_gravi |
-- atomic memory access (A) --
|
432 |
39 |
zero_gravi |
constant opcode_atomic_c : std_ulogic_vector(6 downto 0) := "0101111"; -- atomic operations (A extension)
|
433 |
53 |
zero_gravi |
-- floating point operations (Zfinx-only) (F/D/H/Q) --
|
434 |
66 |
zero_gravi |
constant opcode_fop_c : std_ulogic_vector(6 downto 0) := "1010011"; -- dual/single operand instruction
|
435 |
2 |
zero_gravi |
|
436 |
|
|
-- RISC-V Funct3 --------------------------------------------------------------------------
|
437 |
|
|
-- -------------------------------------------------------------------------------------------
|
438 |
|
|
-- control flow --
|
439 |
|
|
constant funct3_beq_c : std_ulogic_vector(2 downto 0) := "000"; -- branch if equal
|
440 |
|
|
constant funct3_bne_c : std_ulogic_vector(2 downto 0) := "001"; -- branch if not equal
|
441 |
|
|
constant funct3_blt_c : std_ulogic_vector(2 downto 0) := "100"; -- branch if less than
|
442 |
|
|
constant funct3_bge_c : std_ulogic_vector(2 downto 0) := "101"; -- branch if greater than or equal
|
443 |
|
|
constant funct3_bltu_c : std_ulogic_vector(2 downto 0) := "110"; -- branch if less than (unsigned)
|
444 |
|
|
constant funct3_bgeu_c : std_ulogic_vector(2 downto 0) := "111"; -- branch if greater than or equal (unsigned)
|
445 |
|
|
-- memory access --
|
446 |
|
|
constant funct3_lb_c : std_ulogic_vector(2 downto 0) := "000"; -- load byte
|
447 |
|
|
constant funct3_lh_c : std_ulogic_vector(2 downto 0) := "001"; -- load half word
|
448 |
|
|
constant funct3_lw_c : std_ulogic_vector(2 downto 0) := "010"; -- load word
|
449 |
|
|
constant funct3_lbu_c : std_ulogic_vector(2 downto 0) := "100"; -- load byte (unsigned)
|
450 |
|
|
constant funct3_lhu_c : std_ulogic_vector(2 downto 0) := "101"; -- load half word (unsigned)
|
451 |
|
|
constant funct3_sb_c : std_ulogic_vector(2 downto 0) := "000"; -- store byte
|
452 |
|
|
constant funct3_sh_c : std_ulogic_vector(2 downto 0) := "001"; -- store half word
|
453 |
|
|
constant funct3_sw_c : std_ulogic_vector(2 downto 0) := "010"; -- store word
|
454 |
|
|
-- alu --
|
455 |
|
|
constant funct3_subadd_c : std_ulogic_vector(2 downto 0) := "000"; -- sub/add via funct7
|
456 |
|
|
constant funct3_sll_c : std_ulogic_vector(2 downto 0) := "001"; -- shift logical left
|
457 |
|
|
constant funct3_slt_c : std_ulogic_vector(2 downto 0) := "010"; -- set on less
|
458 |
|
|
constant funct3_sltu_c : std_ulogic_vector(2 downto 0) := "011"; -- set on less unsigned
|
459 |
|
|
constant funct3_xor_c : std_ulogic_vector(2 downto 0) := "100"; -- xor
|
460 |
|
|
constant funct3_sr_c : std_ulogic_vector(2 downto 0) := "101"; -- shift right via funct7
|
461 |
|
|
constant funct3_or_c : std_ulogic_vector(2 downto 0) := "110"; -- or
|
462 |
|
|
constant funct3_and_c : std_ulogic_vector(2 downto 0) := "111"; -- and
|
463 |
|
|
-- system/csr --
|
464 |
59 |
zero_gravi |
constant funct3_env_c : std_ulogic_vector(2 downto 0) := "000"; -- ecall, ebreak, mret, wfi, ...
|
465 |
2 |
zero_gravi |
constant funct3_csrrw_c : std_ulogic_vector(2 downto 0) := "001"; -- atomic r/w
|
466 |
|
|
constant funct3_csrrs_c : std_ulogic_vector(2 downto 0) := "010"; -- atomic read & set bit
|
467 |
|
|
constant funct3_csrrc_c : std_ulogic_vector(2 downto 0) := "011"; -- atomic read & clear bit
|
468 |
|
|
constant funct3_csrrwi_c : std_ulogic_vector(2 downto 0) := "101"; -- atomic r/w immediate
|
469 |
|
|
constant funct3_csrrsi_c : std_ulogic_vector(2 downto 0) := "110"; -- atomic read & set bit immediate
|
470 |
|
|
constant funct3_csrrci_c : std_ulogic_vector(2 downto 0) := "111"; -- atomic read & clear bit immediate
|
471 |
8 |
zero_gravi |
-- fence --
|
472 |
|
|
constant funct3_fence_c : std_ulogic_vector(2 downto 0) := "000"; -- fence - order IO/memory access (->NOP)
|
473 |
66 |
zero_gravi |
constant funct3_fencei_c : std_ulogic_vector(2 downto 0) := "001"; -- fencei - instruction stream sync
|
474 |
2 |
zero_gravi |
|
475 |
39 |
zero_gravi |
-- RISC-V Funct12 -------------------------------------------------------------------------
|
476 |
11 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
477 |
|
|
-- system --
|
478 |
|
|
constant funct12_ecall_c : std_ulogic_vector(11 downto 0) := x"000"; -- ECALL
|
479 |
|
|
constant funct12_ebreak_c : std_ulogic_vector(11 downto 0) := x"001"; -- EBREAK
|
480 |
|
|
constant funct12_mret_c : std_ulogic_vector(11 downto 0) := x"302"; -- MRET
|
481 |
|
|
constant funct12_wfi_c : std_ulogic_vector(11 downto 0) := x"105"; -- WFI
|
482 |
59 |
zero_gravi |
constant funct12_dret_c : std_ulogic_vector(11 downto 0) := x"7b2"; -- DRET
|
483 |
11 |
zero_gravi |
|
484 |
39 |
zero_gravi |
-- RISC-V Funct5 --------------------------------------------------------------------------
|
485 |
|
|
-- -------------------------------------------------------------------------------------------
|
486 |
|
|
-- atomic operations --
|
487 |
|
|
constant funct5_a_lr_c : std_ulogic_vector(4 downto 0) := "00010"; -- LR
|
488 |
|
|
constant funct5_a_sc_c : std_ulogic_vector(4 downto 0) := "00011"; -- SC
|
489 |
|
|
|
490 |
54 |
zero_gravi |
-- RISC-V Floating-Point Stuff ------------------------------------------------------------
|
491 |
52 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
492 |
54 |
zero_gravi |
-- formats --
|
493 |
|
|
constant float_single_c : std_ulogic_vector(1 downto 0) := "00"; -- single-precision (32-bit)
|
494 |
|
|
constant float_double_c : std_ulogic_vector(1 downto 0) := "01"; -- double-precision (64-bit)
|
495 |
|
|
constant float_half_c : std_ulogic_vector(1 downto 0) := "10"; -- half-precision (16-bit)
|
496 |
|
|
constant float_quad_c : std_ulogic_vector(1 downto 0) := "11"; -- quad-precision (128-bit)
|
497 |
52 |
zero_gravi |
|
498 |
54 |
zero_gravi |
-- number class flags --
|
499 |
|
|
constant fp_class_neg_inf_c : natural := 0; -- negative infinity
|
500 |
|
|
constant fp_class_neg_norm_c : natural := 1; -- negative normal number
|
501 |
|
|
constant fp_class_neg_denorm_c : natural := 2; -- negative subnormal number
|
502 |
|
|
constant fp_class_neg_zero_c : natural := 3; -- negative zero
|
503 |
|
|
constant fp_class_pos_zero_c : natural := 4; -- positive zero
|
504 |
|
|
constant fp_class_pos_denorm_c : natural := 5; -- positive subnormal number
|
505 |
|
|
constant fp_class_pos_norm_c : natural := 6; -- positive normal number
|
506 |
|
|
constant fp_class_pos_inf_c : natural := 7; -- positive infinity
|
507 |
|
|
constant fp_class_snan_c : natural := 8; -- signaling NaN (sNaN)
|
508 |
|
|
constant fp_class_qnan_c : natural := 9; -- quiet NaN (qNaN)
|
509 |
|
|
|
510 |
|
|
-- exception flags --
|
511 |
|
|
constant fp_exc_nv_c : natural := 0; -- invalid operation
|
512 |
|
|
constant fp_exc_dz_c : natural := 1; -- divide by zero
|
513 |
|
|
constant fp_exc_of_c : natural := 2; -- overflow
|
514 |
|
|
constant fp_exc_uf_c : natural := 3; -- underflow
|
515 |
|
|
constant fp_exc_nx_c : natural := 4; -- inexact
|
516 |
|
|
|
517 |
|
|
-- special values (single-precision) --
|
518 |
|
|
constant fp_single_qnan_c : std_ulogic_vector(31 downto 0) := x"7fc00000"; -- quiet NaN
|
519 |
|
|
constant fp_single_snan_c : std_ulogic_vector(31 downto 0) := x"7fa00000"; -- signaling NaN
|
520 |
|
|
constant fp_single_pos_inf_c : std_ulogic_vector(31 downto 0) := x"7f800000"; -- positive infinity
|
521 |
|
|
constant fp_single_neg_inf_c : std_ulogic_vector(31 downto 0) := x"ff800000"; -- negative infinity
|
522 |
|
|
constant fp_single_pos_zero_c : std_ulogic_vector(31 downto 0) := x"00000000"; -- positive zero
|
523 |
|
|
constant fp_single_neg_zero_c : std_ulogic_vector(31 downto 0) := x"80000000"; -- negative zero
|
524 |
|
|
|
525 |
29 |
zero_gravi |
-- RISC-V CSR Addresses -------------------------------------------------------------------
|
526 |
|
|
-- -------------------------------------------------------------------------------------------
|
527 |
56 |
zero_gravi |
-- <<< standard read/write CSRs >>> --
|
528 |
|
|
-- user floating-point CSRs --
|
529 |
52 |
zero_gravi |
constant csr_class_float_c : std_ulogic_vector(07 downto 0) := x"00"; -- floating point
|
530 |
|
|
constant csr_fflags_c : std_ulogic_vector(11 downto 0) := x"001";
|
531 |
|
|
constant csr_frm_c : std_ulogic_vector(11 downto 0) := x"002";
|
532 |
|
|
constant csr_fcsr_c : std_ulogic_vector(11 downto 0) := x"003";
|
533 |
56 |
zero_gravi |
-- machine trap setup --
|
534 |
63 |
zero_gravi |
constant csr_class_setup_c : std_ulogic_vector(08 downto 0) := x"30" & '0'; -- trap setup
|
535 |
42 |
zero_gravi |
constant csr_mstatus_c : std_ulogic_vector(11 downto 0) := x"300";
|
536 |
|
|
constant csr_misa_c : std_ulogic_vector(11 downto 0) := x"301";
|
537 |
|
|
constant csr_mie_c : std_ulogic_vector(11 downto 0) := x"304";
|
538 |
|
|
constant csr_mtvec_c : std_ulogic_vector(11 downto 0) := x"305";
|
539 |
|
|
constant csr_mcounteren_c : std_ulogic_vector(11 downto 0) := x"306";
|
540 |
62 |
zero_gravi |
--
|
541 |
|
|
constant csr_mstatush_c : std_ulogic_vector(11 downto 0) := x"310";
|
542 |
64 |
zero_gravi |
-- machine configuration --
|
543 |
|
|
constant csr_class_envcfg_c : std_ulogic_vector(06 downto 0) := x"3" & "000"; -- configuration
|
544 |
|
|
constant csr_menvcfg_c : std_ulogic_vector(11 downto 0) := x"30a";
|
545 |
|
|
constant csr_menvcfgh_c : std_ulogic_vector(11 downto 0) := x"31a";
|
546 |
56 |
zero_gravi |
-- machine counter setup --
|
547 |
|
|
constant csr_cnt_setup_c : std_ulogic_vector(06 downto 0) := x"3" & "001"; -- counter setup
|
548 |
42 |
zero_gravi |
constant csr_mcountinhibit_c : std_ulogic_vector(11 downto 0) := x"320";
|
549 |
|
|
constant csr_mhpmevent3_c : std_ulogic_vector(11 downto 0) := x"323";
|
550 |
|
|
constant csr_mhpmevent4_c : std_ulogic_vector(11 downto 0) := x"324";
|
551 |
|
|
constant csr_mhpmevent5_c : std_ulogic_vector(11 downto 0) := x"325";
|
552 |
|
|
constant csr_mhpmevent6_c : std_ulogic_vector(11 downto 0) := x"326";
|
553 |
|
|
constant csr_mhpmevent7_c : std_ulogic_vector(11 downto 0) := x"327";
|
554 |
|
|
constant csr_mhpmevent8_c : std_ulogic_vector(11 downto 0) := x"328";
|
555 |
|
|
constant csr_mhpmevent9_c : std_ulogic_vector(11 downto 0) := x"329";
|
556 |
|
|
constant csr_mhpmevent10_c : std_ulogic_vector(11 downto 0) := x"32a";
|
557 |
|
|
constant csr_mhpmevent11_c : std_ulogic_vector(11 downto 0) := x"32b";
|
558 |
|
|
constant csr_mhpmevent12_c : std_ulogic_vector(11 downto 0) := x"32c";
|
559 |
|
|
constant csr_mhpmevent13_c : std_ulogic_vector(11 downto 0) := x"32d";
|
560 |
|
|
constant csr_mhpmevent14_c : std_ulogic_vector(11 downto 0) := x"32e";
|
561 |
|
|
constant csr_mhpmevent15_c : std_ulogic_vector(11 downto 0) := x"32f";
|
562 |
|
|
constant csr_mhpmevent16_c : std_ulogic_vector(11 downto 0) := x"330";
|
563 |
|
|
constant csr_mhpmevent17_c : std_ulogic_vector(11 downto 0) := x"331";
|
564 |
|
|
constant csr_mhpmevent18_c : std_ulogic_vector(11 downto 0) := x"332";
|
565 |
|
|
constant csr_mhpmevent19_c : std_ulogic_vector(11 downto 0) := x"333";
|
566 |
|
|
constant csr_mhpmevent20_c : std_ulogic_vector(11 downto 0) := x"334";
|
567 |
|
|
constant csr_mhpmevent21_c : std_ulogic_vector(11 downto 0) := x"335";
|
568 |
|
|
constant csr_mhpmevent22_c : std_ulogic_vector(11 downto 0) := x"336";
|
569 |
|
|
constant csr_mhpmevent23_c : std_ulogic_vector(11 downto 0) := x"337";
|
570 |
|
|
constant csr_mhpmevent24_c : std_ulogic_vector(11 downto 0) := x"338";
|
571 |
|
|
constant csr_mhpmevent25_c : std_ulogic_vector(11 downto 0) := x"339";
|
572 |
|
|
constant csr_mhpmevent26_c : std_ulogic_vector(11 downto 0) := x"33a";
|
573 |
|
|
constant csr_mhpmevent27_c : std_ulogic_vector(11 downto 0) := x"33b";
|
574 |
|
|
constant csr_mhpmevent28_c : std_ulogic_vector(11 downto 0) := x"33c";
|
575 |
|
|
constant csr_mhpmevent29_c : std_ulogic_vector(11 downto 0) := x"33d";
|
576 |
|
|
constant csr_mhpmevent30_c : std_ulogic_vector(11 downto 0) := x"33e";
|
577 |
|
|
constant csr_mhpmevent31_c : std_ulogic_vector(11 downto 0) := x"33f";
|
578 |
56 |
zero_gravi |
-- machine trap handling --
|
579 |
64 |
zero_gravi |
constant csr_class_trap_c : std_ulogic_vector(07 downto 0) := x"34"; -- machine trap handling
|
580 |
42 |
zero_gravi |
constant csr_mscratch_c : std_ulogic_vector(11 downto 0) := x"340";
|
581 |
|
|
constant csr_mepc_c : std_ulogic_vector(11 downto 0) := x"341";
|
582 |
|
|
constant csr_mcause_c : std_ulogic_vector(11 downto 0) := x"342";
|
583 |
|
|
constant csr_mtval_c : std_ulogic_vector(11 downto 0) := x"343";
|
584 |
|
|
constant csr_mip_c : std_ulogic_vector(11 downto 0) := x"344";
|
585 |
56 |
zero_gravi |
-- physical memory protection - configuration --
|
586 |
52 |
zero_gravi |
constant csr_class_pmpcfg_c : std_ulogic_vector(07 downto 0) := x"3a"; -- pmp configuration
|
587 |
42 |
zero_gravi |
constant csr_pmpcfg0_c : std_ulogic_vector(11 downto 0) := x"3a0";
|
588 |
|
|
constant csr_pmpcfg1_c : std_ulogic_vector(11 downto 0) := x"3a1";
|
589 |
|
|
constant csr_pmpcfg2_c : std_ulogic_vector(11 downto 0) := x"3a2";
|
590 |
|
|
constant csr_pmpcfg3_c : std_ulogic_vector(11 downto 0) := x"3a3";
|
591 |
|
|
constant csr_pmpcfg4_c : std_ulogic_vector(11 downto 0) := x"3a4";
|
592 |
|
|
constant csr_pmpcfg5_c : std_ulogic_vector(11 downto 0) := x"3a5";
|
593 |
|
|
constant csr_pmpcfg6_c : std_ulogic_vector(11 downto 0) := x"3a6";
|
594 |
|
|
constant csr_pmpcfg7_c : std_ulogic_vector(11 downto 0) := x"3a7";
|
595 |
|
|
constant csr_pmpcfg8_c : std_ulogic_vector(11 downto 0) := x"3a8";
|
596 |
|
|
constant csr_pmpcfg9_c : std_ulogic_vector(11 downto 0) := x"3a9";
|
597 |
|
|
constant csr_pmpcfg10_c : std_ulogic_vector(11 downto 0) := x"3aa";
|
598 |
|
|
constant csr_pmpcfg11_c : std_ulogic_vector(11 downto 0) := x"3ab";
|
599 |
|
|
constant csr_pmpcfg12_c : std_ulogic_vector(11 downto 0) := x"3ac";
|
600 |
|
|
constant csr_pmpcfg13_c : std_ulogic_vector(11 downto 0) := x"3ad";
|
601 |
|
|
constant csr_pmpcfg14_c : std_ulogic_vector(11 downto 0) := x"3ae";
|
602 |
|
|
constant csr_pmpcfg15_c : std_ulogic_vector(11 downto 0) := x"3af";
|
603 |
56 |
zero_gravi |
-- physical memory protection - address --
|
604 |
42 |
zero_gravi |
constant csr_pmpaddr0_c : std_ulogic_vector(11 downto 0) := x"3b0";
|
605 |
|
|
constant csr_pmpaddr1_c : std_ulogic_vector(11 downto 0) := x"3b1";
|
606 |
|
|
constant csr_pmpaddr2_c : std_ulogic_vector(11 downto 0) := x"3b2";
|
607 |
|
|
constant csr_pmpaddr3_c : std_ulogic_vector(11 downto 0) := x"3b3";
|
608 |
|
|
constant csr_pmpaddr4_c : std_ulogic_vector(11 downto 0) := x"3b4";
|
609 |
|
|
constant csr_pmpaddr5_c : std_ulogic_vector(11 downto 0) := x"3b5";
|
610 |
|
|
constant csr_pmpaddr6_c : std_ulogic_vector(11 downto 0) := x"3b6";
|
611 |
|
|
constant csr_pmpaddr7_c : std_ulogic_vector(11 downto 0) := x"3b7";
|
612 |
|
|
constant csr_pmpaddr8_c : std_ulogic_vector(11 downto 0) := x"3b8";
|
613 |
|
|
constant csr_pmpaddr9_c : std_ulogic_vector(11 downto 0) := x"3b9";
|
614 |
|
|
constant csr_pmpaddr10_c : std_ulogic_vector(11 downto 0) := x"3ba";
|
615 |
|
|
constant csr_pmpaddr11_c : std_ulogic_vector(11 downto 0) := x"3bb";
|
616 |
|
|
constant csr_pmpaddr12_c : std_ulogic_vector(11 downto 0) := x"3bc";
|
617 |
|
|
constant csr_pmpaddr13_c : std_ulogic_vector(11 downto 0) := x"3bd";
|
618 |
|
|
constant csr_pmpaddr14_c : std_ulogic_vector(11 downto 0) := x"3be";
|
619 |
|
|
constant csr_pmpaddr15_c : std_ulogic_vector(11 downto 0) := x"3bf";
|
620 |
|
|
constant csr_pmpaddr16_c : std_ulogic_vector(11 downto 0) := x"3c0";
|
621 |
|
|
constant csr_pmpaddr17_c : std_ulogic_vector(11 downto 0) := x"3c1";
|
622 |
|
|
constant csr_pmpaddr18_c : std_ulogic_vector(11 downto 0) := x"3c2";
|
623 |
|
|
constant csr_pmpaddr19_c : std_ulogic_vector(11 downto 0) := x"3c3";
|
624 |
|
|
constant csr_pmpaddr20_c : std_ulogic_vector(11 downto 0) := x"3c4";
|
625 |
|
|
constant csr_pmpaddr21_c : std_ulogic_vector(11 downto 0) := x"3c5";
|
626 |
|
|
constant csr_pmpaddr22_c : std_ulogic_vector(11 downto 0) := x"3c6";
|
627 |
|
|
constant csr_pmpaddr23_c : std_ulogic_vector(11 downto 0) := x"3c7";
|
628 |
|
|
constant csr_pmpaddr24_c : std_ulogic_vector(11 downto 0) := x"3c8";
|
629 |
|
|
constant csr_pmpaddr25_c : std_ulogic_vector(11 downto 0) := x"3c9";
|
630 |
|
|
constant csr_pmpaddr26_c : std_ulogic_vector(11 downto 0) := x"3ca";
|
631 |
|
|
constant csr_pmpaddr27_c : std_ulogic_vector(11 downto 0) := x"3cb";
|
632 |
|
|
constant csr_pmpaddr28_c : std_ulogic_vector(11 downto 0) := x"3cc";
|
633 |
|
|
constant csr_pmpaddr29_c : std_ulogic_vector(11 downto 0) := x"3cd";
|
634 |
|
|
constant csr_pmpaddr30_c : std_ulogic_vector(11 downto 0) := x"3ce";
|
635 |
|
|
constant csr_pmpaddr31_c : std_ulogic_vector(11 downto 0) := x"3cf";
|
636 |
|
|
constant csr_pmpaddr32_c : std_ulogic_vector(11 downto 0) := x"3d0";
|
637 |
|
|
constant csr_pmpaddr33_c : std_ulogic_vector(11 downto 0) := x"3d1";
|
638 |
|
|
constant csr_pmpaddr34_c : std_ulogic_vector(11 downto 0) := x"3d2";
|
639 |
|
|
constant csr_pmpaddr35_c : std_ulogic_vector(11 downto 0) := x"3d3";
|
640 |
|
|
constant csr_pmpaddr36_c : std_ulogic_vector(11 downto 0) := x"3d4";
|
641 |
|
|
constant csr_pmpaddr37_c : std_ulogic_vector(11 downto 0) := x"3d5";
|
642 |
|
|
constant csr_pmpaddr38_c : std_ulogic_vector(11 downto 0) := x"3d6";
|
643 |
|
|
constant csr_pmpaddr39_c : std_ulogic_vector(11 downto 0) := x"3d7";
|
644 |
|
|
constant csr_pmpaddr40_c : std_ulogic_vector(11 downto 0) := x"3d8";
|
645 |
|
|
constant csr_pmpaddr41_c : std_ulogic_vector(11 downto 0) := x"3d9";
|
646 |
|
|
constant csr_pmpaddr42_c : std_ulogic_vector(11 downto 0) := x"3da";
|
647 |
|
|
constant csr_pmpaddr43_c : std_ulogic_vector(11 downto 0) := x"3db";
|
648 |
|
|
constant csr_pmpaddr44_c : std_ulogic_vector(11 downto 0) := x"3dc";
|
649 |
|
|
constant csr_pmpaddr45_c : std_ulogic_vector(11 downto 0) := x"3dd";
|
650 |
|
|
constant csr_pmpaddr46_c : std_ulogic_vector(11 downto 0) := x"3de";
|
651 |
|
|
constant csr_pmpaddr47_c : std_ulogic_vector(11 downto 0) := x"3df";
|
652 |
|
|
constant csr_pmpaddr48_c : std_ulogic_vector(11 downto 0) := x"3e0";
|
653 |
|
|
constant csr_pmpaddr49_c : std_ulogic_vector(11 downto 0) := x"3e1";
|
654 |
|
|
constant csr_pmpaddr50_c : std_ulogic_vector(11 downto 0) := x"3e2";
|
655 |
|
|
constant csr_pmpaddr51_c : std_ulogic_vector(11 downto 0) := x"3e3";
|
656 |
|
|
constant csr_pmpaddr52_c : std_ulogic_vector(11 downto 0) := x"3e4";
|
657 |
|
|
constant csr_pmpaddr53_c : std_ulogic_vector(11 downto 0) := x"3e5";
|
658 |
|
|
constant csr_pmpaddr54_c : std_ulogic_vector(11 downto 0) := x"3e6";
|
659 |
|
|
constant csr_pmpaddr55_c : std_ulogic_vector(11 downto 0) := x"3e7";
|
660 |
|
|
constant csr_pmpaddr56_c : std_ulogic_vector(11 downto 0) := x"3e8";
|
661 |
|
|
constant csr_pmpaddr57_c : std_ulogic_vector(11 downto 0) := x"3e9";
|
662 |
|
|
constant csr_pmpaddr58_c : std_ulogic_vector(11 downto 0) := x"3ea";
|
663 |
|
|
constant csr_pmpaddr59_c : std_ulogic_vector(11 downto 0) := x"3eb";
|
664 |
|
|
constant csr_pmpaddr60_c : std_ulogic_vector(11 downto 0) := x"3ec";
|
665 |
|
|
constant csr_pmpaddr61_c : std_ulogic_vector(11 downto 0) := x"3ed";
|
666 |
|
|
constant csr_pmpaddr62_c : std_ulogic_vector(11 downto 0) := x"3ee";
|
667 |
|
|
constant csr_pmpaddr63_c : std_ulogic_vector(11 downto 0) := x"3ef";
|
668 |
59 |
zero_gravi |
-- debug mode registers --
|
669 |
|
|
constant csr_class_debug_c : std_ulogic_vector(09 downto 0) := x"7b" & "00"; -- debug registers
|
670 |
|
|
constant csr_dcsr_c : std_ulogic_vector(11 downto 0) := x"7b0";
|
671 |
|
|
constant csr_dpc_c : std_ulogic_vector(11 downto 0) := x"7b1";
|
672 |
|
|
constant csr_dscratch0_c : std_ulogic_vector(11 downto 0) := x"7b2";
|
673 |
56 |
zero_gravi |
-- machine counters/timers --
|
674 |
42 |
zero_gravi |
constant csr_mcycle_c : std_ulogic_vector(11 downto 0) := x"b00";
|
675 |
|
|
constant csr_minstret_c : std_ulogic_vector(11 downto 0) := x"b02";
|
676 |
|
|
--
|
677 |
|
|
constant csr_mhpmcounter3_c : std_ulogic_vector(11 downto 0) := x"b03";
|
678 |
|
|
constant csr_mhpmcounter4_c : std_ulogic_vector(11 downto 0) := x"b04";
|
679 |
|
|
constant csr_mhpmcounter5_c : std_ulogic_vector(11 downto 0) := x"b05";
|
680 |
|
|
constant csr_mhpmcounter6_c : std_ulogic_vector(11 downto 0) := x"b06";
|
681 |
|
|
constant csr_mhpmcounter7_c : std_ulogic_vector(11 downto 0) := x"b07";
|
682 |
|
|
constant csr_mhpmcounter8_c : std_ulogic_vector(11 downto 0) := x"b08";
|
683 |
|
|
constant csr_mhpmcounter9_c : std_ulogic_vector(11 downto 0) := x"b09";
|
684 |
|
|
constant csr_mhpmcounter10_c : std_ulogic_vector(11 downto 0) := x"b0a";
|
685 |
|
|
constant csr_mhpmcounter11_c : std_ulogic_vector(11 downto 0) := x"b0b";
|
686 |
|
|
constant csr_mhpmcounter12_c : std_ulogic_vector(11 downto 0) := x"b0c";
|
687 |
|
|
constant csr_mhpmcounter13_c : std_ulogic_vector(11 downto 0) := x"b0d";
|
688 |
|
|
constant csr_mhpmcounter14_c : std_ulogic_vector(11 downto 0) := x"b0e";
|
689 |
|
|
constant csr_mhpmcounter15_c : std_ulogic_vector(11 downto 0) := x"b0f";
|
690 |
|
|
constant csr_mhpmcounter16_c : std_ulogic_vector(11 downto 0) := x"b10";
|
691 |
|
|
constant csr_mhpmcounter17_c : std_ulogic_vector(11 downto 0) := x"b11";
|
692 |
|
|
constant csr_mhpmcounter18_c : std_ulogic_vector(11 downto 0) := x"b12";
|
693 |
|
|
constant csr_mhpmcounter19_c : std_ulogic_vector(11 downto 0) := x"b13";
|
694 |
|
|
constant csr_mhpmcounter20_c : std_ulogic_vector(11 downto 0) := x"b14";
|
695 |
|
|
constant csr_mhpmcounter21_c : std_ulogic_vector(11 downto 0) := x"b15";
|
696 |
|
|
constant csr_mhpmcounter22_c : std_ulogic_vector(11 downto 0) := x"b16";
|
697 |
|
|
constant csr_mhpmcounter23_c : std_ulogic_vector(11 downto 0) := x"b17";
|
698 |
|
|
constant csr_mhpmcounter24_c : std_ulogic_vector(11 downto 0) := x"b18";
|
699 |
|
|
constant csr_mhpmcounter25_c : std_ulogic_vector(11 downto 0) := x"b19";
|
700 |
|
|
constant csr_mhpmcounter26_c : std_ulogic_vector(11 downto 0) := x"b1a";
|
701 |
|
|
constant csr_mhpmcounter27_c : std_ulogic_vector(11 downto 0) := x"b1b";
|
702 |
|
|
constant csr_mhpmcounter28_c : std_ulogic_vector(11 downto 0) := x"b1c";
|
703 |
|
|
constant csr_mhpmcounter29_c : std_ulogic_vector(11 downto 0) := x"b1d";
|
704 |
|
|
constant csr_mhpmcounter30_c : std_ulogic_vector(11 downto 0) := x"b1e";
|
705 |
|
|
constant csr_mhpmcounter31_c : std_ulogic_vector(11 downto 0) := x"b1f";
|
706 |
|
|
--
|
707 |
|
|
constant csr_mcycleh_c : std_ulogic_vector(11 downto 0) := x"b80";
|
708 |
|
|
constant csr_minstreth_c : std_ulogic_vector(11 downto 0) := x"b82";
|
709 |
|
|
--
|
710 |
|
|
constant csr_mhpmcounter3h_c : std_ulogic_vector(11 downto 0) := x"b83";
|
711 |
|
|
constant csr_mhpmcounter4h_c : std_ulogic_vector(11 downto 0) := x"b84";
|
712 |
|
|
constant csr_mhpmcounter5h_c : std_ulogic_vector(11 downto 0) := x"b85";
|
713 |
|
|
constant csr_mhpmcounter6h_c : std_ulogic_vector(11 downto 0) := x"b86";
|
714 |
|
|
constant csr_mhpmcounter7h_c : std_ulogic_vector(11 downto 0) := x"b87";
|
715 |
|
|
constant csr_mhpmcounter8h_c : std_ulogic_vector(11 downto 0) := x"b88";
|
716 |
|
|
constant csr_mhpmcounter9h_c : std_ulogic_vector(11 downto 0) := x"b89";
|
717 |
|
|
constant csr_mhpmcounter10h_c : std_ulogic_vector(11 downto 0) := x"b8a";
|
718 |
|
|
constant csr_mhpmcounter11h_c : std_ulogic_vector(11 downto 0) := x"b8b";
|
719 |
|
|
constant csr_mhpmcounter12h_c : std_ulogic_vector(11 downto 0) := x"b8c";
|
720 |
|
|
constant csr_mhpmcounter13h_c : std_ulogic_vector(11 downto 0) := x"b8d";
|
721 |
|
|
constant csr_mhpmcounter14h_c : std_ulogic_vector(11 downto 0) := x"b8e";
|
722 |
|
|
constant csr_mhpmcounter15h_c : std_ulogic_vector(11 downto 0) := x"b8f";
|
723 |
|
|
constant csr_mhpmcounter16h_c : std_ulogic_vector(11 downto 0) := x"b90";
|
724 |
|
|
constant csr_mhpmcounter17h_c : std_ulogic_vector(11 downto 0) := x"b91";
|
725 |
|
|
constant csr_mhpmcounter18h_c : std_ulogic_vector(11 downto 0) := x"b92";
|
726 |
|
|
constant csr_mhpmcounter19h_c : std_ulogic_vector(11 downto 0) := x"b93";
|
727 |
|
|
constant csr_mhpmcounter20h_c : std_ulogic_vector(11 downto 0) := x"b94";
|
728 |
|
|
constant csr_mhpmcounter21h_c : std_ulogic_vector(11 downto 0) := x"b95";
|
729 |
|
|
constant csr_mhpmcounter22h_c : std_ulogic_vector(11 downto 0) := x"b96";
|
730 |
|
|
constant csr_mhpmcounter23h_c : std_ulogic_vector(11 downto 0) := x"b97";
|
731 |
|
|
constant csr_mhpmcounter24h_c : std_ulogic_vector(11 downto 0) := x"b98";
|
732 |
|
|
constant csr_mhpmcounter25h_c : std_ulogic_vector(11 downto 0) := x"b99";
|
733 |
|
|
constant csr_mhpmcounter26h_c : std_ulogic_vector(11 downto 0) := x"b9a";
|
734 |
|
|
constant csr_mhpmcounter27h_c : std_ulogic_vector(11 downto 0) := x"b9b";
|
735 |
|
|
constant csr_mhpmcounter28h_c : std_ulogic_vector(11 downto 0) := x"b9c";
|
736 |
|
|
constant csr_mhpmcounter29h_c : std_ulogic_vector(11 downto 0) := x"b9d";
|
737 |
|
|
constant csr_mhpmcounter30h_c : std_ulogic_vector(11 downto 0) := x"b9e";
|
738 |
|
|
constant csr_mhpmcounter31h_c : std_ulogic_vector(11 downto 0) := x"b9f";
|
739 |
|
|
|
740 |
56 |
zero_gravi |
-- <<< standard read-only CSRs >>> --
|
741 |
|
|
-- user counters/timers --
|
742 |
42 |
zero_gravi |
constant csr_cycle_c : std_ulogic_vector(11 downto 0) := x"c00";
|
743 |
|
|
constant csr_time_c : std_ulogic_vector(11 downto 0) := x"c01";
|
744 |
|
|
constant csr_instret_c : std_ulogic_vector(11 downto 0) := x"c02";
|
745 |
|
|
constant csr_cycleh_c : std_ulogic_vector(11 downto 0) := x"c80";
|
746 |
|
|
constant csr_timeh_c : std_ulogic_vector(11 downto 0) := x"c81";
|
747 |
|
|
constant csr_instreth_c : std_ulogic_vector(11 downto 0) := x"c82";
|
748 |
56 |
zero_gravi |
-- machine information registers --
|
749 |
42 |
zero_gravi |
constant csr_mvendorid_c : std_ulogic_vector(11 downto 0) := x"f11";
|
750 |
|
|
constant csr_marchid_c : std_ulogic_vector(11 downto 0) := x"f12";
|
751 |
|
|
constant csr_mimpid_c : std_ulogic_vector(11 downto 0) := x"f13";
|
752 |
|
|
constant csr_mhartid_c : std_ulogic_vector(11 downto 0) := x"f14";
|
753 |
62 |
zero_gravi |
constant csr_mconfigptr_c : std_ulogic_vector(11 downto 0) := x"f15";
|
754 |
42 |
zero_gravi |
|
755 |
44 |
zero_gravi |
-- Co-Processor IDs -----------------------------------------------------------------------
|
756 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
757 |
63 |
zero_gravi |
constant cp_sel_shifter_c : std_ulogic_vector(1 downto 0) := "00"; -- shift operations (base ISA)
|
758 |
|
|
constant cp_sel_muldiv_c : std_ulogic_vector(1 downto 0) := "01"; -- multiplication/division operations ('M' extensions)
|
759 |
|
|
constant cp_sel_bitmanip_c : std_ulogic_vector(1 downto 0) := "10"; -- bit manipulation ('B' extensions)
|
760 |
61 |
zero_gravi |
constant cp_sel_fpu_c : std_ulogic_vector(1 downto 0) := "11"; -- floating-point unit ('Zfinx' extension)
|
761 |
2 |
zero_gravi |
|
762 |
|
|
-- ALU Function Codes ---------------------------------------------------------------------
|
763 |
|
|
-- -------------------------------------------------------------------------------------------
|
764 |
39 |
zero_gravi |
-- arithmetic core --
|
765 |
|
|
constant alu_arith_cmd_addsub_c : std_ulogic := '0'; -- r.arith <= A +/- B
|
766 |
|
|
constant alu_arith_cmd_slt_c : std_ulogic := '1'; -- r.arith <= A < B
|
767 |
|
|
-- logic core --
|
768 |
|
|
constant alu_logic_cmd_movb_c : std_ulogic_vector(1 downto 0) := "00"; -- r.logic <= B
|
769 |
|
|
constant alu_logic_cmd_xor_c : std_ulogic_vector(1 downto 0) := "01"; -- r.logic <= A xor B
|
770 |
|
|
constant alu_logic_cmd_or_c : std_ulogic_vector(1 downto 0) := "10"; -- r.logic <= A or B
|
771 |
|
|
constant alu_logic_cmd_and_c : std_ulogic_vector(1 downto 0) := "11"; -- r.logic <= A and B
|
772 |
|
|
-- function select (actual alu result) --
|
773 |
|
|
constant alu_func_cmd_arith_c : std_ulogic_vector(1 downto 0) := "00"; -- r <= r.arith
|
774 |
|
|
constant alu_func_cmd_logic_c : std_ulogic_vector(1 downto 0) := "01"; -- r <= r.logic
|
775 |
61 |
zero_gravi |
constant alu_func_cmd_csrr_c : std_ulogic_vector(1 downto 0) := "10"; -- r <= CSR read
|
776 |
60 |
zero_gravi |
constant alu_func_cmd_copro_c : std_ulogic_vector(1 downto 0) := "11"; -- r <= CP result (multi-cycle)
|
777 |
2 |
zero_gravi |
|
778 |
12 |
zero_gravi |
-- Trap ID Codes --------------------------------------------------------------------------
|
779 |
|
|
-- -------------------------------------------------------------------------------------------
|
780 |
64 |
zero_gravi |
-- MSB: 1 = async exception (IRQ), 0 = sync exception (e.g. ebreak)
|
781 |
|
|
-- MSB-1: 1 = entry to debug mode, 0 = normal trapping
|
782 |
48 |
zero_gravi |
-- RISC-V compliant sync. exceptions --
|
783 |
59 |
zero_gravi |
constant trap_ima_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00000"; -- 0.0: instruction misaligned
|
784 |
|
|
constant trap_iba_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00001"; -- 0.1: instruction access fault
|
785 |
|
|
constant trap_iil_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00010"; -- 0.2: illegal instruction
|
786 |
|
|
constant trap_brk_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00011"; -- 0.3: breakpoint
|
787 |
|
|
constant trap_lma_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00100"; -- 0.4: load address misaligned
|
788 |
|
|
constant trap_lbe_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00101"; -- 0.5: load access fault
|
789 |
|
|
constant trap_sma_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00110"; -- 0.6: store address misaligned
|
790 |
|
|
constant trap_sbe_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "00111"; -- 0.7: store access fault
|
791 |
|
|
constant trap_uenv_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "01000"; -- 0.8: environment call from u-mode
|
792 |
|
|
constant trap_menv_c : std_ulogic_vector(6 downto 0) := "0" & "0" & "01011"; -- 0.11: environment call from m-mode
|
793 |
48 |
zero_gravi |
-- RISC-V compliant interrupts (async. exceptions) --
|
794 |
59 |
zero_gravi |
constant trap_msi_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "00011"; -- 1.3: machine software interrupt
|
795 |
|
|
constant trap_mti_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "00111"; -- 1.7: machine timer interrupt
|
796 |
|
|
constant trap_mei_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "01011"; -- 1.11: machine external interrupt
|
797 |
48 |
zero_gravi |
-- NEORV32-specific (custom) interrupts (async. exceptions) --
|
798 |
59 |
zero_gravi |
constant trap_firq0_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10000"; -- 1.16: fast interrupt 0
|
799 |
|
|
constant trap_firq1_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10001"; -- 1.17: fast interrupt 1
|
800 |
|
|
constant trap_firq2_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10010"; -- 1.18: fast interrupt 2
|
801 |
|
|
constant trap_firq3_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10011"; -- 1.19: fast interrupt 3
|
802 |
|
|
constant trap_firq4_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10100"; -- 1.20: fast interrupt 4
|
803 |
|
|
constant trap_firq5_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10101"; -- 1.21: fast interrupt 5
|
804 |
|
|
constant trap_firq6_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10110"; -- 1.22: fast interrupt 6
|
805 |
|
|
constant trap_firq7_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "10111"; -- 1.23: fast interrupt 7
|
806 |
|
|
constant trap_firq8_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11000"; -- 1.24: fast interrupt 8
|
807 |
|
|
constant trap_firq9_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11001"; -- 1.25: fast interrupt 9
|
808 |
|
|
constant trap_firq10_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11010"; -- 1.26: fast interrupt 10
|
809 |
|
|
constant trap_firq11_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11011"; -- 1.27: fast interrupt 11
|
810 |
|
|
constant trap_firq12_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11100"; -- 1.28: fast interrupt 12
|
811 |
|
|
constant trap_firq13_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11101"; -- 1.29: fast interrupt 13
|
812 |
|
|
constant trap_firq14_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11110"; -- 1.30: fast interrupt 14
|
813 |
|
|
constant trap_firq15_c : std_ulogic_vector(6 downto 0) := "1" & "0" & "11111"; -- 1.31: fast interrupt 15
|
814 |
|
|
-- entering debug mode - cause --
|
815 |
|
|
constant trap_db_break_c : std_ulogic_vector(6 downto 0) := "0" & "1" & "00010"; -- break instruction (sync / EXCEPTION)
|
816 |
|
|
constant trap_db_halt_c : std_ulogic_vector(6 downto 0) := "1" & "1" & "00011"; -- external halt request (async / IRQ)
|
817 |
|
|
constant trap_db_step_c : std_ulogic_vector(6 downto 0) := "1" & "1" & "00100"; -- single-stepping (async / IRQ)
|
818 |
12 |
zero_gravi |
|
819 |
2 |
zero_gravi |
-- CPU Control Exception System -----------------------------------------------------------
|
820 |
|
|
-- -------------------------------------------------------------------------------------------
|
821 |
|
|
-- exception source bits --
|
822 |
59 |
zero_gravi |
constant exception_iaccess_c : natural := 0; -- instruction access fault
|
823 |
|
|
constant exception_iillegal_c : natural := 1; -- illegal instruction
|
824 |
|
|
constant exception_ialign_c : natural := 2; -- instruction address misaligned
|
825 |
47 |
zero_gravi |
constant exception_m_envcall_c : natural := 3; -- ENV call from m-mode
|
826 |
|
|
constant exception_u_envcall_c : natural := 4; -- ENV call from u-mode
|
827 |
|
|
constant exception_break_c : natural := 5; -- breakpoint
|
828 |
|
|
constant exception_salign_c : natural := 6; -- store address misaligned
|
829 |
|
|
constant exception_lalign_c : natural := 7; -- load address misaligned
|
830 |
|
|
constant exception_saccess_c : natural := 8; -- store access fault
|
831 |
|
|
constant exception_laccess_c : natural := 9; -- load access fault
|
832 |
59 |
zero_gravi |
-- for debug mode only --
|
833 |
|
|
constant exception_db_break_c : natural := 10; -- enter debug mode via ebreak instruction ("sync EXCEPTION")
|
834 |
14 |
zero_gravi |
--
|
835 |
59 |
zero_gravi |
constant exception_width_c : natural := 11; -- length of this list in bits
|
836 |
2 |
zero_gravi |
-- interrupt source bits --
|
837 |
64 |
zero_gravi |
constant interrupt_msw_irq_c : natural := 0; -- machine software interrupt
|
838 |
|
|
constant interrupt_mtime_irq_c : natural := 1; -- machine timer interrupt
|
839 |
|
|
constant interrupt_mext_irq_c : natural := 2; -- machine external interrupt
|
840 |
|
|
constant interrupt_firq_0_c : natural := 3; -- fast interrupt channel 0
|
841 |
|
|
constant interrupt_firq_1_c : natural := 4; -- fast interrupt channel 1
|
842 |
|
|
constant interrupt_firq_2_c : natural := 5; -- fast interrupt channel 2
|
843 |
|
|
constant interrupt_firq_3_c : natural := 6; -- fast interrupt channel 3
|
844 |
|
|
constant interrupt_firq_4_c : natural := 7; -- fast interrupt channel 4
|
845 |
|
|
constant interrupt_firq_5_c : natural := 8; -- fast interrupt channel 5
|
846 |
|
|
constant interrupt_firq_6_c : natural := 9; -- fast interrupt channel 6
|
847 |
|
|
constant interrupt_firq_7_c : natural := 10; -- fast interrupt channel 7
|
848 |
|
|
constant interrupt_firq_8_c : natural := 11; -- fast interrupt channel 8
|
849 |
|
|
constant interrupt_firq_9_c : natural := 12; -- fast interrupt channel 9
|
850 |
|
|
constant interrupt_firq_10_c : natural := 13; -- fast interrupt channel 10
|
851 |
|
|
constant interrupt_firq_11_c : natural := 14; -- fast interrupt channel 11
|
852 |
|
|
constant interrupt_firq_12_c : natural := 15; -- fast interrupt channel 12
|
853 |
|
|
constant interrupt_firq_13_c : natural := 16; -- fast interrupt channel 13
|
854 |
|
|
constant interrupt_firq_14_c : natural := 17; -- fast interrupt channel 14
|
855 |
|
|
constant interrupt_firq_15_c : natural := 18; -- fast interrupt channel 15
|
856 |
59 |
zero_gravi |
-- for debug mode only --
|
857 |
64 |
zero_gravi |
constant interrupt_db_halt_c : natural := 19; -- enter debug mode via external halt request ("async IRQ")
|
858 |
|
|
constant interrupt_db_step_c : natural := 20; -- enter debug mode via single-stepping ("async IRQ")
|
859 |
14 |
zero_gravi |
--
|
860 |
64 |
zero_gravi |
constant interrupt_width_c : natural := 21; -- length of this list in bits
|
861 |
2 |
zero_gravi |
|
862 |
15 |
zero_gravi |
-- CPU Privilege Modes --------------------------------------------------------------------
|
863 |
|
|
-- -------------------------------------------------------------------------------------------
|
864 |
29 |
zero_gravi |
constant priv_mode_m_c : std_ulogic_vector(1 downto 0) := "11"; -- machine mode
|
865 |
|
|
constant priv_mode_u_c : std_ulogic_vector(1 downto 0) := "00"; -- user mode
|
866 |
15 |
zero_gravi |
|
867 |
42 |
zero_gravi |
-- HPM Event System -----------------------------------------------------------------------
|
868 |
|
|
-- -------------------------------------------------------------------------------------------
|
869 |
|
|
constant hpmcnt_event_cy_c : natural := 0; -- Active cycle
|
870 |
56 |
zero_gravi |
constant hpmcnt_event_never_c : natural := 1; -- Unused / never (actually, this would be used for TIME)
|
871 |
42 |
zero_gravi |
constant hpmcnt_event_ir_c : natural := 2; -- Retired instruction
|
872 |
|
|
constant hpmcnt_event_cir_c : natural := 3; -- Retired compressed instruction
|
873 |
|
|
constant hpmcnt_event_wait_if_c : natural := 4; -- Instruction fetch memory wait cycle
|
874 |
|
|
constant hpmcnt_event_wait_ii_c : natural := 5; -- Instruction issue wait cycle
|
875 |
45 |
zero_gravi |
constant hpmcnt_event_wait_mc_c : natural := 6; -- Multi-cycle ALU-operation wait cycle
|
876 |
|
|
constant hpmcnt_event_load_c : natural := 7; -- Load operation
|
877 |
|
|
constant hpmcnt_event_store_c : natural := 8; -- Store operation
|
878 |
|
|
constant hpmcnt_event_wait_ls_c : natural := 9; -- Load/store memory wait cycle
|
879 |
|
|
constant hpmcnt_event_jump_c : natural := 10; -- Unconditional jump
|
880 |
|
|
constant hpmcnt_event_branch_c : natural := 11; -- Conditional branch (taken or not taken)
|
881 |
|
|
constant hpmcnt_event_tbranch_c : natural := 12; -- Conditional taken branch
|
882 |
|
|
constant hpmcnt_event_trap_c : natural := 13; -- Entered trap
|
883 |
|
|
constant hpmcnt_event_illegal_c : natural := 14; -- Illegal instruction exception
|
884 |
42 |
zero_gravi |
--
|
885 |
45 |
zero_gravi |
constant hpmcnt_event_size_c : natural := 15; -- length of this list
|
886 |
42 |
zero_gravi |
|
887 |
39 |
zero_gravi |
-- Clock Generator ------------------------------------------------------------------------
|
888 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
889 |
|
|
constant clk_div2_c : natural := 0;
|
890 |
|
|
constant clk_div4_c : natural := 1;
|
891 |
|
|
constant clk_div8_c : natural := 2;
|
892 |
|
|
constant clk_div64_c : natural := 3;
|
893 |
|
|
constant clk_div128_c : natural := 4;
|
894 |
|
|
constant clk_div1024_c : natural := 5;
|
895 |
|
|
constant clk_div2048_c : natural := 6;
|
896 |
|
|
constant clk_div4096_c : natural := 7;
|
897 |
|
|
|
898 |
|
|
-- Component: NEORV32 Processor Top Entity ------------------------------------------------
|
899 |
|
|
-- -------------------------------------------------------------------------------------------
|
900 |
|
|
component neorv32_top
|
901 |
|
|
generic (
|
902 |
|
|
-- General --
|
903 |
62 |
zero_gravi |
CLOCK_FREQUENCY : natural; -- clock frequency of clk_i in Hz
|
904 |
49 |
zero_gravi |
HW_THREAD_ID : natural := 0; -- hardware thread id (32-bit)
|
905 |
62 |
zero_gravi |
INT_BOOTLOADER_EN : boolean := false; -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM
|
906 |
59 |
zero_gravi |
-- On-Chip Debugger (OCD) --
|
907 |
|
|
ON_CHIP_DEBUGGER_EN : boolean := false; -- implement on-chip debugger
|
908 |
2 |
zero_gravi |
-- RISC-V CPU Extensions --
|
909 |
39 |
zero_gravi |
CPU_EXTENSION_RISCV_A : boolean := false; -- implement atomic extension?
|
910 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_B : boolean := false; -- implement bit-manipulation extension?
|
911 |
18 |
zero_gravi |
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
912 |
8 |
zero_gravi |
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
913 |
61 |
zero_gravi |
CPU_EXTENSION_RISCV_M : boolean := false; -- implement mul/div extension?
|
914 |
18 |
zero_gravi |
CPU_EXTENSION_RISCV_U : boolean := false; -- implement user mode extension?
|
915 |
57 |
zero_gravi |
CPU_EXTENSION_RISCV_Zfinx : boolean := false; -- implement 32-bit floating-point extension (using INT regs!)
|
916 |
8 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
917 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicntr : boolean := true; -- implement base counters?
|
918 |
|
|
CPU_EXTENSION_RISCV_Zihpm : boolean := false; -- implement hardware performance monitors?
|
919 |
39 |
zero_gravi |
CPU_EXTENSION_RISCV_Zifencei : boolean := false; -- implement instruction stream sync.?
|
920 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_Zmmul : boolean := false; -- implement multiply-only M sub-extension?
|
921 |
19 |
zero_gravi |
-- Extension Options --
|
922 |
34 |
zero_gravi |
FAST_MUL_EN : boolean := false; -- use DSPs for M extension's multiplier
|
923 |
|
|
FAST_SHIFT_EN : boolean := false; -- use barrel shifter for shift operations
|
924 |
56 |
zero_gravi |
CPU_CNT_WIDTH : natural := 64; -- total width of CPU cycle and instret counters (0..64)
|
925 |
62 |
zero_gravi |
CPU_IPB_ENTRIES : natural := 2; -- entries is instruction prefetch buffer, has to be a power of 2
|
926 |
15 |
zero_gravi |
-- Physical Memory Protection (PMP) --
|
927 |
42 |
zero_gravi |
PMP_NUM_REGIONS : natural := 0; -- number of regions (0..64)
|
928 |
|
|
PMP_MIN_GRANULARITY : natural := 64*1024; -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
929 |
|
|
-- Hardware Performance Monitors (HPM) --
|
930 |
47 |
zero_gravi |
HPM_NUM_CNTS : natural := 0; -- number of implemented HPM counters (0..29)
|
931 |
60 |
zero_gravi |
HPM_CNT_WIDTH : natural := 40; -- total size of HPM counters (0..64)
|
932 |
61 |
zero_gravi |
-- Internal Instruction memory (IMEM) --
|
933 |
62 |
zero_gravi |
MEM_INT_IMEM_EN : boolean := false; -- implement processor-internal instruction memory
|
934 |
8 |
zero_gravi |
MEM_INT_IMEM_SIZE : natural := 16*1024; -- size of processor-internal instruction memory in bytes
|
935 |
61 |
zero_gravi |
-- Internal Data memory (DMEM) --
|
936 |
62 |
zero_gravi |
MEM_INT_DMEM_EN : boolean := false; -- implement processor-internal data memory
|
937 |
8 |
zero_gravi |
MEM_INT_DMEM_SIZE : natural := 8*1024; -- size of processor-internal data memory in bytes
|
938 |
61 |
zero_gravi |
-- Internal Cache memory (iCACHE) --
|
939 |
44 |
zero_gravi |
ICACHE_EN : boolean := false; -- implement instruction cache
|
940 |
41 |
zero_gravi |
ICACHE_NUM_BLOCKS : natural := 4; -- i-cache: number of blocks (min 1), has to be a power of 2
|
941 |
|
|
ICACHE_BLOCK_SIZE : natural := 64; -- i-cache: block size in bytes (min 4), has to be a power of 2
|
942 |
45 |
zero_gravi |
ICACHE_ASSOCIATIVITY : natural := 1; -- i-cache: associativity / number of sets (1=direct_mapped), has to be a power of 2
|
943 |
61 |
zero_gravi |
-- External memory interface (WISHBONE) --
|
944 |
44 |
zero_gravi |
MEM_EXT_EN : boolean := false; -- implement external memory bus interface?
|
945 |
57 |
zero_gravi |
MEM_EXT_TIMEOUT : natural := 255; -- cycles after a pending bus access auto-terminates (0 = disabled)
|
946 |
62 |
zero_gravi |
MEM_EXT_PIPE_MODE : boolean := false; -- protocol: false=classic/standard wishbone mode, true=pipelined wishbone mode
|
947 |
|
|
MEM_EXT_BIG_ENDIAN : boolean := false; -- byte order: true=big-endian, false=little-endian
|
948 |
|
|
MEM_EXT_ASYNC_RX : boolean := false; -- use register buffer for RX data when false
|
949 |
61 |
zero_gravi |
-- Stream link interface (SLINK) --
|
950 |
|
|
SLINK_NUM_TX : natural := 0; -- number of TX links (0..8)
|
951 |
|
|
SLINK_NUM_RX : natural := 0; -- number of TX links (0..8)
|
952 |
|
|
SLINK_TX_FIFO : natural := 1; -- TX fifo depth, has to be a power of two
|
953 |
|
|
SLINK_RX_FIFO : natural := 1; -- RX fifo depth, has to be a power of two
|
954 |
|
|
-- External Interrupts Controller (XIRQ) --
|
955 |
|
|
XIRQ_NUM_CH : natural := 0; -- number of external IRQ channels (0..32)
|
956 |
62 |
zero_gravi |
XIRQ_TRIGGER_TYPE : std_ulogic_vector(31 downto 0) := x"FFFFFFFF"; -- trigger type: 0=level, 1=edge
|
957 |
|
|
XIRQ_TRIGGER_POLARITY : std_ulogic_vector(31 downto 0) := x"FFFFFFFF"; -- trigger polarity: 0=low-level/falling-edge, 1=high-level/rising-edge
|
958 |
2 |
zero_gravi |
-- Processor peripherals --
|
959 |
62 |
zero_gravi |
IO_GPIO_EN : boolean := false; -- implement general purpose input/output port unit (GPIO)?
|
960 |
|
|
IO_MTIME_EN : boolean := false; -- implement machine system timer (MTIME)?
|
961 |
|
|
IO_UART0_EN : boolean := false; -- implement primary universal asynchronous receiver/transmitter (UART0)?
|
962 |
65 |
zero_gravi |
IO_UART0_RX_FIFO : natural := 1; -- RX fifo depth, has to be a power of two, min 1
|
963 |
|
|
IO_UART0_TX_FIFO : natural := 1; -- TX fifo depth, has to be a power of two, min 1
|
964 |
62 |
zero_gravi |
IO_UART1_EN : boolean := false; -- implement secondary universal asynchronous receiver/transmitter (UART1)?
|
965 |
65 |
zero_gravi |
IO_UART1_RX_FIFO : natural := 1; -- RX fifo depth, has to be a power of two, min 1
|
966 |
|
|
IO_UART1_TX_FIFO : natural := 1; -- TX fifo depth, has to be a power of two, min 1
|
967 |
62 |
zero_gravi |
IO_SPI_EN : boolean := false; -- implement serial peripheral interface (SPI)?
|
968 |
|
|
IO_TWI_EN : boolean := false; -- implement two-wire interface (TWI)?
|
969 |
|
|
IO_PWM_NUM_CH : natural := 0; -- number of PWM channels to implement (0..60); 0 = disabled
|
970 |
|
|
IO_WDT_EN : boolean := false; -- implement watch dog timer (WDT)?
|
971 |
44 |
zero_gravi |
IO_TRNG_EN : boolean := false; -- implement true random number generator (TRNG)?
|
972 |
47 |
zero_gravi |
IO_CFS_EN : boolean := false; -- implement custom functions subsystem (CFS)?
|
973 |
56 |
zero_gravi |
IO_CFS_CONFIG : std_ulogic_vector(31 downto 0) := x"00000000"; -- custom CFS configuration generic
|
974 |
52 |
zero_gravi |
IO_CFS_IN_SIZE : positive := 32; -- size of CFS input conduit in bits
|
975 |
|
|
IO_CFS_OUT_SIZE : positive := 32; -- size of CFS output conduit in bits
|
976 |
62 |
zero_gravi |
IO_NEOLED_EN : boolean := false; -- implement NeoPixel-compatible smart LED interface (NEOLED)?
|
977 |
67 |
zero_gravi |
IO_NEOLED_TX_FIFO : natural := 1; -- NEOLED TX FIFO depth, 1..32k, has to be a power of two
|
978 |
|
|
IO_GPTMR_EN : boolean := false -- implement general purpose timer (GPTMR)?
|
979 |
2 |
zero_gravi |
);
|
980 |
|
|
port (
|
981 |
|
|
-- Global control --
|
982 |
62 |
zero_gravi |
clk_i : in std_ulogic; -- global clock, rising edge
|
983 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
984 |
59 |
zero_gravi |
-- JTAG on-chip debugger interface --
|
985 |
62 |
zero_gravi |
jtag_trst_i : in std_ulogic := 'U'; -- low-active TAP reset (optional)
|
986 |
|
|
jtag_tck_i : in std_ulogic := 'U'; -- serial clock
|
987 |
|
|
jtag_tdi_i : in std_ulogic := 'U'; -- serial data input
|
988 |
61 |
zero_gravi |
jtag_tdo_o : out std_ulogic; -- serial data output
|
989 |
62 |
zero_gravi |
jtag_tms_i : in std_ulogic := 'U'; -- mode select
|
990 |
49 |
zero_gravi |
-- Wishbone bus interface (available if MEM_EXT_EN = true) --
|
991 |
61 |
zero_gravi |
wb_tag_o : out std_ulogic_vector(02 downto 0); -- request tag
|
992 |
|
|
wb_adr_o : out std_ulogic_vector(31 downto 0); -- address
|
993 |
62 |
zero_gravi |
wb_dat_i : in std_ulogic_vector(31 downto 0) := (others => 'U'); -- read data
|
994 |
61 |
zero_gravi |
wb_dat_o : out std_ulogic_vector(31 downto 0); -- write data
|
995 |
|
|
wb_we_o : out std_ulogic; -- read/write
|
996 |
|
|
wb_sel_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
997 |
|
|
wb_stb_o : out std_ulogic; -- strobe
|
998 |
|
|
wb_cyc_o : out std_ulogic; -- valid cycle
|
999 |
|
|
wb_lock_o : out std_ulogic; -- exclusive access request
|
1000 |
62 |
zero_gravi |
wb_ack_i : in std_ulogic := 'L'; -- transfer acknowledge
|
1001 |
|
|
wb_err_i : in std_ulogic := 'L'; -- transfer error
|
1002 |
44 |
zero_gravi |
-- Advanced memory control signals (available if MEM_EXT_EN = true) --
|
1003 |
61 |
zero_gravi |
fence_o : out std_ulogic; -- indicates an executed FENCE operation
|
1004 |
|
|
fencei_o : out std_ulogic; -- indicates an executed FENCEI operation
|
1005 |
|
|
-- TX stream interfaces (available if SLINK_NUM_TX > 0) --
|
1006 |
|
|
slink_tx_dat_o : out sdata_8x32_t; -- output data
|
1007 |
|
|
slink_tx_val_o : out std_ulogic_vector(7 downto 0); -- valid output
|
1008 |
62 |
zero_gravi |
slink_tx_rdy_i : in std_ulogic_vector(7 downto 0) := (others => 'L'); -- ready to send
|
1009 |
61 |
zero_gravi |
-- RX stream interfaces (available if SLINK_NUM_RX > 0) --
|
1010 |
62 |
zero_gravi |
slink_rx_dat_i : in sdata_8x32_t := (others => (others => 'U')); -- input data
|
1011 |
|
|
slink_rx_val_i : in std_ulogic_vector(7 downto 0) := (others => 'L'); -- valid input
|
1012 |
61 |
zero_gravi |
slink_rx_rdy_o : out std_ulogic_vector(7 downto 0); -- ready to receive
|
1013 |
49 |
zero_gravi |
-- GPIO (available if IO_GPIO_EN = true) --
|
1014 |
61 |
zero_gravi |
gpio_o : out std_ulogic_vector(63 downto 0); -- parallel output
|
1015 |
62 |
zero_gravi |
gpio_i : in std_ulogic_vector(63 downto 0) := (others => 'U'); -- parallel input
|
1016 |
50 |
zero_gravi |
-- primary UART0 (available if IO_UART0_EN = true) --
|
1017 |
61 |
zero_gravi |
uart0_txd_o : out std_ulogic; -- UART0 send data
|
1018 |
62 |
zero_gravi |
uart0_rxd_i : in std_ulogic := 'U'; -- UART0 receive data
|
1019 |
61 |
zero_gravi |
uart0_rts_o : out std_ulogic; -- hw flow control: UART0.RX ready to receive ("RTR"), low-active, optional
|
1020 |
62 |
zero_gravi |
uart0_cts_i : in std_ulogic := 'L'; -- hw flow control: UART0.TX allowed to transmit, low-active, optional
|
1021 |
50 |
zero_gravi |
-- secondary UART1 (available if IO_UART1_EN = true) --
|
1022 |
61 |
zero_gravi |
uart1_txd_o : out std_ulogic; -- UART1 send data
|
1023 |
62 |
zero_gravi |
uart1_rxd_i : in std_ulogic := 'U'; -- UART1 receive data
|
1024 |
61 |
zero_gravi |
uart1_rts_o : out std_ulogic; -- hw flow control: UART1.RX ready to receive ("RTR"), low-active, optional
|
1025 |
62 |
zero_gravi |
uart1_cts_i : in std_ulogic := 'L'; -- hw flow control: UART1.TX allowed to transmit, low-active, optional
|
1026 |
49 |
zero_gravi |
-- SPI (available if IO_SPI_EN = true) --
|
1027 |
61 |
zero_gravi |
spi_sck_o : out std_ulogic; -- SPI serial clock
|
1028 |
|
|
spi_sdo_o : out std_ulogic; -- controller data out, peripheral data in
|
1029 |
62 |
zero_gravi |
spi_sdi_i : in std_ulogic := 'U'; -- controller data in, peripheral data out
|
1030 |
61 |
zero_gravi |
spi_csn_o : out std_ulogic_vector(07 downto 0); -- SPI CS
|
1031 |
49 |
zero_gravi |
-- TWI (available if IO_TWI_EN = true) --
|
1032 |
62 |
zero_gravi |
twi_sda_io : inout std_logic := 'U'; -- twi serial data line
|
1033 |
|
|
twi_scl_io : inout std_logic := 'U'; -- twi serial clock line
|
1034 |
60 |
zero_gravi |
-- PWM (available if IO_PWM_NUM_CH > 0) --
|
1035 |
61 |
zero_gravi |
pwm_o : out std_ulogic_vector(IO_PWM_NUM_CH-1 downto 0); -- pwm channels
|
1036 |
47 |
zero_gravi |
-- Custom Functions Subsystem IO --
|
1037 |
62 |
zero_gravi |
cfs_in_i : in std_ulogic_vector(IO_CFS_IN_SIZE-1 downto 0) := (others => 'U'); -- custom CFS inputs conduit
|
1038 |
61 |
zero_gravi |
cfs_out_o : out std_ulogic_vector(IO_CFS_OUT_SIZE-1 downto 0); -- custom CFS outputs conduit
|
1039 |
52 |
zero_gravi |
-- NeoPixel-compatible smart LED interface (available if IO_NEOLED_EN = true) --
|
1040 |
61 |
zero_gravi |
neoled_o : out std_ulogic; -- async serial data line
|
1041 |
59 |
zero_gravi |
-- System time --
|
1042 |
62 |
zero_gravi |
mtime_i : in std_ulogic_vector(63 downto 0) := (others => 'U'); -- current system time from ext. MTIME (if IO_MTIME_EN = false)
|
1043 |
61 |
zero_gravi |
mtime_o : out std_ulogic_vector(63 downto 0); -- current system time from int. MTIME (if IO_MTIME_EN = true)
|
1044 |
|
|
-- External platform interrupts (available if XIRQ_NUM_CH > 0) --
|
1045 |
62 |
zero_gravi |
xirq_i : in std_ulogic_vector(XIRQ_NUM_CH-1 downto 0) := (others => 'L'); -- IRQ channels
|
1046 |
61 |
zero_gravi |
-- CPU Interrupts --
|
1047 |
62 |
zero_gravi |
mtime_irq_i : in std_ulogic := 'L'; -- machine timer interrupt, available if IO_MTIME_EN = false
|
1048 |
|
|
msw_irq_i : in std_ulogic := 'L'; -- machine software interrupt
|
1049 |
|
|
mext_irq_i : in std_ulogic := 'L' -- machine external interrupt
|
1050 |
2 |
zero_gravi |
);
|
1051 |
|
|
end component;
|
1052 |
|
|
|
1053 |
4 |
zero_gravi |
-- Component: CPU Top Entity --------------------------------------------------------------
|
1054 |
|
|
-- -------------------------------------------------------------------------------------------
|
1055 |
|
|
component neorv32_cpu
|
1056 |
|
|
generic (
|
1057 |
|
|
-- General --
|
1058 |
62 |
zero_gravi |
HW_THREAD_ID : natural; -- hardware thread id (32-bit)
|
1059 |
|
|
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0); -- cpu boot address
|
1060 |
|
|
CPU_DEBUG_ADDR : std_ulogic_vector(31 downto 0); -- cpu debug mode start address
|
1061 |
4 |
zero_gravi |
-- RISC-V CPU Extensions --
|
1062 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_A : boolean; -- implement atomic extension?
|
1063 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_B : boolean; -- implement bit-manipulation extension?
|
1064 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_C : boolean; -- implement compressed extension?
|
1065 |
|
|
CPU_EXTENSION_RISCV_E : boolean; -- implement embedded RF extension?
|
1066 |
|
|
CPU_EXTENSION_RISCV_M : boolean; -- implement mul/div extension?
|
1067 |
|
|
CPU_EXTENSION_RISCV_U : boolean; -- implement user mode extension?
|
1068 |
|
|
CPU_EXTENSION_RISCV_Zfinx : boolean; -- implement 32-bit floating-point extension (using INT reg!)
|
1069 |
|
|
CPU_EXTENSION_RISCV_Zicsr : boolean; -- implement CSR system?
|
1070 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicntr : boolean; -- implement base counters?
|
1071 |
|
|
CPU_EXTENSION_RISCV_Zihpm : boolean; -- implement hardware performance monitors?
|
1072 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_Zifencei : boolean; -- implement instruction stream sync.?
|
1073 |
|
|
CPU_EXTENSION_RISCV_Zmmul : boolean; -- implement multiply-only M sub-extension?
|
1074 |
|
|
CPU_EXTENSION_RISCV_DEBUG : boolean; -- implement CPU debug mode?
|
1075 |
19 |
zero_gravi |
-- Extension Options --
|
1076 |
62 |
zero_gravi |
FAST_MUL_EN : boolean; -- use DSPs for M extension's multiplier
|
1077 |
|
|
FAST_SHIFT_EN : boolean; -- use barrel shifter for shift operations
|
1078 |
|
|
CPU_CNT_WIDTH : natural; -- total width of CPU cycle and instret counters (0..64)
|
1079 |
|
|
CPU_IPB_ENTRIES : natural; -- entries is instruction prefetch buffer, has to be a power of 2
|
1080 |
15 |
zero_gravi |
-- Physical Memory Protection (PMP) --
|
1081 |
62 |
zero_gravi |
PMP_NUM_REGIONS : natural; -- number of regions (0..64)
|
1082 |
|
|
PMP_MIN_GRANULARITY : natural; -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
1083 |
42 |
zero_gravi |
-- Hardware Performance Monitors (HPM) --
|
1084 |
62 |
zero_gravi |
HPM_NUM_CNTS : natural; -- number of implemented HPM counters (0..29)
|
1085 |
|
|
HPM_CNT_WIDTH : natural -- total size of HPM counters (0..64)
|
1086 |
4 |
zero_gravi |
);
|
1087 |
|
|
port (
|
1088 |
|
|
-- global control --
|
1089 |
62 |
zero_gravi |
clk_i : in std_ulogic; -- global clock, rising edge
|
1090 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1091 |
47 |
zero_gravi |
sleep_o : out std_ulogic; -- cpu is in sleep mode when set
|
1092 |
12 |
zero_gravi |
-- instruction bus interface --
|
1093 |
|
|
i_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1094 |
62 |
zero_gravi |
i_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1095 |
12 |
zero_gravi |
i_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1096 |
|
|
i_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1097 |
|
|
i_bus_we_o : out std_ulogic; -- write enable
|
1098 |
|
|
i_bus_re_o : out std_ulogic; -- read enable
|
1099 |
57 |
zero_gravi |
i_bus_lock_o : out std_ulogic; -- exclusive access request
|
1100 |
62 |
zero_gravi |
i_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
1101 |
|
|
i_bus_err_i : in std_ulogic; -- bus transfer error
|
1102 |
12 |
zero_gravi |
i_bus_fence_o : out std_ulogic; -- executed FENCEI operation
|
1103 |
35 |
zero_gravi |
i_bus_priv_o : out std_ulogic_vector(1 downto 0); -- privilege level
|
1104 |
12 |
zero_gravi |
-- data bus interface --
|
1105 |
|
|
d_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1106 |
62 |
zero_gravi |
d_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1107 |
12 |
zero_gravi |
d_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1108 |
|
|
d_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1109 |
|
|
d_bus_we_o : out std_ulogic; -- write enable
|
1110 |
|
|
d_bus_re_o : out std_ulogic; -- read enable
|
1111 |
57 |
zero_gravi |
d_bus_lock_o : out std_ulogic; -- exclusive access request
|
1112 |
62 |
zero_gravi |
d_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
1113 |
|
|
d_bus_err_i : in std_ulogic; -- bus transfer error
|
1114 |
12 |
zero_gravi |
d_bus_fence_o : out std_ulogic; -- executed FENCE operation
|
1115 |
35 |
zero_gravi |
d_bus_priv_o : out std_ulogic_vector(1 downto 0); -- privilege level
|
1116 |
11 |
zero_gravi |
-- system time input from MTIME --
|
1117 |
62 |
zero_gravi |
time_i : in std_ulogic_vector(63 downto 0); -- current system time
|
1118 |
14 |
zero_gravi |
-- interrupts (risc-v compliant) --
|
1119 |
62 |
zero_gravi |
msw_irq_i : in std_ulogic; -- machine software interrupt
|
1120 |
|
|
mext_irq_i : in std_ulogic; -- machine external interrupt
|
1121 |
|
|
mtime_irq_i : in std_ulogic; -- machine timer interrupt
|
1122 |
14 |
zero_gravi |
-- fast interrupts (custom) --
|
1123 |
62 |
zero_gravi |
firq_i : in std_ulogic_vector(15 downto 0);
|
1124 |
59 |
zero_gravi |
-- debug mode (halt) request --
|
1125 |
62 |
zero_gravi |
db_halt_req_i : in std_ulogic
|
1126 |
4 |
zero_gravi |
);
|
1127 |
|
|
end component;
|
1128 |
|
|
|
1129 |
2 |
zero_gravi |
-- Component: CPU Control -----------------------------------------------------------------
|
1130 |
|
|
-- -------------------------------------------------------------------------------------------
|
1131 |
|
|
component neorv32_cpu_control
|
1132 |
|
|
generic (
|
1133 |
|
|
-- General --
|
1134 |
62 |
zero_gravi |
HW_THREAD_ID : natural; -- hardware thread id (32-bit)
|
1135 |
|
|
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0); -- cpu boot address
|
1136 |
|
|
CPU_DEBUG_ADDR : std_ulogic_vector(31 downto 0); -- cpu debug mode start address
|
1137 |
2 |
zero_gravi |
-- RISC-V CPU Extensions --
|
1138 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_A : boolean; -- implement atomic extension?
|
1139 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_B : boolean; -- implement bit-manipulation extension?
|
1140 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_C : boolean; -- implement compressed extension?
|
1141 |
|
|
CPU_EXTENSION_RISCV_E : boolean; -- implement embedded RF extension?
|
1142 |
|
|
CPU_EXTENSION_RISCV_M : boolean; -- implement mul/div extension?
|
1143 |
|
|
CPU_EXTENSION_RISCV_U : boolean; -- implement user mode extension?
|
1144 |
|
|
CPU_EXTENSION_RISCV_Zfinx : boolean; -- implement 32-bit floating-point extension (using INT reg!)
|
1145 |
|
|
CPU_EXTENSION_RISCV_Zicsr : boolean; -- implement CSR system?
|
1146 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicntr : boolean; -- implement base counters?
|
1147 |
|
|
CPU_EXTENSION_RISCV_Zihpm : boolean; -- implement hardware performance monitors?
|
1148 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_Zifencei : boolean; -- implement instruction stream sync.?
|
1149 |
|
|
CPU_EXTENSION_RISCV_Zmmul : boolean; -- implement multiply-only M sub-extension?
|
1150 |
|
|
CPU_EXTENSION_RISCV_DEBUG : boolean; -- implement CPU debug mode?
|
1151 |
56 |
zero_gravi |
-- Extension Options --
|
1152 |
62 |
zero_gravi |
CPU_CNT_WIDTH : natural; -- total width of CPU cycle and instret counters (0..64)
|
1153 |
|
|
CPU_IPB_ENTRIES : natural; -- entries is instruction prefetch buffer, has to be a power of 2
|
1154 |
15 |
zero_gravi |
-- Physical memory protection (PMP) --
|
1155 |
62 |
zero_gravi |
PMP_NUM_REGIONS : natural; -- number of regions (0..64)
|
1156 |
|
|
PMP_MIN_GRANULARITY : natural; -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
1157 |
42 |
zero_gravi |
-- Hardware Performance Monitors (HPM) --
|
1158 |
62 |
zero_gravi |
HPM_NUM_CNTS : natural; -- number of implemented HPM counters (0..29)
|
1159 |
|
|
HPM_CNT_WIDTH : natural -- total size of HPM counters (0..64)
|
1160 |
2 |
zero_gravi |
);
|
1161 |
|
|
port (
|
1162 |
|
|
-- global control --
|
1163 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1164 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1165 |
|
|
ctrl_o : out std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1166 |
|
|
-- status input --
|
1167 |
61 |
zero_gravi |
alu_idone_i : in std_ulogic; -- ALU iterative operation done
|
1168 |
12 |
zero_gravi |
bus_i_wait_i : in std_ulogic; -- wait for bus
|
1169 |
|
|
bus_d_wait_i : in std_ulogic; -- wait for bus
|
1170 |
57 |
zero_gravi |
excl_state_i : in std_ulogic; -- atomic/exclusive access lock status
|
1171 |
2 |
zero_gravi |
-- data input --
|
1172 |
|
|
instr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- instruction
|
1173 |
|
|
cmp_i : in std_ulogic_vector(1 downto 0); -- comparator status
|
1174 |
36 |
zero_gravi |
alu_add_i : in std_ulogic_vector(data_width_c-1 downto 0); -- ALU address result
|
1175 |
52 |
zero_gravi |
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
1176 |
2 |
zero_gravi |
-- data output --
|
1177 |
|
|
imm_o : out std_ulogic_vector(data_width_c-1 downto 0); -- immediate
|
1178 |
6 |
zero_gravi |
fetch_pc_o : out std_ulogic_vector(data_width_c-1 downto 0); -- PC for instruction fetch
|
1179 |
|
|
curr_pc_o : out std_ulogic_vector(data_width_c-1 downto 0); -- current PC (corresponding to current instruction)
|
1180 |
2 |
zero_gravi |
csr_rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- CSR read data
|
1181 |
52 |
zero_gravi |
-- FPU interface --
|
1182 |
|
|
fpu_flags_i : in std_ulogic_vector(04 downto 0); -- exception flags
|
1183 |
59 |
zero_gravi |
-- debug mode (halt) request --
|
1184 |
|
|
db_halt_req_i : in std_ulogic;
|
1185 |
14 |
zero_gravi |
-- interrupts (risc-v compliant) --
|
1186 |
|
|
msw_irq_i : in std_ulogic; -- machine software interrupt
|
1187 |
|
|
mext_irq_i : in std_ulogic; -- machine external interrupt
|
1188 |
2 |
zero_gravi |
mtime_irq_i : in std_ulogic; -- machine timer interrupt
|
1189 |
14 |
zero_gravi |
-- fast interrupts (custom) --
|
1190 |
48 |
zero_gravi |
firq_i : in std_ulogic_vector(15 downto 0);
|
1191 |
11 |
zero_gravi |
-- system time input from MTIME --
|
1192 |
|
|
time_i : in std_ulogic_vector(63 downto 0); -- current system time
|
1193 |
15 |
zero_gravi |
-- physical memory protection --
|
1194 |
|
|
pmp_addr_o : out pmp_addr_if_t; -- addresses
|
1195 |
|
|
pmp_ctrl_o : out pmp_ctrl_if_t; -- configs
|
1196 |
2 |
zero_gravi |
-- bus access exceptions --
|
1197 |
|
|
mar_i : in std_ulogic_vector(data_width_c-1 downto 0); -- memory address register
|
1198 |
|
|
ma_instr_i : in std_ulogic; -- misaligned instruction address
|
1199 |
|
|
ma_load_i : in std_ulogic; -- misaligned load data address
|
1200 |
|
|
ma_store_i : in std_ulogic; -- misaligned store data address
|
1201 |
|
|
be_instr_i : in std_ulogic; -- bus error on instruction access
|
1202 |
|
|
be_load_i : in std_ulogic; -- bus error on load data access
|
1203 |
12 |
zero_gravi |
be_store_i : in std_ulogic -- bus error on store data access
|
1204 |
2 |
zero_gravi |
);
|
1205 |
|
|
end component;
|
1206 |
|
|
|
1207 |
|
|
-- Component: CPU Register File -----------------------------------------------------------
|
1208 |
|
|
-- -------------------------------------------------------------------------------------------
|
1209 |
|
|
component neorv32_cpu_regfile
|
1210 |
|
|
generic (
|
1211 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_E : boolean -- implement embedded RF extension?
|
1212 |
2 |
zero_gravi |
);
|
1213 |
|
|
port (
|
1214 |
|
|
-- global control --
|
1215 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1216 |
|
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1217 |
|
|
-- data input --
|
1218 |
|
|
mem_i : in std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
|
1219 |
|
|
alu_i : in std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
|
1220 |
|
|
-- data output --
|
1221 |
|
|
rs1_o : out std_ulogic_vector(data_width_c-1 downto 0); -- operand 1
|
1222 |
65 |
zero_gravi |
rs2_o : out std_ulogic_vector(data_width_c-1 downto 0) -- operand 2
|
1223 |
2 |
zero_gravi |
);
|
1224 |
|
|
end component;
|
1225 |
|
|
|
1226 |
|
|
-- Component: CPU ALU ---------------------------------------------------------------------
|
1227 |
|
|
-- -------------------------------------------------------------------------------------------
|
1228 |
|
|
component neorv32_cpu_alu
|
1229 |
11 |
zero_gravi |
generic (
|
1230 |
61 |
zero_gravi |
-- RISC-V CPU Extensions --
|
1231 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_B : boolean; -- implement bit-manipulation extension?
|
1232 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_M : boolean; -- implement mul/div extension?
|
1233 |
|
|
CPU_EXTENSION_RISCV_Zmmul : boolean; -- implement multiply-only M sub-extension?
|
1234 |
|
|
CPU_EXTENSION_RISCV_Zfinx : boolean; -- implement 32-bit floating-point extension (using INT reg!)
|
1235 |
61 |
zero_gravi |
-- Extension Options --
|
1236 |
62 |
zero_gravi |
FAST_MUL_EN : boolean; -- use DSPs for M extension's multiplier
|
1237 |
|
|
FAST_SHIFT_EN : boolean -- use barrel shifter for shift operations
|
1238 |
11 |
zero_gravi |
);
|
1239 |
2 |
zero_gravi |
port (
|
1240 |
|
|
-- global control --
|
1241 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1242 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1243 |
|
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1244 |
|
|
-- data input --
|
1245 |
|
|
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
1246 |
|
|
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
1247 |
|
|
pc2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- delayed PC
|
1248 |
|
|
imm_i : in std_ulogic_vector(data_width_c-1 downto 0); -- immediate
|
1249 |
61 |
zero_gravi |
csr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- CSR read data
|
1250 |
2 |
zero_gravi |
-- data output --
|
1251 |
65 |
zero_gravi |
cmp_o : out std_ulogic_vector(1 downto 0); -- comparator status
|
1252 |
2 |
zero_gravi |
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- ALU result
|
1253 |
36 |
zero_gravi |
add_o : out std_ulogic_vector(data_width_c-1 downto 0); -- address computation result
|
1254 |
61 |
zero_gravi |
fpu_flags_o : out std_ulogic_vector(4 downto 0); -- FPU exception flags
|
1255 |
2 |
zero_gravi |
-- status --
|
1256 |
61 |
zero_gravi |
idone_o : out std_ulogic -- iterative processing units done?
|
1257 |
2 |
zero_gravi |
);
|
1258 |
|
|
end component;
|
1259 |
|
|
|
1260 |
61 |
zero_gravi |
-- Component: CPU Co-Processor SHIFTER ----------------------------------------------------
|
1261 |
|
|
-- -------------------------------------------------------------------------------------------
|
1262 |
|
|
component neorv32_cpu_cp_shifter
|
1263 |
|
|
generic (
|
1264 |
62 |
zero_gravi |
FAST_SHIFT_EN : boolean -- use barrel shifter for shift operations
|
1265 |
61 |
zero_gravi |
);
|
1266 |
|
|
port (
|
1267 |
|
|
-- global control --
|
1268 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1269 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1270 |
|
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1271 |
|
|
start_i : in std_ulogic; -- trigger operation
|
1272 |
|
|
-- data input --
|
1273 |
|
|
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
1274 |
66 |
zero_gravi |
shamt_i : in std_ulogic_vector(index_size_f(data_width_c)-1 downto 0); -- shift amount
|
1275 |
61 |
zero_gravi |
-- result and status --
|
1276 |
|
|
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- operation result
|
1277 |
|
|
valid_o : out std_ulogic -- data output valid
|
1278 |
|
|
);
|
1279 |
|
|
end component;
|
1280 |
|
|
|
1281 |
44 |
zero_gravi |
-- Component: CPU Co-Processor MULDIV ('M' extension) -------------------------------------
|
1282 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
1283 |
|
|
component neorv32_cpu_cp_muldiv
|
1284 |
19 |
zero_gravi |
generic (
|
1285 |
62 |
zero_gravi |
FAST_MUL_EN : boolean; -- use DSPs for faster multiplication
|
1286 |
|
|
DIVISION_EN : boolean -- implement divider hardware
|
1287 |
19 |
zero_gravi |
);
|
1288 |
2 |
zero_gravi |
port (
|
1289 |
|
|
-- global control --
|
1290 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1291 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1292 |
|
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1293 |
36 |
zero_gravi |
start_i : in std_ulogic; -- trigger operation
|
1294 |
2 |
zero_gravi |
-- data input --
|
1295 |
|
|
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
1296 |
|
|
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
1297 |
|
|
-- result and status --
|
1298 |
|
|
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- operation result
|
1299 |
|
|
valid_o : out std_ulogic -- data output valid
|
1300 |
|
|
);
|
1301 |
|
|
end component;
|
1302 |
|
|
|
1303 |
63 |
zero_gravi |
-- Component: CPU Co-Processor Bit-Manipulation Unit ('B' extension) ----------------------
|
1304 |
|
|
-- -------------------------------------------------------------------------------------------
|
1305 |
|
|
component neorv32_cpu_cp_bitmanip is
|
1306 |
|
|
generic (
|
1307 |
66 |
zero_gravi |
FAST_SHIFT_EN : boolean -- use barrel shifter for shift operations
|
1308 |
63 |
zero_gravi |
);
|
1309 |
|
|
port (
|
1310 |
|
|
-- global control --
|
1311 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1312 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1313 |
|
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1314 |
|
|
start_i : in std_ulogic; -- trigger operation
|
1315 |
|
|
-- data input --
|
1316 |
|
|
cmp_i : in std_ulogic_vector(1 downto 0); -- comparator status
|
1317 |
|
|
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
1318 |
|
|
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
1319 |
66 |
zero_gravi |
shamt_i : in std_ulogic_vector(index_size_f(data_width_c)-1 downto 0); -- shift amount
|
1320 |
63 |
zero_gravi |
-- result and status --
|
1321 |
|
|
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- operation result
|
1322 |
|
|
valid_o : out std_ulogic -- data output valid
|
1323 |
|
|
);
|
1324 |
|
|
end component;
|
1325 |
|
|
|
1326 |
53 |
zero_gravi |
-- Component: CPU Co-Processor 32-bit FPU ('Zfinx' extension) -----------------------------
|
1327 |
52 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
1328 |
|
|
component neorv32_cpu_cp_fpu
|
1329 |
|
|
port (
|
1330 |
|
|
-- global control --
|
1331 |
53 |
zero_gravi |
clk_i : in std_ulogic; -- global clock, rising edge
|
1332 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1333 |
|
|
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1334 |
|
|
start_i : in std_ulogic; -- trigger operation
|
1335 |
52 |
zero_gravi |
-- data input --
|
1336 |
56 |
zero_gravi |
cmp_i : in std_ulogic_vector(1 downto 0); -- comparator status
|
1337 |
53 |
zero_gravi |
rs1_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 1
|
1338 |
|
|
rs2_i : in std_ulogic_vector(data_width_c-1 downto 0); -- rf source 2
|
1339 |
52 |
zero_gravi |
-- result and status --
|
1340 |
53 |
zero_gravi |
res_o : out std_ulogic_vector(data_width_c-1 downto 0); -- operation result
|
1341 |
|
|
fflags_o : out std_ulogic_vector(4 downto 0); -- exception flags
|
1342 |
|
|
valid_o : out std_ulogic -- data output valid
|
1343 |
52 |
zero_gravi |
);
|
1344 |
|
|
end component;
|
1345 |
|
|
|
1346 |
2 |
zero_gravi |
-- Component: CPU Bus Interface -----------------------------------------------------------
|
1347 |
|
|
-- -------------------------------------------------------------------------------------------
|
1348 |
|
|
component neorv32_cpu_bus
|
1349 |
|
|
generic (
|
1350 |
62 |
zero_gravi |
CPU_EXTENSION_RISCV_A : boolean; -- implement atomic extension?
|
1351 |
|
|
CPU_EXTENSION_RISCV_C : boolean; -- implement compressed extension?
|
1352 |
15 |
zero_gravi |
-- Physical memory protection (PMP) --
|
1353 |
62 |
zero_gravi |
PMP_NUM_REGIONS : natural; -- number of regions (0..64)
|
1354 |
|
|
PMP_MIN_GRANULARITY : natural -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
1355 |
2 |
zero_gravi |
);
|
1356 |
|
|
port (
|
1357 |
|
|
-- global control --
|
1358 |
12 |
zero_gravi |
clk_i : in std_ulogic; -- global clock, rising edge
|
1359 |
38 |
zero_gravi |
rstn_i : in std_ulogic := '0'; -- global reset, low-active, async
|
1360 |
12 |
zero_gravi |
ctrl_i : in std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
1361 |
|
|
-- cpu instruction fetch interface --
|
1362 |
|
|
fetch_pc_i : in std_ulogic_vector(data_width_c-1 downto 0); -- PC for instruction fetch
|
1363 |
|
|
instr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- instruction
|
1364 |
|
|
i_wait_o : out std_ulogic; -- wait for fetch to complete
|
1365 |
|
|
--
|
1366 |
|
|
ma_instr_o : out std_ulogic; -- misaligned instruction address
|
1367 |
|
|
be_instr_o : out std_ulogic; -- bus error on instruction access
|
1368 |
|
|
-- cpu data access interface --
|
1369 |
|
|
addr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- ALU result -> access address
|
1370 |
|
|
wdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- write data
|
1371 |
|
|
rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- read data
|
1372 |
|
|
mar_o : out std_ulogic_vector(data_width_c-1 downto 0); -- current memory address register
|
1373 |
|
|
d_wait_o : out std_ulogic; -- wait for access to complete
|
1374 |
|
|
--
|
1375 |
57 |
zero_gravi |
excl_state_o : out std_ulogic; -- atomic/exclusive access status
|
1376 |
12 |
zero_gravi |
ma_load_o : out std_ulogic; -- misaligned load data address
|
1377 |
|
|
ma_store_o : out std_ulogic; -- misaligned store data address
|
1378 |
|
|
be_load_o : out std_ulogic; -- bus error on load data access
|
1379 |
|
|
be_store_o : out std_ulogic; -- bus error on store data access
|
1380 |
15 |
zero_gravi |
-- physical memory protection --
|
1381 |
|
|
pmp_addr_i : in pmp_addr_if_t; -- addresses
|
1382 |
|
|
pmp_ctrl_i : in pmp_ctrl_if_t; -- configs
|
1383 |
12 |
zero_gravi |
-- instruction bus --
|
1384 |
|
|
i_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1385 |
|
|
i_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1386 |
|
|
i_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1387 |
|
|
i_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1388 |
|
|
i_bus_we_o : out std_ulogic; -- write enable
|
1389 |
|
|
i_bus_re_o : out std_ulogic; -- read enable
|
1390 |
57 |
zero_gravi |
i_bus_lock_o : out std_ulogic; -- exclusive access request
|
1391 |
12 |
zero_gravi |
i_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
1392 |
|
|
i_bus_err_i : in std_ulogic; -- bus transfer error
|
1393 |
|
|
i_bus_fence_o : out std_ulogic; -- fence operation
|
1394 |
|
|
-- data bus --
|
1395 |
|
|
d_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1396 |
|
|
d_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1397 |
|
|
d_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1398 |
|
|
d_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1399 |
|
|
d_bus_we_o : out std_ulogic; -- write enable
|
1400 |
|
|
d_bus_re_o : out std_ulogic; -- read enable
|
1401 |
57 |
zero_gravi |
d_bus_lock_o : out std_ulogic; -- exclusive access request
|
1402 |
12 |
zero_gravi |
d_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
1403 |
|
|
d_bus_err_i : in std_ulogic; -- bus transfer error
|
1404 |
57 |
zero_gravi |
d_bus_fence_o : out std_ulogic -- fence operation
|
1405 |
2 |
zero_gravi |
);
|
1406 |
|
|
end component;
|
1407 |
|
|
|
1408 |
57 |
zero_gravi |
-- Component: Bus Keeper ------------------------------------------------------------------
|
1409 |
|
|
-- -------------------------------------------------------------------------------------------
|
1410 |
|
|
component neorv32_bus_keeper is
|
1411 |
|
|
generic (
|
1412 |
59 |
zero_gravi |
-- External memory interface --
|
1413 |
62 |
zero_gravi |
MEM_EXT_EN : boolean; -- implement external memory bus interface?
|
1414 |
57 |
zero_gravi |
-- Internal instruction memory --
|
1415 |
62 |
zero_gravi |
MEM_INT_IMEM_EN : boolean; -- implement processor-internal instruction memory
|
1416 |
|
|
MEM_INT_IMEM_SIZE : natural; -- size of processor-internal instruction memory in bytes
|
1417 |
57 |
zero_gravi |
-- Internal data memory --
|
1418 |
62 |
zero_gravi |
MEM_INT_DMEM_EN : boolean; -- implement processor-internal data memory
|
1419 |
|
|
MEM_INT_DMEM_SIZE : natural -- size of processor-internal data memory in bytes
|
1420 |
57 |
zero_gravi |
);
|
1421 |
|
|
port (
|
1422 |
|
|
-- host access --
|
1423 |
66 |
zero_gravi |
clk_i : in std_ulogic; -- global clock line
|
1424 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1425 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1426 |
|
|
rden_i : in std_ulogic; -- read enable
|
1427 |
|
|
wren_i : in std_ulogic; -- write enable
|
1428 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1429 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1430 |
|
|
err_o : out std_ulogic; -- transfer error
|
1431 |
|
|
-- bus monitoring --
|
1432 |
|
|
bus_addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1433 |
|
|
bus_rden_i : in std_ulogic; -- read enable
|
1434 |
|
|
bus_wren_i : in std_ulogic; -- write enable
|
1435 |
|
|
bus_ack_i : in std_ulogic; -- transfer acknowledge from bus system
|
1436 |
|
|
bus_err_i : in std_ulogic -- transfer error from bus system
|
1437 |
57 |
zero_gravi |
);
|
1438 |
|
|
end component;
|
1439 |
|
|
|
1440 |
45 |
zero_gravi |
-- Component: CPU Instruction Cache -------------------------------------------------------
|
1441 |
41 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
1442 |
45 |
zero_gravi |
component neorv32_icache
|
1443 |
41 |
zero_gravi |
generic (
|
1444 |
62 |
zero_gravi |
ICACHE_NUM_BLOCKS : natural; -- number of blocks (min 1), has to be a power of 2
|
1445 |
|
|
ICACHE_BLOCK_SIZE : natural; -- block size in bytes (min 4), has to be a power of 2
|
1446 |
|
|
ICACHE_NUM_SETS : natural -- associativity / number of sets (1=direct_mapped), has to be a power of 2
|
1447 |
41 |
zero_gravi |
);
|
1448 |
|
|
port (
|
1449 |
|
|
-- global control --
|
1450 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1451 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1452 |
|
|
clear_i : in std_ulogic; -- cache clear
|
1453 |
|
|
-- host controller interface --
|
1454 |
|
|
host_addr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1455 |
|
|
host_rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1456 |
|
|
host_wdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1457 |
|
|
host_ben_i : in std_ulogic_vector(03 downto 0); -- byte enable
|
1458 |
|
|
host_we_i : in std_ulogic; -- write enable
|
1459 |
|
|
host_re_i : in std_ulogic; -- read enable
|
1460 |
|
|
host_ack_o : out std_ulogic; -- bus transfer acknowledge
|
1461 |
|
|
host_err_o : out std_ulogic; -- bus transfer error
|
1462 |
|
|
-- peripheral bus interface --
|
1463 |
|
|
bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1464 |
|
|
bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1465 |
|
|
bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1466 |
|
|
bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1467 |
|
|
bus_we_o : out std_ulogic; -- write enable
|
1468 |
|
|
bus_re_o : out std_ulogic; -- read enable
|
1469 |
|
|
bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
1470 |
|
|
bus_err_i : in std_ulogic -- bus transfer error
|
1471 |
|
|
);
|
1472 |
|
|
end component;
|
1473 |
|
|
|
1474 |
12 |
zero_gravi |
-- Component: CPU Bus Switch --------------------------------------------------------------
|
1475 |
|
|
-- -------------------------------------------------------------------------------------------
|
1476 |
|
|
component neorv32_busswitch
|
1477 |
|
|
generic (
|
1478 |
62 |
zero_gravi |
PORT_CA_READ_ONLY : boolean; -- set if controller port A is read-only
|
1479 |
|
|
PORT_CB_READ_ONLY : boolean -- set if controller port B is read-only
|
1480 |
12 |
zero_gravi |
);
|
1481 |
|
|
port (
|
1482 |
|
|
-- global control --
|
1483 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
1484 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
1485 |
|
|
-- controller interface a --
|
1486 |
|
|
ca_bus_addr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1487 |
|
|
ca_bus_rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1488 |
|
|
ca_bus_wdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1489 |
|
|
ca_bus_ben_i : in std_ulogic_vector(03 downto 0); -- byte enable
|
1490 |
|
|
ca_bus_we_i : in std_ulogic; -- write enable
|
1491 |
|
|
ca_bus_re_i : in std_ulogic; -- read enable
|
1492 |
57 |
zero_gravi |
ca_bus_lock_i : in std_ulogic; -- exclusive access request
|
1493 |
12 |
zero_gravi |
ca_bus_ack_o : out std_ulogic; -- bus transfer acknowledge
|
1494 |
|
|
ca_bus_err_o : out std_ulogic; -- bus transfer error
|
1495 |
|
|
-- controller interface b --
|
1496 |
|
|
cb_bus_addr_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1497 |
|
|
cb_bus_rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1498 |
|
|
cb_bus_wdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1499 |
|
|
cb_bus_ben_i : in std_ulogic_vector(03 downto 0); -- byte enable
|
1500 |
|
|
cb_bus_we_i : in std_ulogic; -- write enable
|
1501 |
|
|
cb_bus_re_i : in std_ulogic; -- read enable
|
1502 |
57 |
zero_gravi |
cb_bus_lock_i : in std_ulogic; -- exclusive access request
|
1503 |
12 |
zero_gravi |
cb_bus_ack_o : out std_ulogic; -- bus transfer acknowledge
|
1504 |
|
|
cb_bus_err_o : out std_ulogic; -- bus transfer error
|
1505 |
|
|
-- peripheral bus --
|
1506 |
36 |
zero_gravi |
p_bus_src_o : out std_ulogic; -- access source: 0 = A, 1 = B
|
1507 |
12 |
zero_gravi |
p_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
1508 |
|
|
p_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0); -- bus read data
|
1509 |
|
|
p_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
1510 |
|
|
p_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1511 |
|
|
p_bus_we_o : out std_ulogic; -- write enable
|
1512 |
|
|
p_bus_re_o : out std_ulogic; -- read enable
|
1513 |
57 |
zero_gravi |
p_bus_lock_o : out std_ulogic; -- exclusive access request
|
1514 |
12 |
zero_gravi |
p_bus_ack_i : in std_ulogic; -- bus transfer acknowledge
|
1515 |
|
|
p_bus_err_i : in std_ulogic -- bus transfer error
|
1516 |
|
|
);
|
1517 |
|
|
end component;
|
1518 |
|
|
|
1519 |
2 |
zero_gravi |
-- Component: CPU Compressed Instructions Decompressor ------------------------------------
|
1520 |
|
|
-- -------------------------------------------------------------------------------------------
|
1521 |
|
|
component neorv32_cpu_decompressor
|
1522 |
|
|
port (
|
1523 |
|
|
-- instruction input --
|
1524 |
|
|
ci_instr16_i : in std_ulogic_vector(15 downto 0); -- compressed instruction input
|
1525 |
|
|
-- instruction output --
|
1526 |
|
|
ci_illegal_o : out std_ulogic; -- is an illegal compressed instruction
|
1527 |
|
|
ci_instr32_o : out std_ulogic_vector(31 downto 0) -- 32-bit decompressed instruction
|
1528 |
|
|
);
|
1529 |
|
|
end component;
|
1530 |
|
|
|
1531 |
|
|
-- Component: Processor-internal instruction memory (IMEM) --------------------------------
|
1532 |
|
|
-- -------------------------------------------------------------------------------------------
|
1533 |
|
|
component neorv32_imem
|
1534 |
|
|
generic (
|
1535 |
62 |
zero_gravi |
IMEM_BASE : std_ulogic_vector(31 downto 0); -- memory base address
|
1536 |
|
|
IMEM_SIZE : natural; -- processor-internal instruction memory size in bytes
|
1537 |
|
|
IMEM_AS_IROM : boolean -- implement IMEM as pre-initialized read-only memory?
|
1538 |
2 |
zero_gravi |
);
|
1539 |
|
|
port (
|
1540 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1541 |
|
|
rden_i : in std_ulogic; -- read enable
|
1542 |
|
|
wren_i : in std_ulogic; -- write enable
|
1543 |
|
|
ben_i : in std_ulogic_vector(03 downto 0); -- byte write enable
|
1544 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1545 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1546 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1547 |
|
|
ack_o : out std_ulogic -- transfer acknowledge
|
1548 |
|
|
);
|
1549 |
|
|
end component;
|
1550 |
|
|
|
1551 |
|
|
-- Component: Processor-internal data memory (DMEM) ---------------------------------------
|
1552 |
|
|
-- -------------------------------------------------------------------------------------------
|
1553 |
|
|
component neorv32_dmem
|
1554 |
|
|
generic (
|
1555 |
62 |
zero_gravi |
DMEM_BASE : std_ulogic_vector(31 downto 0); -- memory base address
|
1556 |
|
|
DMEM_SIZE : natural -- processor-internal instruction memory size in bytes
|
1557 |
2 |
zero_gravi |
);
|
1558 |
|
|
port (
|
1559 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1560 |
|
|
rden_i : in std_ulogic; -- read enable
|
1561 |
|
|
wren_i : in std_ulogic; -- write enable
|
1562 |
|
|
ben_i : in std_ulogic_vector(03 downto 0); -- byte write enable
|
1563 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1564 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1565 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1566 |
|
|
ack_o : out std_ulogic -- transfer acknowledge
|
1567 |
|
|
);
|
1568 |
|
|
end component;
|
1569 |
|
|
|
1570 |
|
|
-- Component: Processor-internal bootloader ROM (BOOTROM) ---------------------------------
|
1571 |
|
|
-- -------------------------------------------------------------------------------------------
|
1572 |
|
|
component neorv32_boot_rom
|
1573 |
23 |
zero_gravi |
generic (
|
1574 |
62 |
zero_gravi |
BOOTROM_BASE : std_ulogic_vector(31 downto 0) -- boot ROM base address
|
1575 |
23 |
zero_gravi |
);
|
1576 |
2 |
zero_gravi |
port (
|
1577 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1578 |
|
|
rden_i : in std_ulogic; -- read enable
|
1579 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1580 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1581 |
|
|
ack_o : out std_ulogic -- transfer acknowledge
|
1582 |
|
|
);
|
1583 |
|
|
end component;
|
1584 |
|
|
|
1585 |
|
|
-- Component: Machine System Timer (mtime) ------------------------------------------------
|
1586 |
|
|
-- -------------------------------------------------------------------------------------------
|
1587 |
|
|
component neorv32_mtime
|
1588 |
|
|
port (
|
1589 |
|
|
-- host access --
|
1590 |
60 |
zero_gravi |
clk_i : in std_ulogic; -- global clock line
|
1591 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1592 |
|
|
rden_i : in std_ulogic; -- read enable
|
1593 |
|
|
wren_i : in std_ulogic; -- write enable
|
1594 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1595 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1596 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1597 |
11 |
zero_gravi |
-- time output for CPU --
|
1598 |
60 |
zero_gravi |
time_o : out std_ulogic_vector(63 downto 0); -- current system time
|
1599 |
2 |
zero_gravi |
-- interrupt --
|
1600 |
60 |
zero_gravi |
irq_o : out std_ulogic -- interrupt request
|
1601 |
2 |
zero_gravi |
);
|
1602 |
|
|
end component;
|
1603 |
|
|
|
1604 |
|
|
-- Component: General Purpose Input/Output Port (GPIO) ------------------------------------
|
1605 |
|
|
-- -------------------------------------------------------------------------------------------
|
1606 |
|
|
component neorv32_gpio
|
1607 |
|
|
port (
|
1608 |
|
|
-- host access --
|
1609 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1610 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1611 |
|
|
rden_i : in std_ulogic; -- read enable
|
1612 |
|
|
wren_i : in std_ulogic; -- write enable
|
1613 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1614 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1615 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1616 |
|
|
-- parallel io --
|
1617 |
61 |
zero_gravi |
gpio_o : out std_ulogic_vector(63 downto 0);
|
1618 |
|
|
gpio_i : in std_ulogic_vector(63 downto 0)
|
1619 |
2 |
zero_gravi |
);
|
1620 |
|
|
end component;
|
1621 |
|
|
|
1622 |
|
|
-- Component: Watchdog Timer (WDT) --------------------------------------------------------
|
1623 |
|
|
-- -------------------------------------------------------------------------------------------
|
1624 |
|
|
component neorv32_wdt
|
1625 |
|
|
port (
|
1626 |
|
|
-- host access --
|
1627 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1628 |
|
|
rstn_i : in std_ulogic; -- global reset line, low-active
|
1629 |
|
|
rden_i : in std_ulogic; -- read enable
|
1630 |
|
|
wren_i : in std_ulogic; -- write enable
|
1631 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1632 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1633 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1634 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1635 |
|
|
-- clock generator --
|
1636 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1637 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1638 |
|
|
-- timeout event --
|
1639 |
|
|
irq_o : out std_ulogic; -- timeout IRQ
|
1640 |
|
|
rstn_o : out std_ulogic -- timeout reset, low_active, use it as async!
|
1641 |
|
|
);
|
1642 |
|
|
end component;
|
1643 |
|
|
|
1644 |
|
|
-- Component: Universal Asynchronous Receiver and Transmitter (UART) ----------------------
|
1645 |
|
|
-- -------------------------------------------------------------------------------------------
|
1646 |
|
|
component neorv32_uart
|
1647 |
50 |
zero_gravi |
generic (
|
1648 |
65 |
zero_gravi |
UART_PRIMARY : boolean; -- true = primary UART (UART0), false = secondary UART (UART1)
|
1649 |
|
|
UART_RX_FIFO : natural; -- RX fifo depth, has to be a power of two, min 1
|
1650 |
|
|
UART_TX_FIFO : natural -- TX fifo depth, has to be a power of two, min 1
|
1651 |
50 |
zero_gravi |
);
|
1652 |
2 |
zero_gravi |
port (
|
1653 |
|
|
-- host access --
|
1654 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1655 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1656 |
|
|
rden_i : in std_ulogic; -- read enable
|
1657 |
|
|
wren_i : in std_ulogic; -- write enable
|
1658 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1659 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1660 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1661 |
|
|
-- clock generator --
|
1662 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1663 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1664 |
|
|
-- com lines --
|
1665 |
|
|
uart_txd_o : out std_ulogic;
|
1666 |
|
|
uart_rxd_i : in std_ulogic;
|
1667 |
51 |
zero_gravi |
-- hardware flow control --
|
1668 |
|
|
uart_rts_o : out std_ulogic; -- UART.RX ready to receive ("RTR"), low-active, optional
|
1669 |
|
|
uart_cts_i : in std_ulogic; -- UART.TX allowed to transmit, low-active, optional
|
1670 |
2 |
zero_gravi |
-- interrupts --
|
1671 |
48 |
zero_gravi |
irq_rxd_o : out std_ulogic; -- uart data received interrupt
|
1672 |
|
|
irq_txd_o : out std_ulogic -- uart transmission done interrupt
|
1673 |
2 |
zero_gravi |
);
|
1674 |
|
|
end component;
|
1675 |
|
|
|
1676 |
|
|
-- Component: Serial Peripheral Interface (SPI) -------------------------------------------
|
1677 |
|
|
-- -------------------------------------------------------------------------------------------
|
1678 |
|
|
component neorv32_spi
|
1679 |
|
|
port (
|
1680 |
|
|
-- host access --
|
1681 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1682 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1683 |
|
|
rden_i : in std_ulogic; -- read enable
|
1684 |
|
|
wren_i : in std_ulogic; -- write enable
|
1685 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1686 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1687 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1688 |
|
|
-- clock generator --
|
1689 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1690 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1691 |
|
|
-- com lines --
|
1692 |
6 |
zero_gravi |
spi_sck_o : out std_ulogic; -- SPI serial clock
|
1693 |
|
|
spi_sdo_o : out std_ulogic; -- controller data out, peripheral data in
|
1694 |
|
|
spi_sdi_i : in std_ulogic; -- controller data in, peripheral data out
|
1695 |
2 |
zero_gravi |
spi_csn_o : out std_ulogic_vector(07 downto 0); -- SPI CS
|
1696 |
|
|
-- interrupt --
|
1697 |
48 |
zero_gravi |
irq_o : out std_ulogic -- transmission done interrupt
|
1698 |
2 |
zero_gravi |
);
|
1699 |
|
|
end component;
|
1700 |
|
|
|
1701 |
|
|
-- Component: Two-Wire Interface (TWI) ----------------------------------------------------
|
1702 |
|
|
-- -------------------------------------------------------------------------------------------
|
1703 |
|
|
component neorv32_twi
|
1704 |
|
|
port (
|
1705 |
|
|
-- host access --
|
1706 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1707 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1708 |
|
|
rden_i : in std_ulogic; -- read enable
|
1709 |
|
|
wren_i : in std_ulogic; -- write enable
|
1710 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1711 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1712 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1713 |
|
|
-- clock generator --
|
1714 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1715 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1716 |
|
|
-- com lines --
|
1717 |
|
|
twi_sda_io : inout std_logic; -- serial data line
|
1718 |
|
|
twi_scl_io : inout std_logic; -- serial clock line
|
1719 |
|
|
-- interrupt --
|
1720 |
48 |
zero_gravi |
irq_o : out std_ulogic -- transfer done IRQ
|
1721 |
2 |
zero_gravi |
);
|
1722 |
|
|
end component;
|
1723 |
|
|
|
1724 |
|
|
-- Component: Pulse-Width Modulation Controller (PWM) -------------------------------------
|
1725 |
|
|
-- -------------------------------------------------------------------------------------------
|
1726 |
|
|
component neorv32_pwm
|
1727 |
60 |
zero_gravi |
generic (
|
1728 |
62 |
zero_gravi |
NUM_CHANNELS : natural -- number of PWM channels (0..60)
|
1729 |
60 |
zero_gravi |
);
|
1730 |
2 |
zero_gravi |
port (
|
1731 |
|
|
-- host access --
|
1732 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1733 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1734 |
|
|
rden_i : in std_ulogic; -- read enable
|
1735 |
|
|
wren_i : in std_ulogic; -- write enable
|
1736 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1737 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1738 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1739 |
|
|
-- clock generator --
|
1740 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1741 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1742 |
|
|
-- pwm output channels --
|
1743 |
60 |
zero_gravi |
pwm_o : out std_ulogic_vector(NUM_CHANNELS-1 downto 0)
|
1744 |
2 |
zero_gravi |
);
|
1745 |
|
|
end component;
|
1746 |
|
|
|
1747 |
|
|
-- Component: True Random Number Generator (TRNG) -----------------------------------------
|
1748 |
|
|
-- -------------------------------------------------------------------------------------------
|
1749 |
|
|
component neorv32_trng
|
1750 |
|
|
port (
|
1751 |
|
|
-- host access --
|
1752 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1753 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1754 |
|
|
rden_i : in std_ulogic; -- read enable
|
1755 |
|
|
wren_i : in std_ulogic; -- write enable
|
1756 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1757 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1758 |
|
|
ack_o : out std_ulogic -- transfer acknowledge
|
1759 |
|
|
);
|
1760 |
|
|
end component;
|
1761 |
|
|
|
1762 |
|
|
-- Component: Wishbone Bus Gateway (WISHBONE) ---------------------------------------------
|
1763 |
|
|
-- -------------------------------------------------------------------------------------------
|
1764 |
|
|
component neorv32_wishbone
|
1765 |
|
|
generic (
|
1766 |
23 |
zero_gravi |
-- Internal instruction memory --
|
1767 |
62 |
zero_gravi |
MEM_INT_IMEM_EN : boolean; -- implement processor-internal instruction memory
|
1768 |
|
|
MEM_INT_IMEM_SIZE : natural; -- size of processor-internal instruction memory in bytes
|
1769 |
23 |
zero_gravi |
-- Internal data memory --
|
1770 |
62 |
zero_gravi |
MEM_INT_DMEM_EN : boolean; -- implement processor-internal data memory
|
1771 |
|
|
MEM_INT_DMEM_SIZE : natural; -- size of processor-internal data memory in bytes
|
1772 |
|
|
-- Interface Configuration --
|
1773 |
|
|
BUS_TIMEOUT : natural; -- cycles after an UNACKNOWLEDGED bus access triggers a bus fault exception
|
1774 |
|
|
PIPE_MODE : boolean; -- protocol: false=classic/standard wishbone mode, true=pipelined wishbone mode
|
1775 |
|
|
BIG_ENDIAN : boolean; -- byte order: true=big-endian, false=little-endian
|
1776 |
|
|
ASYNC_RX : boolean -- use register buffer for RX data when false
|
1777 |
2 |
zero_gravi |
);
|
1778 |
|
|
port (
|
1779 |
|
|
-- global control --
|
1780 |
57 |
zero_gravi |
clk_i : in std_ulogic; -- global clock line
|
1781 |
|
|
rstn_i : in std_ulogic; -- global reset line, low-active
|
1782 |
2 |
zero_gravi |
-- host access --
|
1783 |
57 |
zero_gravi |
src_i : in std_ulogic; -- access type (0: data, 1:instruction)
|
1784 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1785 |
|
|
rden_i : in std_ulogic; -- read enable
|
1786 |
|
|
wren_i : in std_ulogic; -- write enable
|
1787 |
|
|
ben_i : in std_ulogic_vector(03 downto 0); -- byte write enable
|
1788 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1789 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1790 |
|
|
lock_i : in std_ulogic; -- exclusive access request
|
1791 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1792 |
|
|
err_o : out std_ulogic; -- transfer error
|
1793 |
|
|
priv_i : in std_ulogic_vector(01 downto 0); -- current CPU privilege level
|
1794 |
2 |
zero_gravi |
-- wishbone interface --
|
1795 |
57 |
zero_gravi |
wb_tag_o : out std_ulogic_vector(02 downto 0); -- request tag
|
1796 |
|
|
wb_adr_o : out std_ulogic_vector(31 downto 0); -- address
|
1797 |
|
|
wb_dat_i : in std_ulogic_vector(31 downto 0); -- read data
|
1798 |
|
|
wb_dat_o : out std_ulogic_vector(31 downto 0); -- write data
|
1799 |
|
|
wb_we_o : out std_ulogic; -- read/write
|
1800 |
|
|
wb_sel_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
1801 |
|
|
wb_stb_o : out std_ulogic; -- strobe
|
1802 |
|
|
wb_cyc_o : out std_ulogic; -- valid cycle
|
1803 |
|
|
wb_lock_o : out std_ulogic; -- exclusive access request
|
1804 |
|
|
wb_ack_i : in std_ulogic; -- transfer acknowledge
|
1805 |
|
|
wb_err_i : in std_ulogic -- transfer error
|
1806 |
2 |
zero_gravi |
);
|
1807 |
|
|
end component;
|
1808 |
|
|
|
1809 |
47 |
zero_gravi |
-- Component: Custom Functions Subsystem (CFS) --------------------------------------------
|
1810 |
23 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
1811 |
47 |
zero_gravi |
component neorv32_cfs
|
1812 |
|
|
generic (
|
1813 |
52 |
zero_gravi |
CFS_CONFIG : std_ulogic_vector(31 downto 0); -- custom CFS configuration generic
|
1814 |
62 |
zero_gravi |
CFS_IN_SIZE : positive; -- size of CFS input conduit in bits
|
1815 |
|
|
CFS_OUT_SIZE : positive -- size of CFS output conduit in bits
|
1816 |
23 |
zero_gravi |
);
|
1817 |
34 |
zero_gravi |
port (
|
1818 |
|
|
-- host access --
|
1819 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1820 |
|
|
rstn_i : in std_ulogic; -- global reset line, low-active, use as async
|
1821 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1822 |
|
|
rden_i : in std_ulogic; -- read enable
|
1823 |
47 |
zero_gravi |
wren_i : in std_ulogic; -- word write enable
|
1824 |
34 |
zero_gravi |
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1825 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1826 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1827 |
|
|
-- clock generator --
|
1828 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1829 |
47 |
zero_gravi |
clkgen_i : in std_ulogic_vector(07 downto 0); -- "clock" inputs
|
1830 |
|
|
-- interrupt --
|
1831 |
|
|
irq_o : out std_ulogic; -- interrupt request
|
1832 |
|
|
-- custom io (conduit) --
|
1833 |
62 |
zero_gravi |
cfs_in_i : in std_ulogic_vector(CFS_IN_SIZE-1 downto 0); -- custom inputs
|
1834 |
|
|
cfs_out_o : out std_ulogic_vector(CFS_OUT_SIZE-1 downto 0) -- custom outputs
|
1835 |
34 |
zero_gravi |
);
|
1836 |
|
|
end component;
|
1837 |
|
|
|
1838 |
61 |
zero_gravi |
-- Component: Smart LED (WS2811/WS2812) Interface (NEOLED) --------------------------------
|
1839 |
49 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
1840 |
61 |
zero_gravi |
component neorv32_neoled
|
1841 |
62 |
zero_gravi |
generic (
|
1842 |
|
|
FIFO_DEPTH : natural -- TX FIFO depth (1..32k, power of two)
|
1843 |
|
|
);
|
1844 |
49 |
zero_gravi |
port (
|
1845 |
|
|
-- host access --
|
1846 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1847 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1848 |
|
|
rden_i : in std_ulogic; -- read enable
|
1849 |
|
|
wren_i : in std_ulogic; -- write enable
|
1850 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1851 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1852 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1853 |
|
|
-- clock generator --
|
1854 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1855 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1856 |
61 |
zero_gravi |
-- interrupt --
|
1857 |
|
|
irq_o : out std_ulogic; -- interrupt request
|
1858 |
|
|
-- NEOLED output --
|
1859 |
|
|
neoled_o : out std_ulogic -- serial async data line
|
1860 |
49 |
zero_gravi |
);
|
1861 |
|
|
end component;
|
1862 |
|
|
|
1863 |
61 |
zero_gravi |
-- Component: Stream Link Interface (SLINK) -----------------------------------------------
|
1864 |
52 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
1865 |
61 |
zero_gravi |
component neorv32_slink
|
1866 |
|
|
generic (
|
1867 |
62 |
zero_gravi |
SLINK_NUM_TX : natural; -- number of TX links (0..8)
|
1868 |
|
|
SLINK_NUM_RX : natural; -- number of TX links (0..8)
|
1869 |
|
|
SLINK_TX_FIFO : natural; -- TX fifo depth, has to be a power of two
|
1870 |
|
|
SLINK_RX_FIFO : natural -- RX fifo depth, has to be a power of two
|
1871 |
61 |
zero_gravi |
);
|
1872 |
52 |
zero_gravi |
port (
|
1873 |
|
|
-- host access --
|
1874 |
61 |
zero_gravi |
clk_i : in std_ulogic; -- global clock line
|
1875 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1876 |
|
|
rden_i : in std_ulogic; -- read enable
|
1877 |
|
|
wren_i : in std_ulogic; -- write enable
|
1878 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1879 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1880 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1881 |
52 |
zero_gravi |
-- interrupt --
|
1882 |
61 |
zero_gravi |
irq_tx_o : out std_ulogic; -- transmission done
|
1883 |
|
|
irq_rx_o : out std_ulogic; -- data received
|
1884 |
|
|
-- TX stream interfaces --
|
1885 |
|
|
slink_tx_dat_o : out sdata_8x32_t; -- output data
|
1886 |
|
|
slink_tx_val_o : out std_ulogic_vector(7 downto 0); -- valid output
|
1887 |
|
|
slink_tx_rdy_i : in std_ulogic_vector(7 downto 0); -- ready to send
|
1888 |
|
|
-- RX stream interfaces --
|
1889 |
|
|
slink_rx_dat_i : in sdata_8x32_t; -- input data
|
1890 |
|
|
slink_rx_val_i : in std_ulogic_vector(7 downto 0); -- valid input
|
1891 |
|
|
slink_rx_rdy_o : out std_ulogic_vector(7 downto 0) -- ready to receive
|
1892 |
52 |
zero_gravi |
);
|
1893 |
|
|
end component;
|
1894 |
|
|
|
1895 |
61 |
zero_gravi |
-- Component: External Interrupt Controller (XIRQ) ----------------------------------------
|
1896 |
|
|
-- -------------------------------------------------------------------------------------------
|
1897 |
|
|
component neorv32_xirq
|
1898 |
|
|
generic (
|
1899 |
62 |
zero_gravi |
XIRQ_NUM_CH : natural; -- number of external IRQ channels (0..32)
|
1900 |
|
|
XIRQ_TRIGGER_TYPE : std_ulogic_vector(31 downto 0); -- trigger type: 0=level, 1=edge
|
1901 |
|
|
XIRQ_TRIGGER_POLARITY : std_ulogic_vector(31 downto 0) -- trigger polarity: 0=low-level/falling-edge, 1=high-level/rising-edge
|
1902 |
61 |
zero_gravi |
);
|
1903 |
|
|
port (
|
1904 |
|
|
-- host access --
|
1905 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1906 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1907 |
|
|
rden_i : in std_ulogic; -- read enable
|
1908 |
|
|
wren_i : in std_ulogic; -- write enable
|
1909 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1910 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1911 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1912 |
|
|
-- external interrupt lines --
|
1913 |
|
|
xirq_i : in std_ulogic_vector(XIRQ_NUM_CH-1 downto 0);
|
1914 |
|
|
-- CPU interrupt --
|
1915 |
|
|
cpu_irq_o : out std_ulogic
|
1916 |
|
|
);
|
1917 |
|
|
end component;
|
1918 |
|
|
|
1919 |
67 |
zero_gravi |
-- Component: General Purpose Timer (GPTMR) -----------------------------------------------
|
1920 |
|
|
-- -------------------------------------------------------------------------------------------
|
1921 |
|
|
component neorv32_gptmr
|
1922 |
|
|
port (
|
1923 |
|
|
-- host access --
|
1924 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1925 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1926 |
|
|
rden_i : in std_ulogic; -- read enable
|
1927 |
|
|
wren_i : in std_ulogic; -- write enable
|
1928 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
1929 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1930 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
1931 |
|
|
-- clock generator --
|
1932 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
1933 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
1934 |
|
|
-- interrupt --
|
1935 |
|
|
irq_o : out std_ulogic -- transmission done interrupt
|
1936 |
|
|
);
|
1937 |
|
|
end component;
|
1938 |
|
|
|
1939 |
23 |
zero_gravi |
-- Component: System Configuration Information Memory (SYSINFO) ---------------------------
|
1940 |
|
|
-- -------------------------------------------------------------------------------------------
|
1941 |
12 |
zero_gravi |
component neorv32_sysinfo
|
1942 |
|
|
generic (
|
1943 |
|
|
-- General --
|
1944 |
63 |
zero_gravi |
CLOCK_FREQUENCY : natural; -- clock frequency of clk_i in Hz
|
1945 |
|
|
INT_BOOTLOADER_EN : boolean; -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM
|
1946 |
|
|
-- RISC-V CPU Extensions --
|
1947 |
|
|
CPU_EXTENSION_RISCV_Zfinx : boolean; -- implement 32-bit floating-point extension (using INT reg!)
|
1948 |
|
|
CPU_EXTENSION_RISCV_Zicsr : boolean; -- implement CSR system?
|
1949 |
66 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicntr : boolean; -- implement base counters?
|
1950 |
|
|
CPU_EXTENSION_RISCV_Zihpm : boolean; -- implement hardware performance monitors?
|
1951 |
63 |
zero_gravi |
CPU_EXTENSION_RISCV_Zifencei : boolean; -- implement instruction stream sync.?
|
1952 |
|
|
CPU_EXTENSION_RISCV_Zmmul : boolean; -- implement multiply-only M sub-extension?
|
1953 |
|
|
CPU_EXTENSION_RISCV_DEBUG : boolean; -- implement CPU debug mode?
|
1954 |
|
|
-- Extension Options --
|
1955 |
|
|
FAST_MUL_EN : boolean; -- use DSPs for M extension's multiplier
|
1956 |
|
|
FAST_SHIFT_EN : boolean; -- use barrel shifter for shift operations
|
1957 |
|
|
CPU_CNT_WIDTH : natural; -- total width of CPU cycle and instret counters (0..64)
|
1958 |
|
|
-- Physical memory protection (PMP) --
|
1959 |
|
|
PMP_NUM_REGIONS : natural; -- number of regions (0..64)
|
1960 |
23 |
zero_gravi |
-- Internal Instruction memory --
|
1961 |
63 |
zero_gravi |
MEM_INT_IMEM_EN : boolean; -- implement processor-internal instruction memory
|
1962 |
|
|
MEM_INT_IMEM_SIZE : natural; -- size of processor-internal instruction memory in bytes
|
1963 |
23 |
zero_gravi |
-- Internal Data memory --
|
1964 |
63 |
zero_gravi |
MEM_INT_DMEM_EN : boolean; -- implement processor-internal data memory
|
1965 |
|
|
MEM_INT_DMEM_SIZE : natural; -- size of processor-internal data memory in bytes
|
1966 |
41 |
zero_gravi |
-- Internal Cache memory --
|
1967 |
63 |
zero_gravi |
ICACHE_EN : boolean; -- implement instruction cache
|
1968 |
|
|
ICACHE_NUM_BLOCKS : natural; -- i-cache: number of blocks (min 2), has to be a power of 2
|
1969 |
|
|
ICACHE_BLOCK_SIZE : natural; -- i-cache: block size in bytes (min 4), has to be a power of 2
|
1970 |
|
|
ICACHE_ASSOCIATIVITY : natural; -- i-cache: associativity (min 1), has to be a power 2
|
1971 |
23 |
zero_gravi |
-- External memory interface --
|
1972 |
63 |
zero_gravi |
MEM_EXT_EN : boolean; -- implement external memory bus interface?
|
1973 |
|
|
MEM_EXT_BIG_ENDIAN : boolean; -- byte order: true=big-endian, false=little-endian
|
1974 |
59 |
zero_gravi |
-- On-Chip Debugger --
|
1975 |
63 |
zero_gravi |
ON_CHIP_DEBUGGER_EN : boolean; -- implement OCD?
|
1976 |
12 |
zero_gravi |
-- Processor peripherals --
|
1977 |
63 |
zero_gravi |
IO_GPIO_EN : boolean; -- implement general purpose input/output port unit (GPIO)?
|
1978 |
|
|
IO_MTIME_EN : boolean; -- implement machine system timer (MTIME)?
|
1979 |
|
|
IO_UART0_EN : boolean; -- implement primary universal asynchronous receiver/transmitter (UART0)?
|
1980 |
|
|
IO_UART1_EN : boolean; -- implement secondary universal asynchronous receiver/transmitter (UART1)?
|
1981 |
|
|
IO_SPI_EN : boolean; -- implement serial peripheral interface (SPI)?
|
1982 |
|
|
IO_TWI_EN : boolean; -- implement two-wire interface (TWI)?
|
1983 |
|
|
IO_PWM_NUM_CH : natural; -- number of PWM channels to implement
|
1984 |
|
|
IO_WDT_EN : boolean; -- implement watch dog timer (WDT)?
|
1985 |
|
|
IO_TRNG_EN : boolean; -- implement true random number generator (TRNG)?
|
1986 |
|
|
IO_CFS_EN : boolean; -- implement custom functions subsystem (CFS)?
|
1987 |
|
|
IO_SLINK_EN : boolean; -- implement stream link interface?
|
1988 |
|
|
IO_NEOLED_EN : boolean; -- implement NeoPixel-compatible smart LED interface (NEOLED)?
|
1989 |
67 |
zero_gravi |
IO_XIRQ_NUM_CH : natural; -- number of external interrupt (XIRQ) channels to implement
|
1990 |
|
|
IO_GPTMR_EN : boolean -- implement general purpose timer (GPTMR)?
|
1991 |
12 |
zero_gravi |
);
|
1992 |
|
|
port (
|
1993 |
|
|
-- host access --
|
1994 |
|
|
clk_i : in std_ulogic; -- global clock line
|
1995 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
1996 |
|
|
rden_i : in std_ulogic; -- read enable
|
1997 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
1998 |
|
|
ack_o : out std_ulogic -- transfer acknowledge
|
1999 |
|
|
);
|
2000 |
|
|
end component;
|
2001 |
|
|
|
2002 |
62 |
zero_gravi |
-- Component: General Purpose FIFO --------------------------------------------------------
|
2003 |
61 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2004 |
|
|
component neorv32_fifo
|
2005 |
|
|
generic (
|
2006 |
62 |
zero_gravi |
FIFO_DEPTH : natural; -- number of fifo entries; has to be a power of two; min 1
|
2007 |
|
|
FIFO_WIDTH : natural; -- size of data elements in fifo
|
2008 |
|
|
FIFO_RSYNC : boolean; -- false = async read; true = sync read
|
2009 |
|
|
FIFO_SAFE : boolean -- true = allow read/write only if entry available
|
2010 |
61 |
zero_gravi |
);
|
2011 |
|
|
port (
|
2012 |
|
|
-- control --
|
2013 |
|
|
clk_i : in std_ulogic; -- clock, rising edge
|
2014 |
|
|
rstn_i : in std_ulogic; -- async reset, low-active
|
2015 |
|
|
clear_i : in std_ulogic; -- sync reset, high-active
|
2016 |
62 |
zero_gravi |
level_o : out std_ulogic_vector(index_size_f(FIFO_DEPTH) downto 0); -- fill level
|
2017 |
65 |
zero_gravi |
half_o : out std_ulogic; -- FIFO is at least half full
|
2018 |
61 |
zero_gravi |
-- write port --
|
2019 |
|
|
wdata_i : in std_ulogic_vector(FIFO_WIDTH-1 downto 0); -- write data
|
2020 |
|
|
we_i : in std_ulogic; -- write enable
|
2021 |
|
|
free_o : out std_ulogic; -- at least one entry is free when set
|
2022 |
|
|
-- read port --
|
2023 |
|
|
re_i : in std_ulogic; -- read enable
|
2024 |
|
|
rdata_o : out std_ulogic_vector(FIFO_WIDTH-1 downto 0); -- read data
|
2025 |
|
|
avail_o : out std_ulogic -- data available when set
|
2026 |
|
|
);
|
2027 |
|
|
end component;
|
2028 |
|
|
|
2029 |
59 |
zero_gravi |
-- Component: On-Chip Debugger - Debug Module (DM) ----------------------------------------
|
2030 |
|
|
-- -------------------------------------------------------------------------------------------
|
2031 |
|
|
component neorv32_debug_dm
|
2032 |
|
|
port (
|
2033 |
|
|
-- global control --
|
2034 |
|
|
clk_i : in std_ulogic; -- global clock line
|
2035 |
|
|
rstn_i : in std_ulogic; -- global reset line, low-active
|
2036 |
|
|
-- debug module interface (DMI) --
|
2037 |
|
|
dmi_rstn_i : in std_ulogic;
|
2038 |
|
|
dmi_req_valid_i : in std_ulogic;
|
2039 |
|
|
dmi_req_ready_o : out std_ulogic; -- DMI is allowed to make new requests when set
|
2040 |
|
|
dmi_req_addr_i : in std_ulogic_vector(06 downto 0);
|
2041 |
|
|
dmi_req_op_i : in std_ulogic; -- 0=read, 1=write
|
2042 |
|
|
dmi_req_data_i : in std_ulogic_vector(31 downto 0);
|
2043 |
|
|
dmi_resp_valid_o : out std_ulogic; -- response valid when set
|
2044 |
|
|
dmi_resp_ready_i : in std_ulogic; -- ready to receive respond
|
2045 |
|
|
dmi_resp_data_o : out std_ulogic_vector(31 downto 0);
|
2046 |
|
|
dmi_resp_err_o : out std_ulogic; -- 0=ok, 1=error
|
2047 |
|
|
-- CPU bus access --
|
2048 |
|
|
cpu_addr_i : in std_ulogic_vector(31 downto 0); -- address
|
2049 |
|
|
cpu_rden_i : in std_ulogic; -- read enable
|
2050 |
|
|
cpu_wren_i : in std_ulogic; -- write enable
|
2051 |
|
|
cpu_data_i : in std_ulogic_vector(31 downto 0); -- data in
|
2052 |
|
|
cpu_data_o : out std_ulogic_vector(31 downto 0); -- data out
|
2053 |
|
|
cpu_ack_o : out std_ulogic; -- transfer acknowledge
|
2054 |
|
|
-- CPU control --
|
2055 |
|
|
cpu_ndmrstn_o : out std_ulogic; -- soc reset
|
2056 |
|
|
cpu_halt_req_o : out std_ulogic -- request hart to halt (enter debug mode)
|
2057 |
|
|
);
|
2058 |
|
|
end component;
|
2059 |
|
|
|
2060 |
|
|
-- Component: On-Chip Debugger - Debug Transport Module (DTM) -----------------------------
|
2061 |
|
|
-- -------------------------------------------------------------------------------------------
|
2062 |
|
|
component neorv32_debug_dtm
|
2063 |
|
|
generic (
|
2064 |
62 |
zero_gravi |
IDCODE_VERSION : std_ulogic_vector(03 downto 0); -- version
|
2065 |
|
|
IDCODE_PARTID : std_ulogic_vector(15 downto 0); -- part number
|
2066 |
|
|
IDCODE_MANID : std_ulogic_vector(10 downto 0) -- manufacturer id
|
2067 |
59 |
zero_gravi |
);
|
2068 |
|
|
port (
|
2069 |
|
|
-- global control --
|
2070 |
|
|
clk_i : in std_ulogic; -- global clock line
|
2071 |
|
|
rstn_i : in std_ulogic; -- global reset line, low-active
|
2072 |
|
|
-- jtag connection --
|
2073 |
|
|
jtag_trst_i : in std_ulogic;
|
2074 |
|
|
jtag_tck_i : in std_ulogic;
|
2075 |
|
|
jtag_tdi_i : in std_ulogic;
|
2076 |
|
|
jtag_tdo_o : out std_ulogic;
|
2077 |
|
|
jtag_tms_i : in std_ulogic;
|
2078 |
|
|
-- debug module interface (DMI) --
|
2079 |
|
|
dmi_rstn_o : out std_ulogic;
|
2080 |
|
|
dmi_req_valid_o : out std_ulogic;
|
2081 |
|
|
dmi_req_ready_i : in std_ulogic; -- DMI is allowed to make new requests when set
|
2082 |
|
|
dmi_req_addr_o : out std_ulogic_vector(06 downto 0);
|
2083 |
|
|
dmi_req_op_o : out std_ulogic; -- 0=read, 1=write
|
2084 |
|
|
dmi_req_data_o : out std_ulogic_vector(31 downto 0);
|
2085 |
|
|
dmi_resp_valid_i : in std_ulogic; -- response valid when set
|
2086 |
|
|
dmi_resp_ready_o : out std_ulogic; -- ready to receive respond
|
2087 |
|
|
dmi_resp_data_i : in std_ulogic_vector(31 downto 0);
|
2088 |
|
|
dmi_resp_err_i : in std_ulogic -- 0=ok, 1=error
|
2089 |
|
|
);
|
2090 |
|
|
end component;
|
2091 |
|
|
|
2092 |
2 |
zero_gravi |
end neorv32_package;
|
2093 |
|
|
|
2094 |
|
|
package body neorv32_package is
|
2095 |
|
|
|
2096 |
41 |
zero_gravi |
-- Function: Minimal required number of bits to represent input number --------------------
|
2097 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2098 |
|
|
function index_size_f(input : natural) return natural is
|
2099 |
|
|
begin
|
2100 |
|
|
for i in 0 to natural'high loop
|
2101 |
|
|
if (2**i >= input) then
|
2102 |
|
|
return i;
|
2103 |
|
|
end if;
|
2104 |
|
|
end loop; -- i
|
2105 |
|
|
return 0;
|
2106 |
|
|
end function index_size_f;
|
2107 |
|
|
|
2108 |
|
|
-- Function: Conditional select natural ---------------------------------------------------
|
2109 |
|
|
-- -------------------------------------------------------------------------------------------
|
2110 |
|
|
function cond_sel_natural_f(cond : boolean; val_t : natural; val_f : natural) return natural is
|
2111 |
|
|
begin
|
2112 |
|
|
if (cond = true) then
|
2113 |
|
|
return val_t;
|
2114 |
|
|
else
|
2115 |
|
|
return val_f;
|
2116 |
|
|
end if;
|
2117 |
|
|
end function cond_sel_natural_f;
|
2118 |
|
|
|
2119 |
56 |
zero_gravi |
-- Function: Conditional select integer ---------------------------------------------------
|
2120 |
|
|
-- -------------------------------------------------------------------------------------------
|
2121 |
|
|
function cond_sel_int_f(cond : boolean; val_t : integer; val_f : integer) return integer is
|
2122 |
|
|
begin
|
2123 |
|
|
if (cond = true) then
|
2124 |
|
|
return val_t;
|
2125 |
|
|
else
|
2126 |
|
|
return val_f;
|
2127 |
|
|
end if;
|
2128 |
|
|
end function cond_sel_int_f;
|
2129 |
|
|
|
2130 |
2 |
zero_gravi |
-- Function: Conditional select std_ulogic_vector -----------------------------------------
|
2131 |
|
|
-- -------------------------------------------------------------------------------------------
|
2132 |
|
|
function cond_sel_stdulogicvector_f(cond : boolean; val_t : std_ulogic_vector; val_f : std_ulogic_vector) return std_ulogic_vector is
|
2133 |
|
|
begin
|
2134 |
|
|
if (cond = true) then
|
2135 |
|
|
return val_t;
|
2136 |
|
|
else
|
2137 |
|
|
return val_f;
|
2138 |
|
|
end if;
|
2139 |
|
|
end function cond_sel_stdulogicvector_f;
|
2140 |
|
|
|
2141 |
56 |
zero_gravi |
-- Function: Conditional select std_ulogic ------------------------------------------------
|
2142 |
|
|
-- -------------------------------------------------------------------------------------------
|
2143 |
|
|
function cond_sel_stdulogic_f(cond : boolean; val_t : std_ulogic; val_f : std_ulogic) return std_ulogic is
|
2144 |
|
|
begin
|
2145 |
|
|
if (cond = true) then
|
2146 |
|
|
return val_t;
|
2147 |
|
|
else
|
2148 |
|
|
return val_f;
|
2149 |
|
|
end if;
|
2150 |
|
|
end function cond_sel_stdulogic_f;
|
2151 |
|
|
|
2152 |
50 |
zero_gravi |
-- Function: Conditional select string ----------------------------------------------------
|
2153 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2154 |
50 |
zero_gravi |
function cond_sel_string_f(cond : boolean; val_t : string; val_f : string) return string is
|
2155 |
|
|
begin
|
2156 |
|
|
if (cond = true) then
|
2157 |
|
|
return val_t;
|
2158 |
|
|
else
|
2159 |
|
|
return val_f;
|
2160 |
|
|
end if;
|
2161 |
|
|
end function cond_sel_string_f;
|
2162 |
|
|
|
2163 |
|
|
-- Function: Convert bool to std_ulogic ---------------------------------------------------
|
2164 |
|
|
-- -------------------------------------------------------------------------------------------
|
2165 |
2 |
zero_gravi |
function bool_to_ulogic_f(cond : boolean) return std_ulogic is
|
2166 |
|
|
begin
|
2167 |
|
|
if (cond = true) then
|
2168 |
|
|
return '1';
|
2169 |
|
|
else
|
2170 |
|
|
return '0';
|
2171 |
|
|
end if;
|
2172 |
|
|
end function bool_to_ulogic_f;
|
2173 |
|
|
|
2174 |
60 |
zero_gravi |
-- Function: OR-reduce all bits -----------------------------------------------------------
|
2175 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2176 |
60 |
zero_gravi |
function or_reduce_f(a : std_ulogic_vector) return std_ulogic is
|
2177 |
2 |
zero_gravi |
variable tmp_v : std_ulogic;
|
2178 |
|
|
begin
|
2179 |
56 |
zero_gravi |
tmp_v := '0';
|
2180 |
65 |
zero_gravi |
for i in a'range loop
|
2181 |
|
|
tmp_v := tmp_v or a(i);
|
2182 |
|
|
end loop; -- i
|
2183 |
2 |
zero_gravi |
return tmp_v;
|
2184 |
60 |
zero_gravi |
end function or_reduce_f;
|
2185 |
2 |
zero_gravi |
|
2186 |
60 |
zero_gravi |
-- Function: AND-reduce all bits ----------------------------------------------------------
|
2187 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2188 |
60 |
zero_gravi |
function and_reduce_f(a : std_ulogic_vector) return std_ulogic is
|
2189 |
2 |
zero_gravi |
variable tmp_v : std_ulogic;
|
2190 |
|
|
begin
|
2191 |
56 |
zero_gravi |
tmp_v := '1';
|
2192 |
65 |
zero_gravi |
for i in a'range loop
|
2193 |
|
|
tmp_v := tmp_v and a(i);
|
2194 |
|
|
end loop; -- i
|
2195 |
2 |
zero_gravi |
return tmp_v;
|
2196 |
60 |
zero_gravi |
end function and_reduce_f;
|
2197 |
2 |
zero_gravi |
|
2198 |
60 |
zero_gravi |
-- Function: XOR-reduce all bits ----------------------------------------------------------
|
2199 |
2 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2200 |
60 |
zero_gravi |
function xor_reduce_f(a : std_ulogic_vector) return std_ulogic is
|
2201 |
2 |
zero_gravi |
variable tmp_v : std_ulogic;
|
2202 |
|
|
begin
|
2203 |
56 |
zero_gravi |
tmp_v := '0';
|
2204 |
65 |
zero_gravi |
for i in a'range loop
|
2205 |
|
|
tmp_v := tmp_v xor a(i);
|
2206 |
|
|
end loop; -- i
|
2207 |
2 |
zero_gravi |
return tmp_v;
|
2208 |
60 |
zero_gravi |
end function xor_reduce_f;
|
2209 |
2 |
zero_gravi |
|
2210 |
40 |
zero_gravi |
-- Function: Convert std_ulogic_vector to hex char ----------------------------------------
|
2211 |
6 |
zero_gravi |
-- -------------------------------------------------------------------------------------------
|
2212 |
|
|
function to_hexchar_f(input : std_ulogic_vector(3 downto 0)) return character is
|
2213 |
|
|
variable output_v : character;
|
2214 |
|
|
begin
|
2215 |
|
|
case input is
|
2216 |
7 |
zero_gravi |
when x"0" => output_v := '0';
|
2217 |
|
|
when x"1" => output_v := '1';
|
2218 |
|
|
when x"2" => output_v := '2';
|
2219 |
|
|
when x"3" => output_v := '3';
|
2220 |
|
|
when x"4" => output_v := '4';
|
2221 |
|
|
when x"5" => output_v := '5';
|
2222 |
|
|
when x"6" => output_v := '6';
|
2223 |
|
|
when x"7" => output_v := '7';
|
2224 |
|
|
when x"8" => output_v := '8';
|
2225 |
|
|
when x"9" => output_v := '9';
|
2226 |
|
|
when x"a" => output_v := 'a';
|
2227 |
|
|
when x"b" => output_v := 'b';
|
2228 |
|
|
when x"c" => output_v := 'c';
|
2229 |
|
|
when x"d" => output_v := 'd';
|
2230 |
|
|
when x"e" => output_v := 'e';
|
2231 |
|
|
when x"f" => output_v := 'f';
|
2232 |
6 |
zero_gravi |
when others => output_v := '?';
|
2233 |
|
|
end case;
|
2234 |
|
|
return output_v;
|
2235 |
|
|
end function to_hexchar_f;
|
2236 |
|
|
|
2237 |
40 |
zero_gravi |
-- Function: Convert hex char to std_ulogic_vector ----------------------------------------
|
2238 |
|
|
-- -------------------------------------------------------------------------------------------
|
2239 |
|
|
function hexchar_to_stdulogicvector_f(input : character) return std_ulogic_vector is
|
2240 |
|
|
variable hex_value_v : std_ulogic_vector(3 downto 0);
|
2241 |
|
|
begin
|
2242 |
|
|
case input is
|
2243 |
|
|
when '0' => hex_value_v := x"0";
|
2244 |
|
|
when '1' => hex_value_v := x"1";
|
2245 |
|
|
when '2' => hex_value_v := x"2";
|
2246 |
|
|
when '3' => hex_value_v := x"3";
|
2247 |
|
|
when '4' => hex_value_v := x"4";
|
2248 |
|
|
when '5' => hex_value_v := x"5";
|
2249 |
|
|
when '6' => hex_value_v := x"6";
|
2250 |
|
|
when '7' => hex_value_v := x"7";
|
2251 |
|
|
when '8' => hex_value_v := x"8";
|
2252 |
|
|
when '9' => hex_value_v := x"9";
|
2253 |
|
|
when 'a' | 'A' => hex_value_v := x"a";
|
2254 |
|
|
when 'b' | 'B' => hex_value_v := x"b";
|
2255 |
|
|
when 'c' | 'C' => hex_value_v := x"c";
|
2256 |
|
|
when 'd' | 'D' => hex_value_v := x"d";
|
2257 |
|
|
when 'e' | 'E' => hex_value_v := x"e";
|
2258 |
|
|
when 'f' | 'F' => hex_value_v := x"f";
|
2259 |
|
|
when others => hex_value_v := (others => 'X');
|
2260 |
|
|
end case;
|
2261 |
|
|
return hex_value_v;
|
2262 |
|
|
end function hexchar_to_stdulogicvector_f;
|
2263 |
|
|
|
2264 |
32 |
zero_gravi |
-- Function: Bit reversal -----------------------------------------------------------------
|
2265 |
|
|
-- -------------------------------------------------------------------------------------------
|
2266 |
|
|
function bit_rev_f(input : std_ulogic_vector) return std_ulogic_vector is
|
2267 |
|
|
variable output_v : std_ulogic_vector(input'range);
|
2268 |
|
|
begin
|
2269 |
|
|
for i in 0 to input'length-1 loop
|
2270 |
|
|
output_v(input'length-i-1) := input(i);
|
2271 |
|
|
end loop; -- i
|
2272 |
|
|
return output_v;
|
2273 |
|
|
end function bit_rev_f;
|
2274 |
|
|
|
2275 |
36 |
zero_gravi |
-- Function: Test if input number is a power of two ---------------------------------------
|
2276 |
|
|
-- -------------------------------------------------------------------------------------------
|
2277 |
|
|
function is_power_of_two_f(input : natural) return boolean is
|
2278 |
|
|
begin
|
2279 |
38 |
zero_gravi |
if (input = 1) then -- 2^0
|
2280 |
36 |
zero_gravi |
return true;
|
2281 |
38 |
zero_gravi |
elsif ((input / 2) /= 0) and ((input mod 2) = 0) then
|
2282 |
|
|
return true;
|
2283 |
36 |
zero_gravi |
else
|
2284 |
|
|
return false;
|
2285 |
|
|
end if;
|
2286 |
|
|
end function is_power_of_two_f;
|
2287 |
|
|
|
2288 |
40 |
zero_gravi |
-- Function: Swap all bytes of a 32-bit word (endianness conversion) ----------------------
|
2289 |
|
|
-- -------------------------------------------------------------------------------------------
|
2290 |
|
|
function bswap32_f(input : std_ulogic_vector) return std_ulogic_vector is
|
2291 |
|
|
variable output_v : std_ulogic_vector(input'range);
|
2292 |
|
|
begin
|
2293 |
|
|
output_v(07 downto 00) := input(31 downto 24);
|
2294 |
|
|
output_v(15 downto 08) := input(23 downto 16);
|
2295 |
|
|
output_v(23 downto 16) := input(15 downto 08);
|
2296 |
|
|
output_v(31 downto 24) := input(07 downto 00);
|
2297 |
|
|
return output_v;
|
2298 |
|
|
end function bswap32_f;
|
2299 |
|
|
|
2300 |
61 |
zero_gravi |
-- Function: Convert char to lowercase ----------------------------------------------------
|
2301 |
|
|
-- -------------------------------------------------------------------------------------------
|
2302 |
62 |
zero_gravi |
function char_to_lower_f(ch : character) return character is
|
2303 |
61 |
zero_gravi |
variable res: character;
|
2304 |
|
|
begin
|
2305 |
|
|
case ch is
|
2306 |
|
|
when 'A' => res := 'a';
|
2307 |
|
|
when 'B' => res := 'b';
|
2308 |
|
|
when 'C' => res := 'c';
|
2309 |
|
|
when 'D' => res := 'd';
|
2310 |
|
|
when 'E' => res := 'e';
|
2311 |
|
|
when 'F' => res := 'f';
|
2312 |
|
|
when 'G' => res := 'g';
|
2313 |
|
|
when 'H' => res := 'h';
|
2314 |
|
|
when 'I' => res := 'i';
|
2315 |
|
|
when 'J' => res := 'j';
|
2316 |
|
|
when 'K' => res := 'k';
|
2317 |
|
|
when 'L' => res := 'l';
|
2318 |
|
|
when 'M' => res := 'm';
|
2319 |
|
|
when 'N' => res := 'n';
|
2320 |
|
|
when 'O' => res := 'o';
|
2321 |
|
|
when 'P' => res := 'p';
|
2322 |
|
|
when 'Q' => res := 'q';
|
2323 |
|
|
when 'R' => res := 'r';
|
2324 |
|
|
when 'S' => res := 's';
|
2325 |
|
|
when 'T' => res := 't';
|
2326 |
|
|
when 'U' => res := 'u';
|
2327 |
|
|
when 'V' => res := 'v';
|
2328 |
|
|
when 'W' => res := 'w';
|
2329 |
|
|
when 'X' => res := 'x';
|
2330 |
|
|
when 'Y' => res := 'y';
|
2331 |
|
|
when 'Z' => res := 'z';
|
2332 |
|
|
when others => res := ch;
|
2333 |
|
|
end case;
|
2334 |
|
|
return res;
|
2335 |
62 |
zero_gravi |
end function char_to_lower_f;
|
2336 |
61 |
zero_gravi |
|
2337 |
|
|
-- Function: Compare strings (convert to lower case, check lengths) -----------------------
|
2338 |
|
|
-- -------------------------------------------------------------------------------------------
|
2339 |
|
|
function str_equal_f(str0 : string; str1 : string) return boolean is
|
2340 |
|
|
variable tmp0_v : string(str0'range);
|
2341 |
|
|
variable tmp1_v : string(str1'range);
|
2342 |
|
|
begin
|
2343 |
|
|
if (str0'length /= str1'length) then -- equal length?
|
2344 |
|
|
return false;
|
2345 |
|
|
else
|
2346 |
|
|
-- convert to lower case --
|
2347 |
|
|
for i in str0'range loop
|
2348 |
62 |
zero_gravi |
tmp0_v(i) := char_to_lower_f(str0(i));
|
2349 |
61 |
zero_gravi |
end loop;
|
2350 |
|
|
for i in str1'range loop
|
2351 |
62 |
zero_gravi |
tmp1_v(i) := char_to_lower_f(str1(i));
|
2352 |
61 |
zero_gravi |
end loop;
|
2353 |
|
|
-- compare lowercase strings --
|
2354 |
|
|
if (tmp0_v = tmp1_v) then
|
2355 |
|
|
return true;
|
2356 |
|
|
else
|
2357 |
|
|
return false;
|
2358 |
|
|
end if;
|
2359 |
|
|
end if;
|
2360 |
|
|
end function str_equal_f;
|
2361 |
|
|
|
2362 |
63 |
zero_gravi |
-- Function: Population count (number of set bits) ----------------------------------------
|
2363 |
|
|
-- -------------------------------------------------------------------------------------------
|
2364 |
|
|
function popcount_f(input : std_ulogic_vector) return natural is
|
2365 |
|
|
variable cnt_v : natural range 0 to input'length;
|
2366 |
|
|
begin
|
2367 |
|
|
cnt_v := 0;
|
2368 |
|
|
for i in input'length-1 downto 0 loop
|
2369 |
|
|
if (input(i) = '1') then
|
2370 |
|
|
cnt_v := cnt_v + 1;
|
2371 |
|
|
end if;
|
2372 |
|
|
end loop; -- i
|
2373 |
|
|
return cnt_v;
|
2374 |
|
|
end function popcount_f;
|
2375 |
|
|
|
2376 |
|
|
-- Function: Count leading zeros ----------------------------------------------------------
|
2377 |
|
|
-- -------------------------------------------------------------------------------------------
|
2378 |
|
|
function leading_zeros_f(input : std_ulogic_vector) return natural is
|
2379 |
|
|
variable cnt_v : natural range 0 to input'length;
|
2380 |
|
|
begin
|
2381 |
|
|
cnt_v := 0;
|
2382 |
|
|
for i in input'length-1 downto 0 loop
|
2383 |
|
|
if (input(i) = '0') then
|
2384 |
|
|
cnt_v := cnt_v + 1;
|
2385 |
|
|
else
|
2386 |
|
|
exit;
|
2387 |
|
|
end if;
|
2388 |
|
|
end loop; -- i
|
2389 |
|
|
return cnt_v;
|
2390 |
|
|
end function leading_zeros_f;
|
2391 |
|
|
|
2392 |
61 |
zero_gravi |
-- Function: Initialize mem32_t array from another mem32_t array --------------------------
|
2393 |
|
|
-- -------------------------------------------------------------------------------------------
|
2394 |
|
|
-- impure function: returns NOT the same result every time it is evaluated with the same arguments since the source file might have changed
|
2395 |
|
|
impure function mem32_init_f(init : mem32_t; depth : natural) return mem32_t is
|
2396 |
|
|
variable mem_v : mem32_t(0 to depth-1);
|
2397 |
|
|
begin
|
2398 |
62 |
zero_gravi |
mem_v := (others => (others => '0')); -- make sure remaining memory entries are set to zero
|
2399 |
|
|
if (init'length > depth) then
|
2400 |
|
|
return mem_v;
|
2401 |
|
|
end if;
|
2402 |
|
|
for idx_v in 0 to init'length-1 loop -- init only in range of source data array
|
2403 |
|
|
mem_v(idx_v) := init(idx_v);
|
2404 |
|
|
end loop; -- idx_v
|
2405 |
61 |
zero_gravi |
return mem_v;
|
2406 |
|
|
end function mem32_init_f;
|
2407 |
|
|
|
2408 |
62 |
zero_gravi |
|
2409 |
2 |
zero_gravi |
end neorv32_package;
|