OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [processor_templates/] [neorv32_ProcessorTop_UP5KDemo.vhd] - Blame information for rev 70

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 zero_gravi
-- #################################################################################################
2
-- # << NEORV32 - Example setup for boards with UP5K devices >>                                    #
3
-- # ********************************************************************************************* #
4
-- # BSD 3-Clause License                                                                          #
5
-- #                                                                                               #
6
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     #
7
-- #                                                                                               #
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
library neorv32;
40
 
41
entity neorv32_ProcessorTop_UP5KDemo is
42
  generic (
43
    CLOCK_FREQUENCY              : natural := 0;      -- clock frequency of clk_i in Hz
44
    HW_THREAD_ID                 : natural := 0;      -- hardware thread id (32-bit)
45
 
46
    -- On-Chip Debugger (OCD) --
47
    ON_CHIP_DEBUGGER_EN          : boolean := false;  -- implement on-chip debugger?
48
 
49
    -- RISC-V CPU Extensions --
50
    CPU_EXTENSION_RISCV_A        : boolean := true;   -- implement atomic extension?
51
    CPU_EXTENSION_RISCV_C        : boolean := true;   -- implement compressed extension?
52
    CPU_EXTENSION_RISCV_E        : boolean := false;  -- implement embedded RF extension?
53
    CPU_EXTENSION_RISCV_M        : boolean := true;   -- implement mul/div extension?
54
    CPU_EXTENSION_RISCV_U        : boolean := false;  -- implement user mode extension?
55
    CPU_EXTENSION_RISCV_Zfinx    : boolean := false;  -- implement 32-bit floating-point extension (using INT regs!)
56
    CPU_EXTENSION_RISCV_Zicsr    : boolean := true;   -- implement CSR system?
57
    CPU_EXTENSION_RISCV_Zifencei : boolean := false;  -- implement instruction stream sync.?
58
 
59
    -- Extension Options --
60
    FAST_MUL_EN                  : boolean := false;  -- use DSPs for M extension's multiplier
61
    FAST_SHIFT_EN                : boolean := false;  -- use barrel shifter for shift operations
62
    CPU_CNT_WIDTH                : natural := 34;     -- total width of CPU cycle and instret counters (0..64)
63
 
64
    -- Physical Memory Protection (PMP) --
65
    PMP_NUM_REGIONS              : natural := 0;       -- number of regions (0..64)
66
    PMP_MIN_GRANULARITY          : natural := 64*1024; -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
67
 
68
    -- Hardware Performance Monitors (HPM) --
69
    HPM_NUM_CNTS                 : natural := 0;       -- number of implemented HPM counters (0..29)
70
    HPM_CNT_WIDTH                : natural := 40;      -- total size of HPM counters (0..64)
71
 
72
    -- Internal Instruction memory --
73
    MEM_INT_IMEM_EN              : boolean := true;    -- implement processor-internal instruction memory
74
    MEM_INT_IMEM_SIZE            : natural := 64*1024; -- size of processor-internal instruction memory in bytes
75
 
76
    -- Internal Data memory --
77
    MEM_INT_DMEM_EN              : boolean := true;    -- implement processor-internal data memory
78
    MEM_INT_DMEM_SIZE            : natural := 64*1024; -- size of processor-internal data memory in bytes
79
 
80
    -- Internal Cache memory --
81
    ICACHE_EN                    : boolean := false;  -- implement instruction cache
82
    ICACHE_NUM_BLOCKS            : natural := 4;      -- i-cache: number of blocks (min 1), has to be a power of 2
83
    ICACHE_BLOCK_SIZE            : natural := 64;     -- i-cache: block size in bytes (min 4), has to be a power of 2
84
    ICACHE_ASSOCIATIVITY         : natural := 1;      -- i-cache: associativity / number of sets (1=direct_mapped), has to be a power of 2
85
 
86
    -- Processor peripherals --
87
    IO_GPIO_EN                   : boolean := true;   -- implement general purpose input/output port unit (GPIO)?
88
    IO_MTIME_EN                  : boolean := true;   -- implement machine system timer (MTIME)?
89
    IO_UART0_EN                  : boolean := true;   -- implement primary universal asynchronous receiver/transmitter (UART0)?
90
    IO_SPI_EN                    : boolean := true;   -- implement serial peripheral interface (SPI)?
91
    IO_TWI_EN                    : boolean := true;   -- implement two-wire interface (TWI)?
92
    IO_PWM_NUM_CH                : natural := 3;      -- number of PWM channels to implement (0..60); 0 = disabled
93
    IO_WDT_EN                    : boolean := true    -- implement watch dog timer (WDT)?
94
  );
