Line 113... |
Line 113... |
|
|
-- spi --
|
-- spi --
|
signal spi_data : std_ulogic;
|
signal spi_data : std_ulogic;
|
|
|
-- irq --
|
-- irq --
|
signal msi_ring, mei_ring, nmi_ring : std_ulogic;
|
signal msi_ring, mei_ring : std_ulogic;
|
|
|
-- Wishbone bus --
|
-- Wishbone bus --
|
type wishbone_t is record
|
type wishbone_t is record
|
addr : std_ulogic_vector(31 downto 0); -- address
|
addr : std_ulogic_vector(31 downto 0); -- address
|
wdata : std_ulogic_vector(31 downto 0); -- master write data
|
wdata : std_ulogic_vector(31 downto 0); -- master write data
|
Line 295... |
Line 295... |
-- Extension Options --
|
-- Extension Options --
|
FAST_MUL_EN => false, -- use DSPs for M extension's multiplier
|
FAST_MUL_EN => false, -- use DSPs for M extension's multiplier
|
FAST_SHIFT_EN => false, -- use barrel shifter for shift operations
|
FAST_SHIFT_EN => false, -- use barrel shifter for shift operations
|
CPU_CNT_WIDTH => 64, -- total width of CPU cycle and instret counters (0..64)
|
CPU_CNT_WIDTH => 64, -- total width of CPU cycle and instret counters (0..64)
|
-- Physical Memory Protection (PMP) --
|
-- Physical Memory Protection (PMP) --
|
PMP_NUM_REGIONS => 5, -- number of regions (0..64)
|
PMP_NUM_REGIONS => 8, -- number of regions (0..64)
|
PMP_MIN_GRANULARITY => 64*1024, -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
PMP_MIN_GRANULARITY => 64*1024, -- minimal region granularity in bytes, has to be a power of 2, min 8 bytes
|
-- Hardware Performance Monitors (HPM) --
|
-- Hardware Performance Monitors (HPM) --
|
HPM_NUM_CNTS => 12, -- number of implemented HPM counters (0..29)
|
HPM_NUM_CNTS => 12, -- number of implemented HPM counters (0..29)
|
HPM_CNT_WIDTH => 40, -- total size of HPM counters (0..64)
|
HPM_CNT_WIDTH => 40, -- total size of HPM counters (0..64)
|
-- Internal Instruction memory --
|
-- Internal Instruction memory --
|
Line 406... |
Line 406... |
mtime_i => (others => '0'), -- current system time from ext. MTIME (if IO_MTIME_EN = false)
|
mtime_i => (others => '0'), -- current system time from ext. MTIME (if IO_MTIME_EN = false)
|
mtime_o => open, -- current system time from int. MTIME (if IO_MTIME_EN = true)
|
mtime_o => open, -- current system time from int. MTIME (if IO_MTIME_EN = true)
|
-- External platform interrupts (available if XIRQ_NUM_CH > 0) --
|
-- External platform interrupts (available if XIRQ_NUM_CH > 0) --
|
xirq_i => gpio(31 downto 0), -- IRQ channels
|
xirq_i => gpio(31 downto 0), -- IRQ channels
|
-- CPU Interrupts --
|
-- CPU Interrupts --
|
nm_irq_i => nmi_ring, -- non-maskable interrupt
|
|
mtime_irq_i => '0', -- machine software interrupt, available if IO_MTIME_EN = false
|
mtime_irq_i => '0', -- machine software interrupt, available if IO_MTIME_EN = false
|
msw_irq_i => msi_ring, -- machine software interrupt
|
msw_irq_i => msi_ring, -- machine software interrupt
|
mext_irq_i => mei_ring -- machine external interrupt
|
mext_irq_i => mei_ring -- machine external interrupt
|
);
|
);
|
|
|
Line 539... |
Line 538... |
end loop;
|
end loop;
|
end if;
|
end if;
|
|
|
-- bus output register --
|
-- bus output register --
|
wb_mem_a.err <= '0';
|
wb_mem_a.err <= '0';
|
if (ext_mem_a.ack(ext_mem_a_latency_c-1) = '1') and (wb_mem_b.cyc = '1') and (wb_mem_a.ack = '0') then
|
if (ext_mem_a.ack(ext_mem_a_latency_c-1) = '1') and (wb_mem_a.cyc = '1') and (wb_mem_a.ack = '0') then
|
wb_mem_a.rdata <= ext_mem_a.rdata(ext_mem_a_latency_c-1);
|
wb_mem_a.rdata <= ext_mem_a.rdata(ext_mem_a_latency_c-1);
|
wb_mem_a.ack <= '1';
|
wb_mem_a.ack <= '1';
|
else
|
else
|
wb_mem_a.rdata <= (others => '0');
|
wb_mem_a.rdata <= (others => '0');
|
wb_mem_a.ack <= '0';
|
wb_mem_a.ack <= '0';
|
Line 651... |
Line 650... |
end process ext_mem_c_access;
|
end process ext_mem_c_access;
|
|
|
|
|
-- Wishbone IRQ Triggers ------------------------------------------------------------------
|
-- Wishbone IRQ Triggers ------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
-- -------------------------------------------------------------------------------------------
|
irq_trigger: process(clk_gen)
|
irq_trigger: process(rst_gen, clk_gen)
|
begin
|
begin
|
if rising_edge(clk_gen) then
|
if (rst_gen = '0') then
|
|
msi_ring <= '0';
|
|
mei_ring <= '0';
|
|
elsif rising_edge(clk_gen) then
|
-- bus interface --
|
-- bus interface --
|
wb_irq.rdata <= (others => '0');
|
wb_irq.rdata <= (others => '0');
|
wb_irq.ack <= wb_irq.cyc and wb_irq.stb and wb_irq.we and and_reduce_f(wb_irq.sel);
|
wb_irq.ack <= wb_irq.cyc and wb_irq.stb and wb_irq.we and and_reduce_f(wb_irq.sel);
|
wb_irq.err <= '0';
|
wb_irq.err <= '0';
|
-- trigger IRQ using CSR.MIE bit layout --
|
-- trigger RISC-V platform IRQs --
|
nmi_ring <= '0';
|
|
msi_ring <= '0';
|
|
mei_ring <= '0';
|
|
if ((wb_irq.cyc and wb_irq.stb and wb_irq.we and and_reduce_f(wb_irq.sel)) = '1') then
|
if ((wb_irq.cyc and wb_irq.stb and wb_irq.we and and_reduce_f(wb_irq.sel)) = '1') then
|
nmi_ring <= wb_irq.wdata(00); -- non-maskable interrupt
|
|
msi_ring <= wb_irq.wdata(03); -- machine software interrupt
|
msi_ring <= wb_irq.wdata(03); -- machine software interrupt
|
mei_ring <= wb_irq.wdata(11); -- machine software interrupt
|
mei_ring <= wb_irq.wdata(11); -- machine software interrupt
|
end if;
|
end if;
|
end if;
|
end if;
|
end process irq_trigger;
|
end process irq_trigger;
|