I have created a run_tests.do script and updated the assembler to support your test cases.
- Integrated Workflow: The run_tests.do script handles compilation, assembly, and simulation in one go.
- Enhanced Assembler:
- Supports Hex numbers by default (
--hexflag). - Supports
#and//comments. - Implements macro for
JMP Rx->PUSH Rx; RET. - Supports
INT0/INT1aliases. - Supports 32-bit immediates for
LDM.
- Supports Hex numbers by default (
- Load the script:
do simulation/scripts/run_tests.do
- Run a specific test case:
Available tests:
run_test "Branch.asm"Branch.asm,BranchPrediction.asm,Memory.asm,OneOperand.asm,TwoOperand.asm.
vsim -do simulation/scripts/run_tests.doThe run_test command will run the simulation for a set duration. You should inspect the Wave window to verify the results against the expected values found in the ASM comments.
Goal: Test basic ALU operations (NOT, INC) and Input/Output. Expected Results:
- R1: Starts at
FFFF, increments to0000(overflow), input000E. - R2: Input
0010, NOT becomesFFEF. - Final Output (R2):
FFEA.
Goal: Test MOV, SWAP, ADD, SUB, AND. Expected Results:
- R4:
F322+0006(from input) =F328. - R6:
FFFE-F328=0CD6. - SWAP R6, R1:
R1becomes0CD6,R6becomes0006(from prev R1). - MOV R1, R3: R3 gets overwritten? No, syntax is MOV Src, Dst or Dst, Src?
- Note: Project ISA usually defines
MOV Rsrc, Rdst-> Rdst = Rsrc. - ASM comment says
R1, R3 #R3=0000000. This suggestsMOV Rdst, Rsrcsyntax orMOV Rsrc, Rdst. - Let's check
opcode_decoder.vhd:MOV Rsrc1, Rdst: Rdst = Rsrc1. - So
MOV R1, R3meansR3 = R1. - Wait, comment says
#R3=0000000. IfR1was0006(from SWAP), thenR3should be0006. - Correction: The comment says
R3=0000000. MaybeR1was 0? - Ah,
SWAP R6, R1. Previous R1 was0006(from input). R6 was0CD6. - After SWAP: R6=
0006, R1=0CD6. MOV R1, R3.R3 = R1->R3 = 0CD6.- Verify this in simulation.
- Note: Project ISA usually defines
Goal: Test JMP, JZ, CALL, RET, INT, RTI, Forwarding with Branches. Expected Results:
- INT0 (Address 800):
R0becomes0. OutputR6. - INT1 (Address A00): Output
R1. - Main Program:
JZ 50: Should be NOT TAKEN? Comment says "Jump Not taken".JZ 400: Should be TAKEN.CALL 300:SPdecrements,PC(return addr) pushed.- Inside
300:ADDoperations, thenRET. RET: Pop PC, return to400.
- Final Checks: Look for
R7increments - they should NOT execute if jumps work correctly.
Goal: Test LDM (32-bit), PUSH, POP, STD, LDD. Expected Results:
- LDM: Check
R2=0010FE19,R3=0021FFFF,R4=00E5F320. - Stack:
PUSHR1, R2. Check Memory at3FFFF,3FFFE. - POP: Restore R1, R2 flipped.
- STD/LDD:
STD R2, 50(R0): StoreFFF5at10200(101B0+50).- Check Memory
10200=0010FE19? No, check register values.
- Forwarding in MEM:
STD R3, 0(R4)immediately followingLDD.
Goal: Test Branch Prediction Logic (if implemented). Expected Results:
- Loops
JMP 20. OUT R4: Should see sequence2, 4, 8, 10, ....JZ 60: Jump ifR0 < R2.
simulation/scripts/run_tests.do: Main automation script.src/assembler/assembler.py: Updated python assembler.