95
  port (
96
    clk_i       : in  std_logic;
97
    rstn_i      : in  std_logic;
98
 
99
    -- GPIO (available if IO_GPIO_EN = true) --
100
    gpio_i      : in  std_ulogic_vector(3 downto 0);
101
    gpio_o      : out std_ulogic_vector(3 downto 0);
102
 
103
    -- primary UART0 (available if IO_UART0_EN = true) --
104
    uart_txd_o  : out std_ulogic; -- UART0 send data
105
    uart_rxd_i  : in  std_ulogic := '0'; -- UART0 receive data
106
    uart_rts_o  : out std_ulogic; -- hw flow control: UART0.RX ready to receive ("RTR"), low-active, optional
107
    uart_cts_i  : in  std_ulogic := '0'; -- hw flow control: UART0.TX allowed to transmit, low-active, optional
108
 
109
    -- SPI to on-board flash --
110
    flash_sck_o : out std_ulogic;
111
    flash_sdo_o : out std_ulogic;
112
    flash_sdi_i : in  std_ulogic;
113
    flash_csn_o : out std_ulogic; -- NEORV32.SPI_CS(0)
114
 
115
    -- SPI (available if IO_SPI_EN = true) --
116
    spi_sck_o   : out std_ulogic;
117
    spi_sdo_o   : out std_ulogic;
118
    spi_sdi_i   : in  std_ulogic;
119
    spi_csn_o   : out std_ulogic; -- NEORV32.SPI_CS(1)
120
 
121
    -- TWI (available if IO_TWI_EN = true) --
122
    twi_sda_io  : inout std_logic;
123
    twi_scl_io  : inout std_logic;
124
 
125
    -- PWM (available if IO_PWM_NUM_CH > 0) --
126
    pwm_o       : out std_ulogic_vector(IO_PWM_NUM_CH-1 downto 0)
127
  );
128
end entity;
129
 
130
architecture neorv32_ProcessorTop_UP5KDemo_rtl of neorv32_ProcessorTop_UP5KDemo is
131
 
132
  -- internal IO connection --
133
  signal con_gpio_o   : std_ulogic_vector(63 downto 0);
134
  signal con_gpio_i   : std_ulogic_vector(63 downto 0);
135 70 zero_gravi
  signal con_pwm_o    : std_ulogic_vector(59 downto 0);
136 63 zero_gravi
  signal con_spi_sck  : std_ulogic;
137
  signal con_spi_sdi  : std_ulogic;
138
  signal con_spi_sdo  : std_ulogic;
139
  signal con_spi_csn  : std_ulogic_vector(07 downto 0);
140
 
141
begin
142
 
143
  -- IO Connection --------------------------------------------------------------------------
144
  -- -------------------------------------------------------------------------------------------
145
 
146
  -- SPI: on-board flash --
147
  flash_sck_o <= con_spi_sck;
148
  flash_sdo_o <= con_spi_sdo;
149
  flash_csn_o <= con_spi_csn(0);
150
 
151
  -- SPI: user port --
152
  spi_sck_o   <= con_spi_sck;
153
  spi_sdo_o   <= con_spi_sdo;
154
  spi_csn_o   <= con_spi_csn(1);
155
 
156
  con_spi_sdi <= flash_sdi_i when (con_spi_csn(0) = '0') else spi_sdi_i;
157
 
158
  -- GPIO --
159
  gpio_o <= con_gpio_o(3 downto 0);
160
  con_gpio_i(03 downto 0) <= gpio_i;
161
  con_gpio_i(63 downto 4) <= (others => '0');
162
 
163 70 zero_gravi
  -- PWM --
164
  pwm_o <= con_pwm_o(IO_PWM_NUM_CH-1 downto 0);
165
 
166
 
167 63 zero_gravi
  -- The core of the problem ----------------------------------------------------------------
168
  -- -------------------------------------------------------------------------------------------
169
  neorv32_inst: entity neorv32.neorv32_top
