A pipelined RISC (Reduced Instruction Set Computer) processor implementation in VHDL, featuring a 4-stage pipeline architecture and non-preemptive interrupt handling.
This project implements a complete 16-bit RISC processor designed and simulated using Mentor Graphics ModelSim. The processor features a classic pipeline architecture with support for external interrupts, making it suitable for educational purposes and understanding fundamental computer architecture concepts.
- 16-bit Instruction Set: 27 instructions including arithmetic, logical, and load/store operations
- 4-Stage Pipeline Architecture: Fetch → Decode → Execute → WriteBack
- Interrupt Support: 4 external interrupt request lines with non-preemptive handling
- Memory Organization:
- 256 bytes of instruction memory (256 × 16-bit)
- 256 bytes of data memory (8-bit wide)
- 16 general-purpose 8-bit registers
- 8-bit Address Bus: All address buses are 8 bits wide
- Fetch Stage: Retrieves instructions from instruction memory using the program counter
- Decode Stage: Decodes instructions and handles interrupt requests
- Execute Stage: Performs arithmetic, logical, and control operations via ALU
- WriteBack Stage: Writes results back to registers or data memory
The processor supports 4 external interrupts (IRQ0-IRQ3) with dedicated Interrupt Service Routine (ISR) locations:
- IRQ0: ISR at address 128
- IRQ1: ISR at address 153
- IRQ2: ISR at address 178
- IRQ3: ISR at address 203
The interrupt handler uses a scratchpad memory to preserve CPU state (registers and program counter) during interrupt servicing.
VHDL-Project-16-bit-RISC-Processor/
├── VHDL code/
│ ├── fetch.vhd # Fetch stage
│ ├── instruction_memory.vhd # Instruction memory (256×16)
│ ├── pc.vhd # Program counter
│ ├── pcresolution.vhd # PC resolution logic
│ ├── fetdec.vhd # Fetch-Decode latch
│ ├── lafetch.vhd # Fetch latch
│ ├── decoder.vhd # Decoder stage
│ ├── combo.vhd # Combinational logic
│ ├── latchdec.vhd # Decode-Execute latch
│ ├── execute.vhd # Execute stage
│ ├── ram.vhd # Register bank
│ ├── aluvala.vhd # ALU
│ ├── laexec.vhd # Execute-WriteBack latch
│ ├── writeback.vhd # WriteBack stage
│ ├── MUX2_1.vhd # 2:1 Multiplexer
│ ├── data_mem.vhd # Data memory
│ ├── scratchpad.vhd # Interrupt handler scratchpad
│ ├── interrupttrail1.vhd # Top-level processor
│ └── pipelined1.vhd # Pipelined processor entity
├── Waveforms/ # Simulation waveforms
├── Project Report.pdf # Detailed project documentation
├── Top Level Block Diagram.jpg # Architecture diagram
└── README.md # This file
- Program Counter (pc.vhd): Increments on each clock cycle; can be modified by ALU or interrupt handler
- Instruction Memory (instruction_memory.vhd): 256×16-bit ROM storing program instructions
- Decoder (decoder.vhd): Decodes 16-bit instructions based on 4-bit opcode
- Scratchpad (scratchpad.vhd): Saves/restores CPU state during interrupt handling
- ALU (aluvala.vhd): Performs arithmetic and logical operations (ADD, SUB, INC, DEC, SHIFT, etc.)
- Register Bank (ram.vhd): 16 general-purpose 8-bit registers
- Data Memory (data_mem.vhd): 256×8-bit RAM for data storage
- Multiplexer (MUX2_1.vhd): Selects between direct and indirect addressing modes
- Mentor Graphics ModelSim (or compatible VHDL simulator)
- Basic understanding of VHDL and computer architecture
- Clone this repository
- Open ModelSim and create a new project
- Add all VHDL files from the
VHDL code/directory - Compile the files in the following order:
- Basic components (RAM, ALU, MUX, memories)
- Pipeline stage components
- Latches
- Top-level entities
- Load the testbench and run the simulation
- View waveforms to verify functionality
The processor supports 27 instructions including:
- Arithmetic: ADD, SUB, INC, DEC
- Logical: AND, OR, XOR, NOT
- Shift: SHL, SHR
- Data Transfer: LOAD, STORE (direct and indirect)
- Control: JUMP, JZ (Jump if Zero), JNZ (Jump if Not Zero)
- Special: SET, CLEAR, PUSH, POP
Refer to Project Report.pdf for complete instruction set details
All project requirements have been met and verified through simulation:
- ✅ 16-bit instruction set implemented
- ✅ 4-stage pipeline functioning correctly
- ✅ 4 external interrupts handled properly
- ✅ Non-preemptive interrupt handling verified
- ✅ Register bank operations validated
- ✅ Memory access confirmed
Simulation waveforms are available in the Waveforms/ directory.
Houssem-eddine Lahmer
This project is available for educational purposes.
- Designed as part of a digital systems design course
- Simulated using Mentor Graphics ModelSim