The simulated 64-bit Arm CPU was written in SystemVerilog.
Go to file
Eric Yu 1175313fbd more generalized sim.do 2024-09-12 21:06:53 -07:00
documents Upload files to "documents" 2024-01-18 21:49:37 +00:00
src more generalized sim.do 2024-09-12 21:06:53 -07:00
tools more generalized sim.do 2024-09-12 21:06:53 -07:00
.gitignore add files 2023-12-23 18:41:58 -08:00
README.md more generalized sim.do 2024-09-12 21:06:53 -07:00

README.md

Simple ARM-compliant CPU

Introduction

A simple 64-bit ARM CPU with Pipelining. The pipelined CPU will have 1 delay slot after each load and branch instruction. The CPU instructions to be implemented are listed below. The data memory and instruction memory modules are provided in the files “datamem.sv” and “instructmem.sv” respectively. To simulate the CPU, head over to "tools/sim" irectory. Change the program loaded by editing the filename specified in “instructmem.sv”

Instruction set:

ADDI Rd, Rn, Imm12: Reg[Rd] = Reg[Rn] + ZeroExtend(Imm12). 
ADDS Rd, Rn, Rm: Reg[Rd] = Reg[Rn] + Reg[Rm].  Set flags. 
B Imm26: PC = PC + SignExtend(Imm26 << 2). 
B.LT Imm19: If (flags.negative != flags.overflow) PC = PC + SignExtend(Imm19<<2). 
BL Imm26: X30 = PC + 4 (instruction after this one), PC = PC + SignExtend(Imm26<<2). 
BR Rd: PC = Reg[Rd]. 
CBZ Rd, Imm19: If (Reg[Rd] == 0) PC = PC + SignExtend(Imm19<<2). 
LDUR Rd, [Rn, #Imm9]: Reg[Rd] = Mem[Reg[Rn] + SignExtend(Imm9)]. 
For lab #4 (only) the value in rd cannot be used in the next cycle. 
STUR Rd, [Rn, #Imm9]: Mem[Reg[Rn] + SignExtend(Imm9)] = Reg[Rd]. 
SUBS Rd, Rn, Rm: Reg[Rd] = Reg[Rn] - Reg[Rm].  Set flags.

How to simulate

  1. Navigate to the tools\sim\runs directory.
  2. Edit bench_path in sim.do to point to the desired benchmark (vector) file.
  3. Run the simulation by executing vsim -c -do sim.do -l vsim.log in the terminal.

To debug in waveform, run command

modelsim -view vsim.wlf -do <path\to\optional\wave.do>

where <path\to\optional\wave.do> is the path to the .do file containing the waveform settings. There are some in the tools\sim\waves directory.