170
  generic map (
171
    -- General --
172
    CLOCK_FREQUENCY              => CLOCK_FREQUENCY,  -- clock frequency of clk_i in Hz
173
    INT_BOOTLOADER_EN            => true,             -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM
174
    HW_THREAD_ID                 => HW_THREAD_ID,     -- hardware thread id (32-bit)
175
 
176
    -- On-Chip Debugger (OCD) --
177
    ON_CHIP_DEBUGGER_EN          => ON_CHIP_DEBUGGER_EN,  -- implement on-chip debugger?
178
 
179
    -- RISC-V CPU Extensions --
180
    CPU_EXTENSION_RISCV_A        => CPU_EXTENSION_RISCV_A,         -- implement atomic extension?
181
    CPU_EXTENSION_RISCV_C        => CPU_EXTENSION_RISCV_C,         -- implement compressed extension?
182
    CPU_EXTENSION_RISCV_E        => CPU_EXTENSION_RISCV_E,         -- implement embedded RF extension?
183
    CPU_EXTENSION_RISCV_M        => CPU_EXTENSION_RISCV_M,         -- implement mul/div extension?
184
    CPU_EXTENSION_RISCV_U        => CPU_EXTENSION_RISCV_U,         -- implement user mode extension?
185
    CPU_EXTENSION_RISCV_Zfinx    => CPU_EXTENSION_RISCV_Zfinx,     -- implement 32-bit floating-point extension (using INT regs!)
186
    CPU_EXTENSION_RISCV_Zicsr    => CPU_EXTENSION_RISCV_Zicsr,     -- implement CSR system?
187 66 zero_gravi
    CPU_EXTENSION_RISCV_Zicntr   => true,                          -- implement base counters?
188 63 zero_gravi
    CPU_EXTENSION_RISCV_Zifencei => CPU_EXTENSION_RISCV_Zifencei,  -- implement instruction stream sync.?
189
 
190
    -- Extension Options --
191
    FAST_MUL_EN                  => FAST_MUL_EN,    -- use DSPs for M extension's multiplier
192
    FAST_SHIFT_EN                => FAST_SHIFT_EN,  -- use barrel shifter for shift operations
193
    CPU_CNT_WIDTH                => CPU_CNT_WIDTH,  -- total width of CPU cycle and instret counters (0..64)
194
 
195
    -- Physical Memory Protection (PMP) --
196
    PMP_NUM_REGIONS              => PMP_NUM_REGIONS,       -- number of regions (0..64)
197
    PMP_MIN_GRANULARITY          => PMP_MIN_GRANULARITY,   -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
198
 
199
    -- Hardware Performance Monitors (HPM) --
200
    HPM_NUM_CNTS                 => HPM_NUM_CNTS,          -- number of implemented HPM counters (0..29)
201
    HPM_CNT_WIDTH                => HPM_CNT_WIDTH,         -- total size of HPM counters (1..64)
202
 
203
    -- Internal Instruction memory --
204
    MEM_INT_IMEM_EN              => MEM_INT_IMEM_EN,       -- implement processor-internal instruction memory
205
    MEM_INT_IMEM_SIZE            => MEM_INT_IMEM_SIZE,     -- size of processor-internal instruction memory in bytes
206
 
207
    -- Internal Data memory --
208
    MEM_INT_DMEM_EN              => MEM_INT_DMEM_EN,       -- implement processor-internal data memory
209
    MEM_INT_DMEM_SIZE            => MEM_INT_DMEM_SIZE,     -- size of processor-internal data memory in bytes
210
 
211
    -- Internal Cache memory --
212
    ICACHE_EN                    => ICACHE_EN,             -- implement instruction cache
213
    ICACHE_NUM_BLOCKS            => ICACHE_NUM_BLOCKS,     -- i-cache: number of blocks (min 1), has to be a power of 2
214
    ICACHE_BLOCK_SIZE            => ICACHE_BLOCK_SIZE,     -- i-cache: block size in bytes (min 4), has to be a power of 2
215
    ICACHE_ASSOCIATIVITY         => ICACHE_ASSOCIATIVITY,  -- i-cache: associativity / number of sets (1=direct_mapped), has to be a power of 2
216
 
217
    -- External memory interface --
218
    MEM_EXT_EN                   => false,  -- implement external memory bus interface?
219
    MEM_EXT_TIMEOUT              => 0,      -- cycles after a pending bus access auto-terminates (0 = disabled)
220
 
221
    -- Processor peripherals --
222
    IO_GPIO_EN                   => IO_GPIO_EN,     -- implement general purpose input/output port unit (GPIO)?
223
    IO_MTIME_EN                  => IO_MTIME_EN,    -- implement machine system timer (MTIME)?
224
    IO_UART0_EN                  => IO_UART0_EN,    -- implement primary universal asynchronous receiver/transmitter (UART0)?
225
    IO_UART1_EN                  => false,          -- implement secondary universal asynchronous receiver/transmitter (UART1)?
226
    IO_SPI_EN                    => IO_SPI_EN,      -- implement serial peripheral interface (SPI)?
227
    IO_TWI_EN                    => IO_TWI_EN,      -- implement two-wire interface (TWI)?
228
    IO_PWM_NUM_CH                => IO_PWM_NUM_CH,  -- number of PWM channels to implement (0..60); 0 = disabled
229
    IO_WDT_EN                    => IO_WDT_EN,      -- implement watch dog timer (WDT)?
230
    IO_TRNG_EN                   => false,          -- implement true random number generator (TRNG)?
231
    IO_CFS_EN                    => false,          -- implement custom functions subsystem (CFS)?
232
    IO_CFS_CONFIG                => x"00000000",    -- custom CFS configuration generic
233
    IO_CFS_IN_SIZE               => 32,             -- size of CFS input conduit in bits
234
    IO_CFS_OUT_SIZE              => 32,             -- size of CFS output conduit in bits
235
    IO_NEOLED_EN                 => false           -- implement NeoPixel-compatible smart LED interface (NEOLED)?
236
  )
