mirror of
https://github.com/Domipheus/RPU.git
synced 2025-04-18 19:15:13 -04:00
Added Interrupt handling support: - Int enable masks - external interrupt - interrupt enable CSR - illegal instruction - system call instruction - breakpoints - interrupt CSR manipulation - correct nextPC resume/branch target selection Added debug data for CPU trace support Added vexrisc IRQ csrs for testing with 3rd party sw Added LINT unit locally arbitrates IRQs into priorities FIX: correctly sign extend data from memory controller FIX: set ALU to not branch on CSR unit ops FIX: correctly detect invalid operations in decode stage FIX: set signals not outputs in decode Change to use two regs arrays in register set to infer two port rams
63 lines
1.9 KiB
VHDL
63 lines
1.9 KiB
VHDL
----------------------------------------------------------------------------------
|
|
-- Project Name: RPU
|
|
-- Description: Program Counter unit of RPU
|
|
--
|
|
-- Simple black box for holding and manipulating the PC
|
|
--
|
|
----------------------------------------------------------------------------------
|
|
-- Copyright 2016,2018,2019,2020 Colin Riley
|
|
--
|
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
|
-- you may not use this file except in compliance with the License.
|
|
-- You may obtain a copy of the License at
|
|
--
|
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
|
--
|
|
-- Unless required by applicable law or agreed to in writing, software
|
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
-- See the License for the specific language governing permissions and
|
|
-- limitations under the License.
|
|
----------------------------------------------------------------------------------
|
|
library IEEE;
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
|
|
use IEEE.NUMERIC_STD.ALL;
|
|
|
|
library work;
|
|
use work.constants.all;
|
|
|
|
entity pc_unit is
|
|
Port (
|
|
I_clk : in STD_LOGIC;
|
|
I_nPC : in STD_LOGIC_VECTOR (XLENM1 downto 0);
|
|
I_nPCop : in STD_LOGIC_VECTOR (1 downto 0);
|
|
I_intVec: in STD_LOGIC;
|
|
O_PC : out STD_LOGIC_VECTOR (XLENM1 downto 0)
|
|
);
|
|
end pc_unit;
|
|
|
|
architecture Behavioral of pc_unit is
|
|
signal current_pc: std_logic_vector( XLENM1 downto 0) := ADDR_RESET;
|
|
begin
|
|
|
|
process (I_clk)
|
|
begin
|
|
if rising_edge(I_clk) then
|
|
case I_nPCop is
|
|
when PCU_OP_NOP => -- NOP, keep PC the same/halt
|
|
when PCU_OP_INC => -- increment
|
|
current_pc <= std_logic_vector(unsigned(current_pc) + 4); -- 32bit byte addressing
|
|
when PCU_OP_ASSIGN => -- set from external input
|
|
current_pc <= I_nPC;
|
|
when PCU_OP_RESET => -- Reset
|
|
current_pc <= ADDR_RESET;
|
|
when others =>
|
|
end case;
|
|
end if;
|
|
end process;
|
|
|
|
O_PC <= current_pc;
|
|
|
|
end Behavioral;
|
|
|