mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-23 21:57:33 -04:00
removed custom CSRs - all processor-related information can now be obtained from SYSINFO IO device
This commit is contained in:
parent
5895df0f03
commit
8ae891352a
5 changed files with 475 additions and 402 deletions
|
@ -50,41 +50,17 @@ use neorv32.neorv32_package.all;
|
|||
entity neorv32_cpu is
|
||||
generic (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID : std_ulogic_vector(31 downto 0):= x"00000000"; -- hardware thread id
|
||||
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0):= x"00000000"; -- cpu boot address
|
||||
-- RISC-V CPU Extensions --
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE : natural := 8*1024; -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE : natural := 8*1024; -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
||||
MEM_DSPACE_SIZE : natural := 4*1024; -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE : natural := 4*1024; -- size of processor-internal data memory in bytes
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
||||
MEM_EXT_TIMEOUT : natural := 15; -- cycles after which a valid bus access will timeout
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE : boolean := true; -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE : boolean := true; -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
||||
MEM_EXT_TIMEOUT : natural := 15 -- cycles after which a valid bus access will timeout
|
||||
);
|
||||
port (
|
||||
-- global control --
|
||||
|
@ -124,28 +100,28 @@ end neorv32_cpu;
|
|||
architecture neorv32_cpu_rtl of neorv32_cpu is
|
||||
|
||||
-- local signals --
|
||||
signal ctrl : std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
||||
signal alu_cmp : std_ulogic_vector(1 downto 0); -- alu comparator result
|
||||
signal imm : std_ulogic_vector(data_width_c-1 downto 0); -- immediate
|
||||
signal instr : std_ulogic_vector(data_width_c-1 downto 0); -- new instruction
|
||||
signal rs1, rs2 : std_ulogic_vector(data_width_c-1 downto 0); -- source registers
|
||||
signal alu_res : std_ulogic_vector(data_width_c-1 downto 0); -- alu result
|
||||
signal alu_add : std_ulogic_vector(data_width_c-1 downto 0); -- alu adder result
|
||||
signal rdata : std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
|
||||
signal alu_wait : std_ulogic; -- alu is busy due to iterative unit
|
||||
signal bus_i_wait : std_ulogic; -- wait for current bus instruction fetch
|
||||
signal bus_d_wait : std_ulogic; -- wait for current bus data access
|
||||
signal csr_rdata : std_ulogic_vector(data_width_c-1 downto 0); -- csr read data
|
||||
signal mar : std_ulogic_vector(data_width_c-1 downto 0); -- current memory address register
|
||||
signal ma_instr : std_ulogic; -- misaligned instruction address
|
||||
signal ma_load : std_ulogic; -- misaligned load data address
|
||||
signal ma_store : std_ulogic; -- misaligned store data address
|
||||
signal be_instr : std_ulogic; -- bus error on instruction access
|
||||
signal be_load : std_ulogic; -- bus error on load data access
|
||||
signal be_store : std_ulogic; -- bus error on store data access
|
||||
signal fetch_pc : std_ulogic_vector(data_width_c-1 downto 0); -- pc for instruction fetch
|
||||
signal curr_pc : std_ulogic_vector(data_width_c-1 downto 0); -- current pc (for current executed instruction)
|
||||
signal next_pc : std_ulogic_vector(data_width_c-1 downto 0); -- next pc (for current executed instruction)
|
||||
signal ctrl : std_ulogic_vector(ctrl_width_c-1 downto 0); -- main control bus
|
||||
signal alu_cmp : std_ulogic_vector(1 downto 0); -- alu comparator result
|
||||
signal imm : std_ulogic_vector(data_width_c-1 downto 0); -- immediate
|
||||
signal instr : std_ulogic_vector(data_width_c-1 downto 0); -- new instruction
|
||||
signal rs1, rs2 : std_ulogic_vector(data_width_c-1 downto 0); -- source registers
|
||||
signal alu_res : std_ulogic_vector(data_width_c-1 downto 0); -- alu result
|
||||
signal alu_add : std_ulogic_vector(data_width_c-1 downto 0); -- alu adder result
|
||||
signal rdata : std_ulogic_vector(data_width_c-1 downto 0); -- memory read data
|
||||
signal alu_wait : std_ulogic; -- alu is busy due to iterative unit
|
||||
signal bus_i_wait : std_ulogic; -- wait for current bus instruction fetch
|
||||
signal bus_d_wait : std_ulogic; -- wait for current bus data access
|
||||
signal csr_rdata : std_ulogic_vector(data_width_c-1 downto 0); -- csr read data
|
||||
signal mar : std_ulogic_vector(data_width_c-1 downto 0); -- current memory address register
|
||||
signal ma_instr : std_ulogic; -- misaligned instruction address
|
||||
signal ma_load : std_ulogic; -- misaligned load data address
|
||||
signal ma_store : std_ulogic; -- misaligned store data address
|
||||
signal be_instr : std_ulogic; -- bus error on instruction access
|
||||
signal be_load : std_ulogic; -- bus error on load data access
|
||||
signal be_store : std_ulogic; -- bus error on store data access
|
||||
signal fetch_pc : std_ulogic_vector(data_width_c-1 downto 0); -- pc for instruction fetch
|
||||
signal curr_pc : std_ulogic_vector(data_width_c-1 downto 0); -- current pc (for current executed instruction)
|
||||
signal next_pc : std_ulogic_vector(data_width_c-1 downto 0); -- next pc (for current executed instruction)
|
||||
|
||||
-- co-processor interface --
|
||||
signal cp0_data, cp1_data : std_ulogic_vector(data_width_c-1 downto 0);
|
||||
|
@ -158,40 +134,15 @@ begin
|
|||
neorv32_cpu_control_inst: neorv32_cpu_control
|
||||
generic map (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY => CLOCK_FREQUENCY, -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE => BOOTLOADER_USE, -- implement processor-internal bootloader?
|
||||
CSR_COUNTERS_USE => CSR_COUNTERS_USE, -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID => HW_THREAD_ID, -- hardware thread id
|
||||
CPU_BOOT_ADDR => CPU_BOOT_ADDR, -- cpu boot address
|
||||
-- RISC-V CPU Extensions --
|
||||
CPU_EXTENSION_RISCV_C => CPU_EXTENSION_RISCV_C, -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E => CPU_EXTENSION_RISCV_E, -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M => CPU_EXTENSION_RISCV_M, -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr => CPU_EXTENSION_RISCV_Zicsr, -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei => CPU_EXTENSION_RISCV_Zifencei, -- implement instruction stream sync.?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE => MEM_ISPACE_BASE, -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE => MEM_ISPACE_SIZE, -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE => MEM_INT_IMEM_USE, -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM => MEM_INT_IMEM_ROM, -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE => MEM_DSPACE_BASE, -- base address of data memory space
|
||||
MEM_DSPACE_SIZE => MEM_DSPACE_SIZE, -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE => MEM_INT_DMEM_USE, -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE, -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE => MEM_EXT_USE, -- implement external memory bus interface?
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE => IO_GPIO_USE, -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE => IO_MTIME_USE, -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE => IO_UART_USE, -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE => IO_SPI_USE, -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE => IO_TWI_USE, -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE => IO_PWM_USE, -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE => IO_WDT_USE, -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE => IO_CLIC_USE, -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE => IO_TRNG_USE, -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE => IO_DEVNULL_USE -- implement dummy device (DEVNULL)?
|
||||
CPU_EXTENSION_RISCV_C => CPU_EXTENSION_RISCV_C, -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E => CPU_EXTENSION_RISCV_E, -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M => CPU_EXTENSION_RISCV_M, -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr => CPU_EXTENSION_RISCV_Zicsr, -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei => CPU_EXTENSION_RISCV_Zifencei -- implement instruction stream sync.?
|
||||
)
|
||||
port map (
|
||||
-- global control --
|
||||
|
@ -335,7 +286,7 @@ begin
|
|||
ma_instr_o => ma_instr, -- misaligned instruction address
|
||||
be_instr_o => be_instr, -- bus error on instruction access
|
||||
-- cpu data access interface --
|
||||
addr_i => alu_res, -- ALU result -> access address
|
||||
addr_i => alu_add, -- ALU.add result -> access address
|
||||
wdata_i => rs2, -- write data
|
||||
rdata_o => rdata, -- read data
|
||||
mar_o => mar, -- current memory address register
|
||||
|
|
|
@ -46,40 +46,15 @@ use neorv32.neorv32_package.all;
|
|||
entity neorv32_cpu_control is
|
||||
generic (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID : std_ulogic_vector(31 downto 0):= x"00000000"; -- hardware thread id
|
||||
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0):= x"00000000"; -- cpu boot address
|
||||
-- RISC-V CPU Extensions --
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE : natural := 8*1024; -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE : natural := 8*1024; -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
||||
MEM_DSPACE_SIZE : natural := 4*1024; -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE : natural := 4*1024; -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE : boolean := true; -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE : boolean := true; -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true -- implement instruction stream sync.?
|
||||
);
|
||||
port (
|
||||
-- global control --
|
||||
|
@ -535,14 +510,9 @@ begin
|
|||
execute_engine_fsm_sync_rst: process(rstn_i, clk_i)
|
||||
begin
|
||||
if (rstn_i = '0') then
|
||||
if (BOOTLOADER_USE = true) then -- boot from bootloader ROM
|
||||
execute_engine.pc <= boot_base_c(data_width_c-1 downto 1) & '0';
|
||||
execute_engine.last_pc <= boot_base_c(data_width_c-1 downto 1) & '0';
|
||||
else -- boot from IMEM
|
||||
execute_engine.pc <= MEM_ISPACE_BASE(data_width_c-1 downto 1) & '0';
|
||||
execute_engine.last_pc <= MEM_ISPACE_BASE(data_width_c-1 downto 1) & '0';
|
||||
end if;
|
||||
execute_engine.state <= SYS_WAIT;
|
||||
execute_engine.pc <= CPU_BOOT_ADDR(data_width_c-1 downto 1) & '0';
|
||||
execute_engine.last_pc <= CPU_BOOT_ADDR(data_width_c-1 downto 1) & '0';
|
||||
execute_engine.state <= SYS_WAIT;
|
||||
--
|
||||
execute_engine.sleep <= '0';
|
||||
elsif rising_edge(clk_i) then
|
||||
|
@ -1051,10 +1021,10 @@ begin
|
|||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"344") or -- mip
|
||||
--
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c00") and (CSR_COUNTERS_USE = true)) or -- cycle
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c01") and (CSR_COUNTERS_USE = true) and (IO_MTIME_USE = true)) or -- time
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c01") and (CSR_COUNTERS_USE = true)) or -- time
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c02") and (CSR_COUNTERS_USE = true)) or -- instret
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c80") and (CSR_COUNTERS_USE = true)) or -- cycleh
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c81") and (CSR_COUNTERS_USE = true) and (IO_MTIME_USE = true)) or -- timeh
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c81") and (CSR_COUNTERS_USE = true)) or -- timeh
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"c82") and (CSR_COUNTERS_USE = true)) or -- instreth
|
||||
--
|
||||
((execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"b00") and (CSR_COUNTERS_USE = true)) or -- mcycle
|
||||
|
@ -1065,14 +1035,7 @@ begin
|
|||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"f11") or -- mvendorid
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"f12") or -- marchid
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"f13") or -- mimpid
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"f14") or -- mhartid
|
||||
--
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"fc0") or -- mfeatures
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"fc1") or -- mclock
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"fc4") or -- mispacebase
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"fc5") or -- mispacesize
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"fc6") or -- mdspacebase
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"fc7") then -- mdspacesize
|
||||
(execute_engine.i_reg(instr_funct12_msb_c downto instr_funct12_lsb_c) = x"f14") then -- mhartid
|
||||
illegal_instruction <= '0';
|
||||
else
|
||||
illegal_instruction <= '1';
|
||||
|
@ -1423,36 +1386,6 @@ begin
|
|||
when x"f14" => -- R/-: mhartid - hardware thread ID
|
||||
csr_rdata_o <= HW_THREAD_ID;
|
||||
|
||||
-- CUSTOM read-only machine CSRs --
|
||||
when x"fc0" => -- R/-: mfeatures - implemented processor devices/features
|
||||
csr_rdata_o(00) <= bool_to_ulogic_f(BOOTLOADER_USE); -- implement processor-internal bootloader?
|
||||
csr_rdata_o(01) <= bool_to_ulogic_f(MEM_EXT_USE); -- implement external memory bus interface?
|
||||
csr_rdata_o(02) <= bool_to_ulogic_f(MEM_INT_IMEM_USE); -- implement processor-internal instruction memory?
|
||||
csr_rdata_o(03) <= bool_to_ulogic_f(MEM_INT_IMEM_ROM); -- implement processor-internal instruction memory as ROM?
|
||||
csr_rdata_o(04) <= bool_to_ulogic_f(MEM_INT_DMEM_USE); -- implement processor-internal data memory?
|
||||
csr_rdata_o(05) <= bool_to_ulogic_f(CSR_COUNTERS_USE); -- implement RISC-V (performance) counter?
|
||||
--
|
||||
csr_rdata_o(16) <= bool_to_ulogic_f(IO_GPIO_USE); -- implement general purpose input/output port unit (GPIO)?
|
||||
csr_rdata_o(17) <= bool_to_ulogic_f(IO_MTIME_USE); -- implement machine system timer (MTIME)?
|
||||
csr_rdata_o(18) <= bool_to_ulogic_f(IO_UART_USE); -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
csr_rdata_o(19) <= bool_to_ulogic_f(IO_SPI_USE); -- implement serial peripheral interface (SPI)?
|
||||
csr_rdata_o(20) <= bool_to_ulogic_f(IO_TWI_USE); -- implement two-wire interface (TWI)?
|
||||
csr_rdata_o(21) <= bool_to_ulogic_f(IO_PWM_USE); -- implement pulse-width modulation unit (PWM)?
|
||||
csr_rdata_o(22) <= bool_to_ulogic_f(IO_WDT_USE); -- implement watch dog timer (WDT)?
|
||||
csr_rdata_o(23) <= bool_to_ulogic_f(IO_CLIC_USE); -- implement core local interrupt controller (CLIC)?
|
||||
csr_rdata_o(24) <= bool_to_ulogic_f(IO_TRNG_USE); -- implement true random number generator (TRNG)?
|
||||
csr_rdata_o(25) <= bool_to_ulogic_f(IO_DEVNULL_USE); -- implement dummy device (DEVNULL)?
|
||||
when x"fc1" => -- R/-: mclock - processor clock speed
|
||||
csr_rdata_o <= std_ulogic_vector(to_unsigned(CLOCK_FREQUENCY, 32));
|
||||
when x"fc4" => -- R/-: mispacebase - Base address of instruction memory space
|
||||
csr_rdata_o <= MEM_ISPACE_BASE;
|
||||
when x"fc5" => -- R/-: mdspacebase - Base address of data memory space
|
||||
csr_rdata_o <= MEM_DSPACE_BASE;
|
||||
when x"fc6" => -- R/-: mispacesize - Total size of instruction memory space in byte
|
||||
csr_rdata_o <= std_ulogic_vector(to_unsigned(MEM_ISPACE_SIZE, 32));
|
||||
when x"fc7" => -- R/-: mdspacesize - Total size of data memory space in byte
|
||||
csr_rdata_o <= std_ulogic_vector(to_unsigned(MEM_DSPACE_SIZE, 32));
|
||||
|
||||
-- undefined/unavailable --
|
||||
when others =>
|
||||
csr_rdata_o <= (others => '0'); -- not implemented
|
||||
|
|
|
@ -124,15 +124,19 @@ package neorv32_package is
|
|||
constant trng_ctrl_addr_c : std_ulogic_vector(31 downto 0) := std_ulogic_vector(unsigned(trng_base_c) + x"00000000");
|
||||
constant trng_data_addr_c : std_ulogic_vector(31 downto 0) := std_ulogic_vector(unsigned(trng_base_c) + x"00000004");
|
||||
|
||||
-- RESERVED --
|
||||
--constant ???_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"FFFFFFC8"; -- base address, fixed!
|
||||
--constant ???_size_c : natural := 13*4; -- bytes, fixed!
|
||||
|
||||
-- Dummy Device (with SIMULATION output) (DEVNULL) --
|
||||
constant devnull_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"FFFFFFFC"; -- base address, fixed!
|
||||
constant devnull_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"FFFFFFC8"; -- base address, fixed!
|
||||
constant devnull_size_c : natural := 1*4; -- bytes, fixed!
|
||||
constant devnull_data_addr_c : std_ulogic_vector(31 downto 0) := std_ulogic_vector(unsigned(devnull_base_c) + x"00000000");
|
||||
|
||||
-- RESERVED --
|
||||
--constant ???_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"FFFFFFCC"; -- base address, fixed!
|
||||
--constant ???_size_c : natural := 5*4; -- bytes, fixed!
|
||||
|
||||
-- System Information Memory (with SIMULATION output) (SYSINFO) --
|
||||
constant sysinfo_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"FFFFFFE0"; -- base address, fixed!
|
||||
constant sysinfo_size_c : natural := 8*4; -- bytes, fixed!
|
||||
|
||||
-- Main Control Bus -----------------------------------------------------------------------
|
||||
-- -------------------------------------------------------------------------------------------
|
||||
-- register file --
|
||||
|
@ -441,41 +445,17 @@ package neorv32_package is
|
|||
component neorv32_cpu
|
||||
generic (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID : std_ulogic_vector(31 downto 0):= x"00000000"; -- hardware thread id
|
||||
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0):= x"00000000"; -- cpu boot address
|
||||
-- RISC-V CPU Extensions --
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE : natural := 8*1024; -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE : natural := 8*1024; -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
||||
MEM_DSPACE_SIZE : natural := 4*1024; -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE : natural := 4*1024; -- size of processor-internal data memory in bytes
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
||||
MEM_EXT_TIMEOUT : natural := 15; -- cycles after which a valid bus access will timeout
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE : boolean := true; -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE : boolean := true; -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
||||
MEM_EXT_TIMEOUT : natural := 15 -- cycles after which a valid bus access will timeout
|
||||
);
|
||||
port (
|
||||
-- global control --
|
||||
|
@ -517,40 +497,15 @@ package neorv32_package is
|
|||
component neorv32_cpu_control
|
||||
generic (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID : std_ulogic_vector(31 downto 0):= x"00000000"; -- hardware thread id
|
||||
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0):= x"00000000"; -- cpu boot address
|
||||
-- RISC-V CPU Extensions --
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE : natural := 16*1024; -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE : natural := 16*1024; -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
||||
MEM_DSPACE_SIZE : natural := 8*1024; -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE : natural := 8*1024; -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE : boolean := true; -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE : boolean := true; -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
||||
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei : boolean := true -- implement instruction stream sync.?
|
||||
);
|
||||
port (
|
||||
-- global control --
|
||||
|
@ -1079,6 +1034,48 @@ package neorv32_package is
|
|||
);
|
||||
end component;
|
||||
|
||||
---- Component: System Configuration Information Memory (SYSINFO) ---------------------------
|
||||
---- -------------------------------------------------------------------------------------------
|
||||
component neorv32_sysinfo
|
||||
generic (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE : natural := 8*1024; -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE : natural := 8*1024; -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
||||
MEM_DSPACE_SIZE : natural := 4*1024; -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE : natural := 4*1024; -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE : boolean := true; -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE : boolean := true; -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
||||
);
|
||||
port (
|
||||
-- host access --
|
||||
clk_i : in std_ulogic; -- global clock line
|
||||
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
||||
rden_i : in std_ulogic; -- read enable
|
||||
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
||||
ack_o : out std_ulogic -- transfer acknowledge
|
||||
);
|
||||
end component;
|
||||
|
||||
end neorv32_package;
|
||||
|
||||
package body neorv32_package is
|
||||
|
|
169
rtl/core/neorv32_sysinfo.vhd
Normal file
169
rtl/core/neorv32_sysinfo.vhd
Normal file
|
@ -0,0 +1,169 @@
|
|||
-- #################################################################################################
|
||||
-- # << NEORV32 - System/Processor Configuration Information Memory (SYSINFO) >> #
|
||||
-- # ********************************************************************************************* #
|
||||
-- # This unit provides information regarding the 'system' configuration - mostly derived from the #
|
||||
-- # top's configuration generics. #
|
||||
-- # ********************************************************************************************* #
|
||||
-- # BSD 3-Clause License #
|
||||
-- # #
|
||||
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
||||
-- # #
|
||||
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
||||
-- # permitted provided that the following conditions are met: #
|
||||
-- # #
|
||||
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
||||
-- # conditions and the following disclaimer. #
|
||||
-- # #
|
||||
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
|
||||
-- # conditions and the following disclaimer in the documentation and/or other materials #
|
||||
-- # provided with the distribution. #
|
||||
-- # #
|
||||
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
|
||||
-- # endorse or promote products derived from this software without specific prior written #
|
||||
-- # permission. #
|
||||
-- # #
|
||||
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
|
||||
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
|
||||
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
|
||||
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
|
||||
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
|
||||
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
|
||||
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
|
||||
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
|
||||
-- # OF THE POSSIBILITY OF SUCH DAMAGE. #
|
||||
-- # ********************************************************************************************* #
|
||||
-- # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
-- #################################################################################################
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
library neorv32;
|
||||
use neorv32.neorv32_package.all;
|
||||
|
||||
entity neorv32_sysinfo is
|
||||
generic (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE : natural := 8*1024; -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE : natural := 8*1024; -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
||||
MEM_DSPACE_SIZE : natural := 4*1024; -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE : natural := 4*1024; -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE : boolean := true; -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE : boolean := true; -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
||||
);
|
||||
port (
|
||||
-- host access --
|
||||
clk_i : in std_ulogic; -- global clock line
|
||||
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
||||
rden_i : in std_ulogic; -- read enable
|
||||
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
||||
ack_o : out std_ulogic -- transfer acknowledge
|
||||
);
|
||||
end neorv32_sysinfo;
|
||||
|
||||
architecture neorv32_sysinfo_rtl of neorv32_sysinfo is
|
||||
|
||||
-- IO space: module base address --
|
||||
constant hi_abb_c : natural := index_size_f(io_size_c)-1; -- high address boundary bit
|
||||
constant lo_abb_c : natural := index_size_f(sysinfo_size_c); -- low address boundary bit
|
||||
|
||||
-- access control --
|
||||
signal acc_en : std_ulogic; -- module access enable
|
||||
signal addr : std_ulogic_vector(31 downto 0);
|
||||
signal rden : std_ulogic;
|
||||
signal info_addr : std_ulogic_vector(02 downto 0);
|
||||
|
||||
-- system information ROM --
|
||||
type info_mem_t is array (0 to 7) of std_ulogic_vector(31 downto 0);
|
||||
signal sysinfo_mem : info_mem_t;
|
||||
|
||||
begin
|
||||
|
||||
-- Access Control -------------------------------------------------------------------------
|
||||
-- -------------------------------------------------------------------------------------------
|
||||
acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = sysinfo_base_c(hi_abb_c downto lo_abb_c)) else '0';
|
||||
rden <= acc_en and rden_i; -- valid read access
|
||||
addr <= sysinfo_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
|
||||
info_addr <= addr(index_size_f(sysinfo_size_c)-1 downto 2);
|
||||
|
||||
|
||||
-- Construct Info ROM ---------------------------------------------------------------------
|
||||
-- -------------------------------------------------------------------------------------------
|
||||
|
||||
-- SYSINFO(0): Processor (primary) clock frequency --
|
||||
sysinfo_mem(0) <= std_ulogic_vector(to_unsigned(CLOCK_FREQUENCY, 32));
|
||||
|
||||
-- SYSINFO(1): reserved --
|
||||
sysinfo_mem(1) <= (others => '0');
|
||||
|
||||
-- SYSINFO(2): Implemented processor devices/features --
|
||||
sysinfo_mem(2)(00) <= bool_to_ulogic_f(BOOTLOADER_USE); -- implement processor-internal bootloader?
|
||||
sysinfo_mem(2)(01) <= bool_to_ulogic_f(MEM_EXT_USE); -- implement external memory bus interface?
|
||||
sysinfo_mem(2)(02) <= bool_to_ulogic_f(MEM_INT_IMEM_USE); -- implement processor-internal instruction memory?
|
||||
sysinfo_mem(2)(03) <= bool_to_ulogic_f(MEM_INT_IMEM_ROM); -- implement processor-internal instruction memory as ROM?
|
||||
sysinfo_mem(2)(04) <= bool_to_ulogic_f(MEM_INT_DMEM_USE); -- implement processor-internal data memory?
|
||||
-- IO
|
||||
sysinfo_mem(2)(16) <= bool_to_ulogic_f(IO_GPIO_USE); -- implement general purpose input/output port unit (GPIO)?
|
||||
sysinfo_mem(2)(17) <= bool_to_ulogic_f(IO_MTIME_USE); -- implement machine system timer (MTIME)?
|
||||
sysinfo_mem(2)(18) <= bool_to_ulogic_f(IO_UART_USE); -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
sysinfo_mem(2)(19) <= bool_to_ulogic_f(IO_SPI_USE); -- implement serial peripheral interface (SPI)?
|
||||
sysinfo_mem(2)(20) <= bool_to_ulogic_f(IO_TWI_USE); -- implement two-wire interface (TWI)?
|
||||
sysinfo_mem(2)(21) <= bool_to_ulogic_f(IO_PWM_USE); -- implement pulse-width modulation unit (PWM)?
|
||||
sysinfo_mem(2)(22) <= bool_to_ulogic_f(IO_WDT_USE); -- implement watch dog timer (WDT)?
|
||||
sysinfo_mem(2)(23) <= bool_to_ulogic_f(IO_CLIC_USE); -- implement core local interrupt controller (CLIC)?
|
||||
sysinfo_mem(2)(24) <= bool_to_ulogic_f(IO_TRNG_USE); -- implement true random number generator (TRNG)?
|
||||
sysinfo_mem(2)(25) <= bool_to_ulogic_f(IO_DEVNULL_USE); -- implement dummy device (DEVNULL)?
|
||||
|
||||
-- SYSINFO(3): reserved --
|
||||
sysinfo_mem(3) <= (others => '0'); -- reserved for technology-specific configuration options
|
||||
|
||||
-- SYSINFO(4): Base address of instruction memory space --
|
||||
sysinfo_mem(4) <= MEM_ISPACE_BASE;
|
||||
|
||||
-- SYSINFO(5): Base address of data memory space --
|
||||
sysinfo_mem(5) <= MEM_DSPACE_BASE;
|
||||
|
||||
-- SYSINFO(6): Total size of instruction memory space in byte --
|
||||
sysinfo_mem(6) <= std_ulogic_vector(to_unsigned(MEM_ISPACE_SIZE, 32));
|
||||
|
||||
-- SYSINFO(7): Total size of data memory space in byte --
|
||||
sysinfo_mem(7) <= std_ulogic_vector(to_unsigned(MEM_DSPACE_SIZE, 32));
|
||||
|
||||
|
||||
-- Read Access ----------------------------------------------------------------------------
|
||||
-- -------------------------------------------------------------------------------------------
|
||||
read_access: process(clk_i)
|
||||
begin
|
||||
if rising_edge(clk_i) then
|
||||
ack_o <= rden;
|
||||
if (rden = '1') then
|
||||
data_o <= sysinfo_mem(to_integer(unsigned(info_addr)));
|
||||
else
|
||||
data_o <= (others => '0');
|
||||
end if;
|
||||
end if;
|
||||
end process read_access;
|
||||
|
||||
|
||||
end neorv32_sysinfo_rtl;
|
|
@ -124,6 +124,9 @@ end neorv32_top;
|
|||
|
||||
architecture neorv32_top_rtl of neorv32_top is
|
||||
|
||||
-- CPU boot address --
|
||||
constant boot_addr_c : std_ulogic_vector(31 downto 0) := cond_sel_stdulogicvector_f(BOOTLOADER_USE, boot_base_c, MEM_ISPACE_BASE);
|
||||
|
||||
-- reset generator --
|
||||
signal rstn_i_sync0 : std_ulogic;
|
||||
signal rstn_i_sync1 : std_ulogic;
|
||||
|
@ -193,6 +196,8 @@ architecture neorv32_top_rtl of neorv32_top is
|
|||
signal trng_ack : std_ulogic;
|
||||
signal devnull_rdata : std_ulogic_vector(data_width_c-1 downto 0);
|
||||
signal devnull_ack : std_ulogic;
|
||||
signal sysinfo_rdata : std_ulogic_vector(data_width_c-1 downto 0);
|
||||
signal sysinfo_ack : std_ulogic;
|
||||
|
||||
-- IRQs --
|
||||
signal mtime_irq : std_ulogic;
|
||||
|
@ -324,41 +329,17 @@ begin
|
|||
neorv32_cpu_inst: neorv32_cpu
|
||||
generic map (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY => CLOCK_FREQUENCY, -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE => BOOTLOADER_USE, -- implement processor-internal bootloader?
|
||||
CSR_COUNTERS_USE => CSR_COUNTERS_USE, -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID => (others => '0'), -- hardware thread id
|
||||
CSR_COUNTERS_USE => CSR_COUNTERS_USE, -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
||||
HW_THREAD_ID => (others => '0'), -- hardware thread id
|
||||
CPU_BOOT_ADDR => boot_addr_c, -- cpu boot address
|
||||
-- RISC-V CPU Extensions --
|
||||
CPU_EXTENSION_RISCV_C => CPU_EXTENSION_RISCV_C, -- implement compressed extension?
|
||||
CPU_EXTENSION_RISCV_E => CPU_EXTENSION_RISCV_E, -- implement embedded RF extension?
|
||||
CPU_EXTENSION_RISCV_M => CPU_EXTENSION_RISCV_M, -- implement muld/div extension?
|
||||
CPU_EXTENSION_RISCV_Zicsr => CPU_EXTENSION_RISCV_Zicsr, -- implement CSR system?
|
||||
CPU_EXTENSION_RISCV_Zifencei => CPU_EXTENSION_RISCV_Zifencei, -- implement instruction stream sync.?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE => MEM_ISPACE_BASE, -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE => MEM_ISPACE_SIZE, -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE => MEM_INT_IMEM_USE, -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM => MEM_INT_IMEM_ROM, -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE => MEM_DSPACE_BASE, -- base address of data memory space
|
||||
MEM_DSPACE_SIZE => MEM_DSPACE_SIZE, -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE => MEM_INT_DMEM_USE, -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE, -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE => MEM_EXT_USE, -- implement external memory bus interface?
|
||||
MEM_EXT_TIMEOUT => MEM_EXT_TIMEOUT, -- cycles after which a valid bus access will timeout
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE => IO_GPIO_USE, -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE => IO_MTIME_USE, -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE => IO_UART_USE, -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE => IO_SPI_USE, -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE => IO_TWI_USE, -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE => IO_PWM_USE, -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE => IO_WDT_USE, -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE => IO_CLIC_USE, -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE => IO_TRNG_USE, -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE => IO_DEVNULL_USE -- implement dummy device (DEVNULL)?
|
||||
MEM_EXT_TIMEOUT => MEM_EXT_TIMEOUT -- cycles after which a valid bus access will timeout
|
||||
)
|
||||
port map (
|
||||
-- global control --
|
||||
|
@ -443,12 +424,12 @@ begin
|
|||
fencei_o <= cpu_i.fence; -- indicates an executed FENCEI operation
|
||||
|
||||
-- process bus: CPU data input --
|
||||
p_bus.rdata <= (imem_rdata or dmem_rdata or bootrom_rdata) or wishbone_rdata or (gpio_rdata or mtime_rdata or
|
||||
uart_rdata or spi_rdata or twi_rdata or pwm_rdata or wdt_rdata or clic_rdata or trng_rdata or devnull_rdata);
|
||||
p_bus.rdata <= (imem_rdata or dmem_rdata or bootrom_rdata) or wishbone_rdata or (gpio_rdata or mtime_rdata or uart_rdata or
|
||||
spi_rdata or twi_rdata or pwm_rdata or wdt_rdata or clic_rdata or trng_rdata or devnull_rdata or sysinfo_rdata);
|
||||
|
||||
-- process bus: CPU data ACK input --
|
||||
p_bus.ack <= (imem_ack or dmem_ack or bootrom_ack) or wishbone_ack or (gpio_ack or mtime_ack or
|
||||
uart_ack or spi_ack or twi_ack or pwm_ack or wdt_ack or clic_ack or trng_ack or devnull_ack);
|
||||
p_bus.ack <= (imem_ack or dmem_ack or bootrom_ack) or wishbone_ack or (gpio_ack or mtime_ack or uart_ack or
|
||||
spi_ack or twi_ack or pwm_ack or wdt_ack or clic_ack or trng_ack or devnull_ack or sysinfo_ack);
|
||||
|
||||
-- process bus: CPU data bus error input --
|
||||
p_bus.err <= wishbone_err;
|
||||
|
@ -466,15 +447,15 @@ begin
|
|||
BOOTLOADER_USE => BOOTLOADER_USE -- implement and use bootloader?
|
||||
)
|
||||
port map (
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => p_bus.re, -- read enable
|
||||
wren_i => p_bus.we, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
upen_i => '1', -- update enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => imem_rdata, -- data out
|
||||
ack_o => imem_ack -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => p_bus.re, -- read enable
|
||||
wren_i => p_bus.we, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
upen_i => '1', -- update enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => imem_rdata, -- data out
|
||||
ack_o => imem_ack -- transfer acknowledge
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -495,14 +476,14 @@ begin
|
|||
DMEM_SIZE => MEM_INT_DMEM_SIZE -- processor-internal data memory size in bytes
|
||||
)
|
||||
port map (
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => p_bus.re, -- read enable
|
||||
wren_i => p_bus.we, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => dmem_rdata, -- data out
|
||||
ack_o => dmem_ack -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => p_bus.re, -- read enable
|
||||
wren_i => p_bus.we, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => dmem_rdata, -- data out
|
||||
ack_o => dmem_ack -- transfer acknowledge
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -519,11 +500,11 @@ begin
|
|||
if (BOOTLOADER_USE = true) generate
|
||||
neorv32_boot_rom_inst: neorv32_boot_rom
|
||||
port map (
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => p_bus.re, -- read enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_o => bootrom_rdata, -- data out
|
||||
ack_o => bootrom_ack -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => p_bus.re, -- read enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_o => bootrom_rdata, -- data out
|
||||
ack_o => bootrom_ack -- transfer acknowledge
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -542,15 +523,15 @@ begin
|
|||
generic map (
|
||||
INTERFACE_REG_STAGES => MEM_EXT_REG_STAGES, -- number of interface register stages (0,1,2)
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE => MEM_ISPACE_BASE, -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE => MEM_ISPACE_SIZE, -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE => MEM_INT_IMEM_USE, -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes
|
||||
MEM_ISPACE_BASE => MEM_ISPACE_BASE, -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE => MEM_ISPACE_SIZE, -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE => MEM_INT_IMEM_USE, -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE => MEM_DSPACE_BASE, -- base address of data memory space
|
||||
MEM_DSPACE_SIZE => MEM_DSPACE_SIZE, -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE => MEM_INT_DMEM_USE, -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE -- size of processor-internal data memory in bytes
|
||||
MEM_DSPACE_BASE => MEM_DSPACE_BASE, -- base address of data memory space
|
||||
MEM_DSPACE_SIZE => MEM_DSPACE_SIZE, -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE => MEM_INT_DMEM_USE, -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE -- size of processor-internal data memory in bytes
|
||||
)
|
||||
port map (
|
||||
-- global control --
|
||||
|
@ -608,19 +589,19 @@ begin
|
|||
neorv32_gpio_inst: neorv32_gpio
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => gpio_rdata, -- data out
|
||||
ack_o => gpio_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => gpio_rdata, -- data out
|
||||
ack_o => gpio_ack, -- transfer acknowledge
|
||||
-- parallel io --
|
||||
gpio_o => gpio_o,
|
||||
gpio_i => gpio_i,
|
||||
-- interrupt --
|
||||
irq_o => gpio_irq -- pin-change interrupt
|
||||
irq_o => gpio_irq -- pin-change interrupt
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -640,19 +621,19 @@ begin
|
|||
neorv32_clic_inst: neorv32_clic
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => clic_rdata, -- data out
|
||||
ack_o => clic_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => clic_rdata, -- data out
|
||||
ack_o => clic_ack, -- transfer acknowledge
|
||||
-- cpu interrupt --
|
||||
cpu_irq_o => clic_irq, -- trigger CPU's external IRQ
|
||||
cpu_irq_o => clic_irq, -- trigger CPU's external IRQ
|
||||
-- external interrupt lines --
|
||||
ext_irq_i => clic_xirq, -- IRQ, triggering on HIGH level
|
||||
ext_ack_o => clic_xack -- acknowledge
|
||||
ext_irq_i => clic_xirq, -- IRQ, triggering on HIGH level
|
||||
ext_ack_o => clic_xack -- acknowledge
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -686,21 +667,21 @@ begin
|
|||
neorv32_wdt_inst: neorv32_wdt
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
rstn_i => ext_rstn, -- global reset line, low-active
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => wdt_rdata, -- data out
|
||||
ack_o => wdt_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
rstn_i => ext_rstn, -- global reset line, low-active
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
addr_i => p_bus.addr, -- address
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => wdt_rdata, -- data out
|
||||
ack_o => wdt_ack, -- transfer acknowledge
|
||||
-- clock generator --
|
||||
clkgen_en_o => wdt_cg_en, -- enable clock generator
|
||||
clkgen_en_o => wdt_cg_en, -- enable clock generator
|
||||
clkgen_i => clk_gen,
|
||||
-- timeout event --
|
||||
irq_o => wdt_irq, -- timeout IRQ
|
||||
rstn_o => wdt_rstn -- timeout reset, low_active, use it as async!
|
||||
irq_o => wdt_irq, -- timeout IRQ
|
||||
rstn_o => wdt_rstn -- timeout reset, low_active, use it as async!
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -721,19 +702,19 @@ begin
|
|||
neorv32_mtime_inst: neorv32_mtime
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
rstn_i => sys_rstn, -- global reset, low-active, async
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => mtime_rdata, -- data out
|
||||
ack_o => mtime_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
rstn_i => sys_rstn, -- global reset, low-active, async
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => mtime_rdata, -- data out
|
||||
ack_o => mtime_ack, -- transfer acknowledge
|
||||
-- time output for CPU --
|
||||
time_o => mtime_time, -- current system time
|
||||
time_o => mtime_time, -- current system time
|
||||
-- interrupt --
|
||||
irq_o => mtime_irq -- interrupt request
|
||||
irq_o => mtime_irq -- interrupt request
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -753,22 +734,22 @@ begin
|
|||
neorv32_uart_inst: neorv32_uart
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => uart_rdata, -- data out
|
||||
ack_o => uart_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => uart_rdata, -- data out
|
||||
ack_o => uart_ack, -- transfer acknowledge
|
||||
-- clock generator --
|
||||
clkgen_en_o => uart_cg_en, -- enable clock generator
|
||||
clkgen_en_o => uart_cg_en, -- enable clock generator
|
||||
clkgen_i => clk_gen,
|
||||
-- com lines --
|
||||
uart_txd_o => uart_txd_o,
|
||||
uart_rxd_i => uart_rxd_i,
|
||||
-- interrupts --
|
||||
uart_irq_o => uart_irq -- uart rx/tx interrupt
|
||||
uart_irq_o => uart_irq -- uart rx/tx interrupt
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -789,24 +770,24 @@ begin
|
|||
neorv32_spi_inst: neorv32_spi
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => spi_rdata, -- data out
|
||||
ack_o => spi_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => spi_rdata, -- data out
|
||||
ack_o => spi_ack, -- transfer acknowledge
|
||||
-- clock generator --
|
||||
clkgen_en_o => spi_cg_en, -- enable clock generator
|
||||
clkgen_en_o => spi_cg_en, -- enable clock generator
|
||||
clkgen_i => clk_gen,
|
||||
-- com lines --
|
||||
spi_sck_o => spi_sck_o, -- SPI serial clock
|
||||
spi_sdo_o => spi_sdo_o, -- controller data out, peripheral data in
|
||||
spi_sdi_i => spi_sdi_i, -- controller data in, peripheral data out
|
||||
spi_csn_o => spi_csn_o, -- SPI CS
|
||||
spi_sck_o => spi_sck_o, -- SPI serial clock
|
||||
spi_sdo_o => spi_sdo_o, -- controller data out, peripheral data in
|
||||
spi_sdi_i => spi_sdi_i, -- controller data in, peripheral data out
|
||||
spi_csn_o => spi_csn_o, -- SPI CS
|
||||
-- interrupt --
|
||||
spi_irq_o => spi_irq -- transmission done interrupt
|
||||
spi_irq_o => spi_irq -- transmission done interrupt
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -829,22 +810,22 @@ begin
|
|||
neorv32_twi_inst: neorv32_twi
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => twi_rdata, -- data out
|
||||
ack_o => twi_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => twi_rdata, -- data out
|
||||
ack_o => twi_ack, -- transfer acknowledge
|
||||
-- clock generator --
|
||||
clkgen_en_o => twi_cg_en, -- enable clock generator
|
||||
clkgen_en_o => twi_cg_en, -- enable clock generator
|
||||
clkgen_i => clk_gen,
|
||||
-- com lines --
|
||||
twi_sda_io => twi_sda_io, -- serial data line
|
||||
twi_scl_io => twi_scl_io, -- serial clock line
|
||||
twi_sda_io => twi_sda_io, -- serial data line
|
||||
twi_scl_io => twi_scl_io, -- serial clock line
|
||||
-- interrupt --
|
||||
twi_irq_o => twi_irq -- transfer done IRQ
|
||||
twi_irq_o => twi_irq -- transfer done IRQ
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -866,16 +847,16 @@ begin
|
|||
neorv32_pwm_inst: neorv32_pwm
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => pwm_rdata, -- data out
|
||||
ack_o => pwm_ack, -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => pwm_rdata, -- data out
|
||||
ack_o => pwm_ack, -- transfer acknowledge
|
||||
-- clock generator --
|
||||
clkgen_en_o => pwm_cg_en, -- enable clock generator
|
||||
clkgen_en_o => pwm_cg_en, -- enable clock generator
|
||||
clkgen_i => clk_gen,
|
||||
-- pwm output channels --
|
||||
pwm_o => pwm_o
|
||||
|
@ -898,14 +879,14 @@ begin
|
|||
neorv32_trng_inst: neorv32_trng
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => trng_rdata, -- data out
|
||||
ack_o => trng_ack -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => trng_rdata, -- data out
|
||||
ack_o => trng_ack -- transfer acknowledge
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
@ -923,17 +904,17 @@ begin
|
|||
neorv32_devnull_inst: neorv32_devnull
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => devnull_rdata, -- data out
|
||||
ack_o => devnull_ack -- transfer acknowledge
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
wren_i => io_wren, -- write enable
|
||||
ben_i => p_bus.ben, -- byte write enable
|
||||
data_i => p_bus.wdata, -- data in
|
||||
data_o => devnull_rdata, -- data out
|
||||
ack_o => devnull_ack -- transfer acknowledge
|
||||
);
|
||||
end generate;
|
||||
|
||||
|
||||
neorv32_devnull_inst_false:
|
||||
if (IO_DEVNULL_USE = false) generate
|
||||
devnull_rdata <= (others => '0');
|
||||
|
@ -941,4 +922,46 @@ begin
|
|||
end generate;
|
||||
|
||||
|
||||
-- System Configuration Information Memory (SYSINFO) --------------------------------------
|
||||
-- -------------------------------------------------------------------------------------------
|
||||
neorv32_sysinfo_inst: neorv32_sysinfo
|
||||
generic map (
|
||||
-- General --
|
||||
CLOCK_FREQUENCY => CLOCK_FREQUENCY, -- clock frequency of clk_i in Hz
|
||||
BOOTLOADER_USE => BOOTLOADER_USE, -- implement processor-internal bootloader?
|
||||
-- Memory configuration: Instruction memory --
|
||||
MEM_ISPACE_BASE => MEM_ISPACE_BASE, -- base address of instruction memory space
|
||||
MEM_ISPACE_SIZE => MEM_ISPACE_SIZE, -- total size of instruction memory space in byte
|
||||
MEM_INT_IMEM_USE => MEM_INT_IMEM_USE, -- implement processor-internal instruction memory
|
||||
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes
|
||||
MEM_INT_IMEM_ROM => MEM_INT_IMEM_ROM, -- implement processor-internal instruction memory as ROM
|
||||
-- Memory configuration: Data memory --
|
||||
MEM_DSPACE_BASE => MEM_DSPACE_BASE, -- base address of data memory space
|
||||
MEM_DSPACE_SIZE => MEM_DSPACE_SIZE, -- total size of data memory space in byte
|
||||
MEM_INT_DMEM_USE => MEM_INT_DMEM_USE, -- implement processor-internal data memory
|
||||
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE, -- size of processor-internal data memory in bytes
|
||||
-- Memory configuration: External memory interface --
|
||||
MEM_EXT_USE => MEM_EXT_USE, -- implement external memory bus interface?
|
||||
-- Processor peripherals --
|
||||
IO_GPIO_USE => IO_GPIO_USE, -- implement general purpose input/output port unit (GPIO)?
|
||||
IO_MTIME_USE => IO_MTIME_USE, -- implement machine system timer (MTIME)?
|
||||
IO_UART_USE => IO_UART_USE, -- implement universal asynchronous receiver/transmitter (UART)?
|
||||
IO_SPI_USE => IO_SPI_USE, -- implement serial peripheral interface (SPI)?
|
||||
IO_TWI_USE => IO_TWI_USE, -- implement two-wire interface (TWI)?
|
||||
IO_PWM_USE => IO_PWM_USE, -- implement pulse-width modulation unit (PWM)?
|
||||
IO_WDT_USE => IO_WDT_USE, -- implement watch dog timer (WDT)?
|
||||
IO_CLIC_USE => IO_CLIC_USE, -- implement core local interrupt controller (CLIC)?
|
||||
IO_TRNG_USE => IO_TRNG_USE, -- implement true random number generator (TRNG)?
|
||||
IO_DEVNULL_USE => IO_DEVNULL_USE -- implement dummy device (DEVNULL)?
|
||||
)
|
||||
port map (
|
||||
-- host access --
|
||||
clk_i => clk_i, -- global clock line
|
||||
addr_i => p_bus.addr, -- address
|
||||
rden_i => io_rden, -- read enable
|
||||
data_o => sysinfo_rdata, -- data out
|
||||
ack_o => sysinfo_ack -- transfer acknowledge
|
||||
);
|
||||
|
||||
|
||||
end neorv32_top_rtl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue