Line 1... |
Line 1... |
-- #################################################################################################
|
-- #################################################################################################
|
-- # << NEORV32 - Simple Testbench >> #
|
-- # << NEORV32 - Default Testbench >> #
|
-- # ********************************************************************************************* #
|
-- # ********************************************************************************************* #
|
-- # This testbench provides a virtual UART receiver connected to the processor's uart_txd_o #
|
-- # This testbench provides a virtual UART receiver connected to the processor's uart_txd_o #
|
-- # signals. The received chars are shown in the simulator console and also written to a file #
|
-- # signal. The received chars are shown in the simulator console and also written to a file #
|
-- # ("neorv32.testbench_uart.out"). #
|
-- # ("neorv32.testbench_uart.out"). Futhermore, this testbench provides a simple RAM connected #
|
-- # Futhermore, this testbench provides a simple RAM connected to the external Wishbone bus. #
|
-- # to the external Wishbone bus. The testbench configures the processor with all optional #
|
-- # The testbench configures the processor with all optional element enabled by default. #
|
-- # elements enabled by default. #
|
-- # ********************************************************************************************* #
|
-- # ********************************************************************************************* #
|
-- # BSD 3-Clause License #
|
-- # BSD 3-Clause License #
|
-- # #
|
-- # #
|
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
-- # #
|
-- # #
|
Line 101... |
Line 101... |
sel : std_ulogic_vector(03 downto 0); -- byte enable
|
sel : std_ulogic_vector(03 downto 0); -- byte enable
|
stb : std_ulogic; -- strobe
|
stb : std_ulogic; -- strobe
|
cyc : std_ulogic; -- valid cycle
|
cyc : std_ulogic; -- valid cycle
|
ack : std_ulogic; -- transfer acknowledge
|
ack : std_ulogic; -- transfer acknowledge
|
err : std_ulogic; -- transfer error
|
err : std_ulogic; -- transfer error
|
|
tag : std_ulogic_vector(2 downto 0); -- tag
|
end record;
|
end record;
|
signal wb_cpu : wishbone_t;
|
signal wb_cpu : wishbone_t;
|
|
|
-- Wishbone memory --
|
-- Wishbone memory --
|
type wb_mem_ram_t is array (0 to wb_mem_size_c/4-1) of std_ulogic_vector(31 downto 0);
|
type wb_mem_ram_t is array (0 to wb_mem_size_c/4-1) of std_ulogic_vector(31 downto 0);
|
Line 124... |
Line 125... |
|
|
-- ---------------------------------------------- --
|
-- ---------------------------------------------- --
|
-- How to simulate a boot from an external memory --
|
-- How to simulate a boot from an external memory --
|
-- ---------------------------------------------- --
|
-- ---------------------------------------------- --
|
-- The simulated Wishbone memory can be initialized with the compiled application init.
|
-- The simulated Wishbone memory can be initialized with the compiled application init.
|
-- 1. Uncomment the init_wbmen function below; this will initialize the simulated wishbone memory with the neorv32_application_image.vhd image
|
-- 1. Uncomment the init_wbmem function below; this will initialize the simulated wishbone memory with the neorv32_application_image.vhd image
|
-- 2. Increase the wb_mem_size_c constant above to (at least) the size of the application image (like 16kB)
|
-- 2. Increase the wb_mem_size_c constant above to (at least) the size of the application image (like 16kB -> 16*1024)
|
-- 3. Disable the processor-internal IMEM in the processor instantiation below (MEM_INT_IMEM_USE => false)
|
-- 3. Disable the processor-internal IMEM in the processor instantiation below (MEM_INT_IMEM_USE => false)
|
-- 4. Set the Wishbone memory base address wb_mem_base_addr_c (above) to zero (constant wb_mem_base_addr_c : std_ulogic_vector(31 downto 0) := x"00000000";)
|
-- 4. Set the Wishbone memory base address wb_mem_base_addr_c (above) to zero (constant wb_mem_base_addr_c : std_ulogic_vector(31 downto 0) := x"00000000";)
|
-- 5. Simulate!
|
-- 5. Simulate!
|
|
|
signal wb_ram : wb_mem_ram_t;-- := init_wbmem(application_init_image); -- uncomment if you want to init the WB ram with app image
|
signal wb_ram : wb_mem_ram_t;-- := init_wbmem(application_init_image); -- uncomment if you want to init the WB ram with app image
|
Line 155... |
Line 156... |
neorv32_top_inst: neorv32_top
|
neorv32_top_inst: neorv32_top
|
generic map (
|
generic map (
|
-- General --
|
-- General --
|
CLOCK_FREQUENCY => f_clock_nat_c, -- clock frequency of clk_i in Hz
|
CLOCK_FREQUENCY => f_clock_nat_c, -- clock frequency of clk_i in Hz
|
BOOTLOADER_USE => false, -- implement processor-internal bootloader?
|
BOOTLOADER_USE => false, -- implement processor-internal bootloader?
|
USER_CODE => x"19880704", -- custom user code
|
USER_CODE => x"12345678", -- custom user code
|
|
HW_THREAD_ID => x"00000000", -- hardware thread id (hartid)
|
-- RISC-V CPU Extensions --
|
-- RISC-V CPU Extensions --
|
CPU_EXTENSION_RISCV_C => true, -- implement compressed extension?
|
CPU_EXTENSION_RISCV_C => true, -- implement compressed extension?
|
CPU_EXTENSION_RISCV_E => false, -- implement embedded RF extension?
|
CPU_EXTENSION_RISCV_E => false, -- implement embedded RF extension?
|
CPU_EXTENSION_RISCV_M => true, -- implement muld/div extension?
|
CPU_EXTENSION_RISCV_M => true, -- implement muld/div extension?
|
CPU_EXTENSION_RISCV_U => true, -- implement user mode extension?
|
CPU_EXTENSION_RISCV_U => true, -- implement user mode extension?
|
Line 196... |
Line 198... |
port map (
|
port map (
|
-- Global control --
|
-- Global control --
|
clk_i => clk_gen, -- global clock, rising edge
|
clk_i => clk_gen, -- global clock, rising edge
|
rstn_i => rst_gen, -- global reset, low-active, async
|
rstn_i => rst_gen, -- global reset, low-active, async
|
-- Wishbone bus interface --
|
-- Wishbone bus interface --
|
|
wb_tag_o => wb_cpu.tag, -- tag
|
wb_adr_o => wb_cpu.addr, -- address
|
wb_adr_o => wb_cpu.addr, -- address
|
wb_dat_i => wb_cpu.rdata, -- read data
|
wb_dat_i => wb_cpu.rdata, -- read data
|
wb_dat_o => wb_cpu.wdata, -- write data
|
wb_dat_o => wb_cpu.wdata, -- write data
|
wb_we_o => wb_cpu.we, -- read/write
|
wb_we_o => wb_cpu.we, -- read/write
|
wb_sel_o => wb_cpu.sel, -- byte enable
|
wb_sel_o => wb_cpu.sel, -- byte enable
|
Line 230... |
Line 233... |
mtime_irq_i => '0', -- machine software interrupt, available if IO_MTIME_USE = false
|
mtime_irq_i => '0', -- machine software interrupt, available if IO_MTIME_USE = false
|
msw_irq_i => '0', -- machine software interrupt
|
msw_irq_i => '0', -- machine software interrupt
|
mext_irq_i => '0' -- machine external interrupt
|
mext_irq_i => '0' -- machine external interrupt
|
);
|
);
|
|
|
-- TWI termination --
|
-- TWI termination (pull-ups) --
|
twi_scl <= 'H';
|
twi_scl <= 'H';
|
twi_sda <= 'H';
|
twi_sda <= 'H';
|
|
|
|
|
-- Console UART Receiver ------------------------------------------------------------------
|
-- Console UART Receiver ------------------------------------------------------------------
|