Design of a simple 32-bit processor that is connected to a separate instruction and data memory using Verilog
Tento projekt vznikl jako jedna ze semestrálních prací v předmětu Architektury počítačových systémů v rámci mého studia na FIT ČVUT
Cílem semestrální práce byl návrh mikroarchitektury jednocyklového 32-bitového procesoru v jazyce Verilog s předem určenými instrukcemi a ukázkovým programem. Součástí projektu není implementace instrukční ani datové paměti. Procesor obsahuje instrukce definované níže, dále byl součástí projektu program (soubor prog1.asm), který na předdefinované pole čísel aplikoval operaci (int)floor(log2(rs1)) pomocí speciálně zadané instrukce floor_log. Jelikož tato instrukce není součástí žádné rozšířené mikroarchitektury, bylo třeba jednotlivé instrukce přeložit do strojového kódu ručně (soubor prog1.hex).
This project was created as a semester project for the Architectures of Computer Systems course during my studies at FIT CTU
The goal of the semester project was to design the microarchitecture of a single-cycle 32-bit processor in Verilog with predefined instructions and a sample program. The project does not include the implementation of instruction or data memory. The processor contains the instructions defined below, and the project also included a program (file prog1.asm) that applied the following operation (int)floor(log2(rs1)) to a predefined array of numbers using a specially defined instruction floor_log. Since this instruction is not part of any well known microarchitecture, the individual instructions had to be manually assembled into machine code (file prog1.hex).
| Instruction | Syntax | Operation | Notes |
|---|---|---|---|
add |
add rd, rs1, rs2 |
rd <- [rs1] + [rs2] |
|
addi |
addi rd, rs1, imm |
rd <- [rs1] + imm |
imm is a 12-bit immediate value |
and |
and rd, rs1, rs2 |
rd <- [rs1] & [rs2] |
Bitwise AND operation |
sub |
sub rd, rs1, rs2 |
rd <- [rs1] - [rs2] |
|
srl |
srl rd, rs1, rs2 |
rd <- (unsigned) [rs1] >> [rs2] |
Logical right shift |
beq |
beq rs1, rs2, imm |
if [rs1] == [rs2] then PC <- PC + imm else PC <- PC + 4 |
Branch if equal |
blt |
blt rs1, rs2, imm |
if [rs1] < [rs2] then PC <- PC + imm else PC <- PC + 4 |
Branch if less than (signed comparison) |
lw |
lw rd, imm(rs1) |
rd <- Memory[[rs1] + imm] |
Load word from memory |
sw |
sw rs2, imm(rs1) |
Memory[[rs1] + imm] <- [rs2] |
Store word to memory |
lui |
lui rd, imm |
rd <- {imm << 12} |
Load upper immediate |
jal |
jal rd, imm |
rd <- PC + 4; PC <- PC + imm |
Jump and link |
jalr |
jalr rd, rs1, imm |
rd <- PC + 4; PC <- [rs1] + imm |
Jump and link register |
floor_log |
floor_log rd, rs1 |
rd <- (int)floor(log2(rs1)) |
The content of register rs1 is treated as a non-zero, positive 32-bit floating-point number in normalized form. The result in register rd is an integer in two's complement. floor() is the floor function, and log2() is the base-2 logarithm. |
- Include processor design (building blocks) image
- Description of said building blocks
- Include gtkwave screenshots of program
prog1