Line 81... |
Line 81... |
function bswap32_f(input : std_ulogic_vector) return std_ulogic_vector;
|
function bswap32_f(input : std_ulogic_vector) return std_ulogic_vector;
|
|
|
-- Architecture Constants (do not modify!) ------------------------------------------------
|
-- Architecture Constants (do not modify!) ------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
constant data_width_c : natural := 32; -- native data path width - do not change!
|
constant data_width_c : natural := 32; -- native data path width - do not change!
|
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01050408"; -- no touchy!
|
constant hw_version_c : std_ulogic_vector(31 downto 0) := x"01050500"; -- no touchy!
|
constant archid_c : natural := 19; -- official NEORV32 architecture ID - hands off!
|
constant archid_c : natural := 19; -- official NEORV32 architecture ID - hands off!
|
constant rf_r0_is_reg_c : boolean := true; -- x0 is a *physical register* that has to be initialized to zero by the CPU
|
constant rf_r0_is_reg_c : boolean := true; -- x0 is a *physical register* that has to be initialized to zero by the CPU
|
constant def_rst_val_c : std_ulogic := cond_sel_stdulogic_f(dedicated_reset_c, '0', '-');
|
constant def_rst_val_c : std_ulogic := cond_sel_stdulogic_f(dedicated_reset_c, '0', '-');
|
|
|
-- Internal Types -------------------------------------------------------------------------
|
-- Internal Types -------------------------------------------------------------------------
|
Line 169... |
Line 169... |
constant mtime_time_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff90";
|
constant mtime_time_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff90";
|
constant mtime_time_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff94";
|
constant mtime_time_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff94";
|
constant mtime_cmp_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff98";
|
constant mtime_cmp_lo_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff98";
|
constant mtime_cmp_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff9c";
|
constant mtime_cmp_hi_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffff9c";
|
|
|
-- Universal Asynchronous Receiver/Transmitter 0 (UART0), primary UART --
|
-- Primary Universal Asynchronous Receiver/Transmitter (UART0) --
|
constant uart0_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa0"; -- base address
|
constant uart0_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa0"; -- base address
|
constant uart0_size_c : natural := 2*4; -- module's address space in bytes
|
constant uart0_size_c : natural := 2*4; -- module's address space in bytes
|
constant uart0_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa0";
|
constant uart0_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa0";
|
constant uart0_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa4";
|
constant uart0_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffa4";
|
|
|
Line 201... |
Line 201... |
constant nco_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc0";
|
constant nco_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc0";
|
constant nco_ch0_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc4";
|
constant nco_ch0_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc4";
|
constant nco_ch1_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc8";
|
constant nco_ch1_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffc8";
|
constant nco_ch2_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffcc";
|
constant nco_ch2_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffcc";
|
|
|
-- Universal Asynchronous Receiver/Transmitter 1 (UART1), secondary UART --
|
-- Secondary Universal Asynchronous Receiver/Transmitter (UART1) --
|
constant uart1_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd0"; -- base address
|
constant uart1_base_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd0"; -- base address
|
constant uart1_size_c : natural := 2*4; -- module's address space in bytes
|
constant uart1_size_c : natural := 2*4; -- module's address space in bytes
|
constant uart1_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd0";
|
constant uart1_ctrl_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd0";
|
constant uart1_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd4";
|
constant uart1_rtx_addr_c : std_ulogic_vector(data_width_c-1 downto 0) := x"ffffffd4";
|
|
|
Line 231... |
Line 231... |
constant ctrl_rf_rs2_adr0_c : natural := 6; -- source register 2 address bit 0
|
constant ctrl_rf_rs2_adr0_c : natural := 6; -- source register 2 address bit 0
|
constant ctrl_rf_rs2_adr1_c : natural := 7; -- source register 2 address bit 1
|
constant ctrl_rf_rs2_adr1_c : natural := 7; -- source register 2 address bit 1
|
constant ctrl_rf_rs2_adr2_c : natural := 8; -- source register 2 address bit 2
|
constant ctrl_rf_rs2_adr2_c : natural := 8; -- source register 2 address bit 2
|
constant ctrl_rf_rs2_adr3_c : natural := 9; -- source register 2 address bit 3
|
constant ctrl_rf_rs2_adr3_c : natural := 9; -- source register 2 address bit 3
|
constant ctrl_rf_rs2_adr4_c : natural := 10; -- source register 2 address bit 4
|
constant ctrl_rf_rs2_adr4_c : natural := 10; -- source register 2 address bit 4
|
constant ctrl_rf_rd_adr0_c : natural := 11; -- destiantion register address bit 0
|
constant ctrl_rf_rd_adr0_c : natural := 11; -- destination register address bit 0
|
constant ctrl_rf_rd_adr1_c : natural := 12; -- destiantion register address bit 1
|
constant ctrl_rf_rd_adr1_c : natural := 12; -- destination register address bit 1
|
constant ctrl_rf_rd_adr2_c : natural := 13; -- destiantion register address bit 2
|
constant ctrl_rf_rd_adr2_c : natural := 13; -- destination register address bit 2
|
constant ctrl_rf_rd_adr3_c : natural := 14; -- destiantion register address bit 3
|
constant ctrl_rf_rd_adr3_c : natural := 14; -- destination register address bit 3
|
constant ctrl_rf_rd_adr4_c : natural := 15; -- destiantion register address bit 4
|
constant ctrl_rf_rd_adr4_c : natural := 15; -- destination register address bit 4
|
constant ctrl_rf_wb_en_c : natural := 16; -- write back enable
|
constant ctrl_rf_wb_en_c : natural := 16; -- write back enable
|
constant ctrl_rf_r0_we_c : natural := 17; -- force write access and force rd=r0
|
constant ctrl_rf_r0_we_c : natural := 17; -- force write access and force rd=r0
|
-- alu --
|
-- alu --
|
constant ctrl_alu_arith_c : natural := 18; -- ALU arithmetic command
|
constant ctrl_alu_arith_c : natural := 18; -- ALU arithmetic command
|
constant ctrl_alu_logic0_c : natural := 19; -- ALU logic command bit 0
|
constant ctrl_alu_logic0_c : natural := 19; -- ALU logic command bit 0
|
Line 579... |
Line 579... |
constant csr_pmpaddr59_c : std_ulogic_vector(11 downto 0) := x"3eb";
|
constant csr_pmpaddr59_c : std_ulogic_vector(11 downto 0) := x"3eb";
|
constant csr_pmpaddr60_c : std_ulogic_vector(11 downto 0) := x"3ec";
|
constant csr_pmpaddr60_c : std_ulogic_vector(11 downto 0) := x"3ec";
|
constant csr_pmpaddr61_c : std_ulogic_vector(11 downto 0) := x"3ed";
|
constant csr_pmpaddr61_c : std_ulogic_vector(11 downto 0) := x"3ed";
|
constant csr_pmpaddr62_c : std_ulogic_vector(11 downto 0) := x"3ee";
|
constant csr_pmpaddr62_c : std_ulogic_vector(11 downto 0) := x"3ee";
|
constant csr_pmpaddr63_c : std_ulogic_vector(11 downto 0) := x"3ef";
|
constant csr_pmpaddr63_c : std_ulogic_vector(11 downto 0) := x"3ef";
|
|
---- debug mode registers --
|
|
--constant csr_class_debug_c : std_ulogic_vector(09 downto 0) := x"7b" & "00"; -- debug registers
|
|
--constant csr_dcsr_c : std_ulogic_vector(11 downto 0) := x"7b0";
|
|
--constant csr_dpc_c : std_ulogic_vector(11 downto 0) := x"7b1";
|
|
--constant csr_dsratch0_c : std_ulogic_vector(11 downto 0) := x"7b2";
|
|
--constant csr_dsratch1_c : std_ulogic_vector(11 downto 0) := x"7b3";
|
-- machine counters/timers --
|
-- machine counters/timers --
|
constant csr_mcycle_c : std_ulogic_vector(11 downto 0) := x"b00";
|
constant csr_mcycle_c : std_ulogic_vector(11 downto 0) := x"b00";
|
constant csr_minstret_c : std_ulogic_vector(11 downto 0) := x"b02";
|
constant csr_minstret_c : std_ulogic_vector(11 downto 0) := x"b02";
|
--
|
--
|
constant csr_mhpmcounter3_c : std_ulogic_vector(11 downto 0) := x"b03";
|
constant csr_mhpmcounter3_c : std_ulogic_vector(11 downto 0) := x"b03";
|
Line 764... |
Line 770... |
constant trap_sma_c : std_ulogic_vector(5 downto 0) := "0" & "00110"; -- 0.6: store address misaligned
|
constant trap_sma_c : std_ulogic_vector(5 downto 0) := "0" & "00110"; -- 0.6: store address misaligned
|
constant trap_sbe_c : std_ulogic_vector(5 downto 0) := "0" & "00111"; -- 0.7: store access fault
|
constant trap_sbe_c : std_ulogic_vector(5 downto 0) := "0" & "00111"; -- 0.7: store access fault
|
constant trap_uenv_c : std_ulogic_vector(5 downto 0) := "0" & "01000"; -- 0.8: environment call from u-mode
|
constant trap_uenv_c : std_ulogic_vector(5 downto 0) := "0" & "01000"; -- 0.8: environment call from u-mode
|
constant trap_menv_c : std_ulogic_vector(5 downto 0) := "0" & "01011"; -- 0.11: environment call from m-mode
|
constant trap_menv_c : std_ulogic_vector(5 downto 0) := "0" & "01011"; -- 0.11: environment call from m-mode
|
-- RISC-V compliant interrupts (async. exceptions) --
|
-- RISC-V compliant interrupts (async. exceptions) --
|
|
constant trap_nmi_c : std_ulogic_vector(5 downto 0) := "1" & "00000"; -- 1.0: non-maskable interrupt
|
constant trap_msi_c : std_ulogic_vector(5 downto 0) := "1" & "00011"; -- 1.3: machine software interrupt
|
constant trap_msi_c : std_ulogic_vector(5 downto 0) := "1" & "00011"; -- 1.3: machine software interrupt
|
constant trap_mti_c : std_ulogic_vector(5 downto 0) := "1" & "00111"; -- 1.7: machine timer interrupt
|
constant trap_mti_c : std_ulogic_vector(5 downto 0) := "1" & "00111"; -- 1.7: machine timer interrupt
|
constant trap_mei_c : std_ulogic_vector(5 downto 0) := "1" & "01011"; -- 1.11: machine external interrupt
|
constant trap_mei_c : std_ulogic_vector(5 downto 0) := "1" & "01011"; -- 1.11: machine external interrupt
|
-- NEORV32-specific (custom) interrupts (async. exceptions) --
|
-- NEORV32-specific (custom) interrupts (async. exceptions) --
|
constant trap_firq0_c : std_ulogic_vector(5 downto 0) := "1" & "10000"; -- 1.16: fast interrupt 0
|
constant trap_firq0_c : std_ulogic_vector(5 downto 0) := "1" & "10000"; -- 1.16: fast interrupt 0
|
Line 801... |
Line 808... |
constant exception_saccess_c : natural := 8; -- store access fault
|
constant exception_saccess_c : natural := 8; -- store access fault
|
constant exception_laccess_c : natural := 9; -- load access fault
|
constant exception_laccess_c : natural := 9; -- load access fault
|
--
|
--
|
constant exception_width_c : natural := 10; -- length of this list in bits
|
constant exception_width_c : natural := 10; -- length of this list in bits
|
-- interrupt source bits --
|
-- interrupt source bits --
|
constant interrupt_msw_irq_c : natural := 0; -- machine software interrupt
|
constant interrupt_nm_irq_c : natural := 0; -- non-maskable interrupt
|
constant interrupt_mtime_irq_c : natural := 1; -- machine timer interrupt
|
constant interrupt_msw_irq_c : natural := 1; -- machine software interrupt
|
constant interrupt_mext_irq_c : natural := 2; -- machine external interrupt
|
constant interrupt_mtime_irq_c : natural := 2; -- machine timer interrupt
|
constant interrupt_firq_0_c : natural := 3; -- fast interrupt channel 0
|
constant interrupt_mext_irq_c : natural := 3; -- machine external interrupt
|
constant interrupt_firq_1_c : natural := 4; -- fast interrupt channel 1
|
constant interrupt_firq_0_c : natural := 4; -- fast interrupt channel 0
|
constant interrupt_firq_2_c : natural := 5; -- fast interrupt channel 2
|
constant interrupt_firq_1_c : natural := 5; -- fast interrupt channel 1
|
constant interrupt_firq_3_c : natural := 6; -- fast interrupt channel 3
|
constant interrupt_firq_2_c : natural := 6; -- fast interrupt channel 2
|
constant interrupt_firq_4_c : natural := 7; -- fast interrupt channel 4
|
constant interrupt_firq_3_c : natural := 7; -- fast interrupt channel 3
|
constant interrupt_firq_5_c : natural := 8; -- fast interrupt channel 5
|
constant interrupt_firq_4_c : natural := 8; -- fast interrupt channel 4
|
constant interrupt_firq_6_c : natural := 9; -- fast interrupt channel 6
|
constant interrupt_firq_5_c : natural := 9; -- fast interrupt channel 5
|
constant interrupt_firq_7_c : natural := 10; -- fast interrupt channel 7
|
constant interrupt_firq_6_c : natural := 10; -- fast interrupt channel 6
|
constant interrupt_firq_8_c : natural := 11; -- fast interrupt channel 8
|
constant interrupt_firq_7_c : natural := 11; -- fast interrupt channel 7
|
constant interrupt_firq_9_c : natural := 12; -- fast interrupt channel 9
|
constant interrupt_firq_8_c : natural := 12; -- fast interrupt channel 8
|
constant interrupt_firq_10_c : natural := 13; -- fast interrupt channel 10
|
constant interrupt_firq_9_c : natural := 13; -- fast interrupt channel 9
|
constant interrupt_firq_11_c : natural := 14; -- fast interrupt channel 11
|
constant interrupt_firq_10_c : natural := 14; -- fast interrupt channel 10
|
constant interrupt_firq_12_c : natural := 15; -- fast interrupt channel 12
|
constant interrupt_firq_11_c : natural := 15; -- fast interrupt channel 11
|
constant interrupt_firq_13_c : natural := 16; -- fast interrupt channel 13
|
constant interrupt_firq_12_c : natural := 16; -- fast interrupt channel 12
|
constant interrupt_firq_14_c : natural := 17; -- fast interrupt channel 14
|
constant interrupt_firq_13_c : natural := 17; -- fast interrupt channel 13
|
constant interrupt_firq_15_c : natural := 18; -- fast interrupt channel 15
|
constant interrupt_firq_14_c : natural := 18; -- fast interrupt channel 14
|
|
constant interrupt_firq_15_c : natural := 19; -- fast interrupt channel 15
|
--
|
--
|
constant interrupt_width_c : natural := 19; -- length of this list in bits
|
constant interrupt_width_c : natural := 20; -- length of this list in bits
|
|
|
-- CPU Privilege Modes --------------------------------------------------------------------
|
-- CPU Privilege Modes --------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
constant priv_mode_m_c : std_ulogic_vector(1 downto 0) := "11"; -- machine mode
|
constant priv_mode_m_c : std_ulogic_vector(1 downto 0) := "11"; -- machine mode
|
constant priv_mode_u_c : std_ulogic_vector(1 downto 0) := "00"; -- user mode
|
constant priv_mode_u_c : std_ulogic_vector(1 downto 0) := "00"; -- user mode
|
Line 973... |
Line 981... |
-- NeoPixel-compatible smart LED interface (available if IO_NEOLED_EN = true) --
|
-- NeoPixel-compatible smart LED interface (available if IO_NEOLED_EN = true) --
|
neoled_o : out std_ulogic; -- async serial data line
|
neoled_o : out std_ulogic; -- async serial data line
|
-- system time input from external MTIME (available if IO_MTIME_EN = false) --
|
-- system time input from external MTIME (available if IO_MTIME_EN = false) --
|
mtime_i : in std_ulogic_vector(63 downto 0) := (others => '0'); -- current system time
|
mtime_i : in std_ulogic_vector(63 downto 0) := (others => '0'); -- current system time
|
-- Interrupts --
|
-- Interrupts --
|
|
nm_irq_i : in std_ulogic := '0'; -- non-maskable interrupt
|
soc_firq_i : in std_ulogic_vector(5 downto 0) := (others => '0'); -- fast interrupt channels
|
soc_firq_i : in std_ulogic_vector(5 downto 0) := (others => '0'); -- fast interrupt channels
|
mtime_irq_i : in std_ulogic := '0'; -- machine timer interrupt, available if IO_MTIME_EN = false
|
mtime_irq_i : in std_ulogic := '0'; -- machine timer interrupt, available if IO_MTIME_EN = false
|
msw_irq_i : in std_ulogic := '0'; -- machine software interrupt
|
msw_irq_i : in std_ulogic := '0'; -- machine software interrupt
|
mext_irq_i : in std_ulogic := '0' -- machine external interrupt
|
mext_irq_i : in std_ulogic := '0' -- machine external interrupt
|
);
|
);
|
Line 1040... |
Line 1049... |
d_bus_err_i : in std_ulogic := '0'; -- bus transfer error
|
d_bus_err_i : in std_ulogic := '0'; -- bus transfer error
|
d_bus_fence_o : out std_ulogic; -- executed FENCE operation
|
d_bus_fence_o : out std_ulogic; -- executed FENCE operation
|
d_bus_priv_o : out std_ulogic_vector(1 downto 0); -- privilege level
|
d_bus_priv_o : out std_ulogic_vector(1 downto 0); -- privilege level
|
-- system time input from MTIME --
|
-- system time input from MTIME --
|
time_i : in std_ulogic_vector(63 downto 0) := (others => '0'); -- current system time
|
time_i : in std_ulogic_vector(63 downto 0) := (others => '0'); -- current system time
|
|
-- non-maskable interrupt --
|
|
nm_irq_i : in std_ulogic := '0'; -- NMI
|
-- interrupts (risc-v compliant) --
|
-- interrupts (risc-v compliant) --
|
msw_irq_i : in std_ulogic := '0'; -- machine software interrupt
|
msw_irq_i : in std_ulogic := '0'; -- machine software interrupt
|
mext_irq_i : in std_ulogic := '0'; -- machine external interrupt
|
mext_irq_i : in std_ulogic := '0'; -- machine external interrupt
|
mtime_irq_i : in std_ulogic := '0'; -- machine timer interrupt
|
mtime_irq_i : in std_ulogic := '0'; -- machine timer interrupt
|
-- fast interrupts (custom) --
|
-- fast interrupts (custom) --
|
Line 1099... |
Line 1110... |
curr_pc_o : out std_ulogic_vector(data_width_c-1 downto 0); -- current PC (corresponding to current instruction)
|
curr_pc_o : out std_ulogic_vector(data_width_c-1 downto 0); -- current PC (corresponding to current instruction)
|
csr_rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- CSR read data
|
csr_rdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- CSR read data
|
-- FPU interface --
|
-- FPU interface --
|
fpu_rm_o : out std_ulogic_vector(02 downto 0); -- rounding mode
|
fpu_rm_o : out std_ulogic_vector(02 downto 0); -- rounding mode
|
fpu_flags_i : in std_ulogic_vector(04 downto 0); -- exception flags
|
fpu_flags_i : in std_ulogic_vector(04 downto 0); -- exception flags
|
|
-- non-maskable interrupt --
|
|
nm_irq_i : in std_ulogic;
|
-- interrupts (risc-v compliant) --
|
-- interrupts (risc-v compliant) --
|
msw_irq_i : in std_ulogic; -- machine software interrupt
|
msw_irq_i : in std_ulogic; -- machine software interrupt
|
mext_irq_i : in std_ulogic; -- machine external interrupt
|
mext_irq_i : in std_ulogic; -- machine external interrupt
|
mtime_irq_i : in std_ulogic; -- machine timer interrupt
|
mtime_irq_i : in std_ulogic; -- machine timer interrupt
|
-- fast interrupts (custom) --
|
-- fast interrupts (custom) --
|