|
| 1 | +# Vector - 8 |
| 2 | + |
| 3 | +This project implements a custom **8-bit Soft-Core CPU** on the Vicharak's **Shrike Lite** board. It serves as a hands-on introduction to Computer Architecture. |
| 4 | + |
| 5 | +Expanding upon the Vector-4 architecture, this CPU doubles the data width and significantly expands the instruction set while maintaining a compact footprint under **140 CLBs**. It is controlled entirely via **SPI**, where the RP2040 acts as the master, sending 16-bit instruction packets and single-stepping the execution. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## System Architecture |
| 10 | + |
| 11 | +The system follows a hybrid controller-target design: |
| 12 | +* **RP2040 (Master):** Manages high-level logic, instruction sequencing, and user interface. |
| 13 | +* **FPGA (Slave):** Contains the 8-bit CPU core (Accumulator-based), ALU, and status registers. |
| 14 | + |
| 15 | +### Specifications |
| 16 | +| Feature | Detail | |
| 17 | +| :--- | :--- | |
| 18 | +| **Data Width** | 8-bit (Full Byte) | |
| 19 | +| **Instruction Set** | 32-ISA (5-bit Opcodes) | |
| 20 | +| **Clocking** | Manual Stepping via SPI (Synchronous to FPGA System Clock) | |
| 21 | +| **Interface** | 16-bit SPI Protocol (Double-Byte Packet) | |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +<img width="2816" height="1504" alt="8-bit_cpu" src="https://github.com/user-attachments/assets/f5d97bca-0007-4263-ad65-2c8b7dee1aeb" /> |
| 26 | + |
| 27 | +## The SPI Interface |
| 28 | + |
| 29 | +To interact with the 8-bit core, the RP2040 sends **16-bit packets** (two 8-bit transfers). The FPGA assembles these into a single instruction and executes it on the rising edge of the internal step signal. |
| 30 | + |
| 31 | +### Input Packet (RP2040 -> FPGA) |
| 32 | +The instruction is sent across two bytes. |
| 33 | + |
| 34 | +**Byte 1: Command** |
| 35 | +| Bit [7:5] | Bit [4:0] | |
| 36 | +| :---: | :---: | |
| 37 | +| **Unused** | **OPCODE** | |
| 38 | +| - | 5-bit Instruction Identifier | |
| 39 | + |
| 40 | +**Byte 2: Data** |
| 41 | +| Bit [7:0] | |
| 42 | +| :---: | |
| 43 | +| **OPERAND / DATA** | |
| 44 | +| 8-bit Immediate Value or Address | |
| 45 | + |
| 46 | +### Output Packet (FPGA -> RP2040) |
| 47 | +The FPGA replies with the current state of the Accumulator for verification. Because the SPI transfer occurs simultaneously with execution, the MISO line returns the result of the *previous* instruction. |
| 48 | +| Bit [7:0] | |
| 49 | +| :---: | |
| 50 | +| **ACC (Accumulator Value)** | |
| 51 | +| Current 8-bit result of the previous operation | |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Instruction Set Architecture (ISA) |
| 56 | + |
| 57 | +The CPU supports an expanded set of 32 operations. Below are the primary validated opcodes. |
| 58 | + |
| 59 | +| Opcode | Name | Description | |
| 60 | +| :--- | :--- | :--- | |
| 61 | +| `0x00` | **NOP** | No Operation | |
| 62 | +| `0x01` | **LDA** | Load Accumulator with 8-bit Data | |
| 63 | +| `0x02` | **ADD** | `Acc = Acc + Data` | |
| 64 | +| `0x03` | **SUB** | `Acc = Acc - Data` | |
| 65 | +| `0x04` | **AND** | Bitwise AND | |
| 66 | +| `0x05` | **OR** | Bitwise OR | |
| 67 | +| `0x06` | **XOR** | Bitwise XOR | |
| 68 | +| `0x07` | **LSL** | Logical Shift Left | |
| 69 | +| `0x08` | **LSR** | Logical Shift Right | |
| 70 | +| `0x09` | **ROL** | Rotate Left | |
| 71 | +| `0x0A` | **ROR** | Rotate Right | |
| 72 | +| `0x0B` | **INC** | `Acc = Acc + 1` | |
| 73 | +| `0x0C` | **DEC** | `Acc = Acc - 1` | |
| 74 | +| `0x0D` | **JMP** | Jump to Address (Update PC) | |
| 75 | +| `0x0E` | **JZ** | Jump to Address if Zero Flag is High | |
| 76 | +| `0x0F` | **JNZ** | Jump to Address if Zero Flag is Low | |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## Hardware Connections |
| 81 | + |
| 82 | +### Top Module Interface |
| 83 | +These signals correspond to the top-level Verilog module (`top.v`). |
| 84 | + |
| 85 | +| Signal | Direction | Description | |
| 86 | +|---------------|-----------|----------------------------------------------| |
| 87 | +| `clk` | In | System clock (50 MHz typical) | |
| 88 | +| `clk_en` | Out | Clock enable (always 1) | |
| 89 | +| `rst_n` | In | Reset Pin (active low) | |
| 90 | +| `spi_ss_n` | In | Input target select signal (active low) | |
| 91 | +| `spi_sck` | In | Input SPI clock signal | |
| 92 | +| `spi_mosi` | In | Input from controller (Master Out) | |
| 93 | +| `spi_miso` | Out | Output to controller (Master In) | |
| 94 | + |
| 95 | +### Pin Mapping Table |
| 96 | + |
| 97 | +| Signal Function | FPGA Pin (GPIO) | RP2040 Pin | Direction | |
| 98 | +| :--- | :---: | :---: | :--- | |
| 99 | +| **SPI Clock** | 3 | 2 | RP2040 Output -> FPGA Input | |
| 100 | +| **Chip Select** | 4 | 1 | RP2040 Output -> FPGA Input | |
| 101 | +| **MOSI** | 5 | 3 | RP2040 Output -> FPGA Input | |
| 102 | +| **MISO** | 6 | 0 | FPGA Output -> RP2040 Input | |
| 103 | +| **Reset** | 18 | 14 | RP2040 Output -> FPGA Input | |
0 commit comments