237
  port map (
238
    -- Global control --
239
    clk_i       => clk_i,                        -- global clock, rising edge
240
    rstn_i      => rstn_i,                       -- global reset, low-active, async
241
 
242
    -- JTAG on-chip debugger interface (available if ON_CHIP_DEBUGGER_EN = true) --
243
    jtag_trst_i => '0',                          -- low-active TAP reset (optional)
244
    jtag_tck_i  => '0',                          -- serial clock
245
    jtag_tdi_i  => '0',                          -- serial data input
246
    jtag_tdo_o  => open,                         -- serial data output
247
    jtag_tms_i  => '0',                          -- mode select
248
 
249
    -- Wishbone bus interface (available if MEM_EXT_EN = true) --
250
    wb_tag_o    => open,                         -- request tag
251
    wb_adr_o    => open,                         -- address
252
    wb_dat_i    => (others => '0'),              -- read data
253
    wb_dat_o    => open,                         -- write data
254
    wb_we_o     => open,                         -- read/write
255
    wb_sel_o    => open,                         -- byte enable
256
    wb_stb_o    => open,                         -- strobe
257
    wb_cyc_o    => open,                         -- valid cycle
258
    wb_lock_o   => open,                         -- exclusive access request
259
    wb_ack_i    => '0',                          -- transfer acknowledge
260
    wb_err_i    => '0',                          -- transfer error
261
 
262
    -- Advanced memory control signals (available if MEM_EXT_EN = true) --
263
    fence_o     => open,                         -- indicates an executed FENCE operation
264
    fencei_o    => open,                         -- indicates an executed FENCEI operation
265
 
266
    -- GPIO (available if IO_GPIO_EN = true) --
267
    gpio_o      => con_gpio_o,                   -- parallel output
268
    gpio_i      => con_gpio_i,                   -- parallel input
269
 
270
    -- primary UART0 (available if IO_UART0_EN = true) --
271
    uart0_txd_o => uart_txd_o,                   -- UART0 send data
272
    uart0_rxd_i => uart_rxd_i,                   -- UART0 receive data
273
    uart0_rts_o => uart_rts_o,                   -- hw flow control: UART0.RX ready to receive ("RTR"), low-active, optional
274
    uart0_cts_i => uart_cts_i,                   -- hw flow control: UART0.TX allowed to transmit, low-active, optional
275
 
276
    -- secondary UART1 (available if IO_UART1_EN = true) --
277
    uart1_txd_o => open,                         -- UART1 send data
278
    uart1_rxd_i => '0',                          -- UART1 receive data
279
    uart1_rts_o => open,                         -- hw flow control: UART1.RX ready to receive ("RTR"), low-active, optional
280
    uart1_cts_i => '0',                          -- hw flow control: UART1.TX allowed to transmit, low-active, optional
281
 
282
    -- SPI (available if IO_SPI_EN = true) --
283
    spi_sck_o   => con_spi_sck,                  -- SPI serial clock
284
    spi_sdo_o   => con_spi_sdo,                  -- controller data out, peripheral data in
285
    spi_sdi_i   => con_spi_sdi,                  -- controller data in, peripheral data out
286
    spi_csn_o   => con_spi_csn,                  -- SPI CS
287
 
288
    -- TWI (available if IO_TWI_EN = true) --
289
    twi_sda_io  => twi_sda_io,                   -- twi serial data line
290
    twi_scl_io  => twi_scl_io,                   -- twi serial clock line
291
 
292
    -- PWM (available if IO_PWM_NUM_CH > 0) --
293 70 zero_gravi
    pwm_o       => con_pwm_o,                    -- pwm channels
294 63 zero_gravi
 
295
    -- Custom Functions Subsystem IO --
296
    cfs_in_i    => (others => '0'),              -- custom CFS inputs conduit
297
    cfs_out_o   => open,                         -- custom CFS outputs conduit
298
 
299
    -- NeoPixel-compatible smart LED interface (available if IO_NEOLED_EN = true) --
300
    neoled_o    => open,                         -- async serial data line
301
 
302
    -- System time --
303
    mtime_i     => (others => '0'),              -- current system time from ext. MTIME (if IO_MTIME_EN = false)
304
    mtime_o     => open,                         -- current system time from int. MTIME (if IO_MTIME_EN = true)
305
 
306
    -- Interrupts --
307
    mtime_irq_i => '0',                          -- machine timer interrupt, available if IO_MTIME_EN = false
308
    msw_irq_i   => '0',                          -- machine software interrupt
309
    mext_irq_i  => '0'                           -- machine external interrupt
310
  );
311
 
312
end architecture;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.