@@ -10,76 +10,76 @@ class MainSpec extends AnyFreeSpec with Matchers with ChiselSim {
1010
1111 " main should pass tests" in {
1212 simulate(new Main ()) { dut =>
13- // BEFORE WRITING
14- dut.io.instruction.poke(" b00000000000000000000000011111111" .U (32 .W )) // print contents of register 1 instruction for debugging
15- dut.io.RegFileA_out .expect(0 .U )
16- dut.io.RegFileB_out .expect(0 .U )
13+ // // BEFORE WRITING
14+ // dut.io.instruction.poke("b00000000000000000000000011111111".U(32.W)) // print contents of register 1 instruction for debugging
15+ // dut.io.RegFileA_out.expect(0.U)
16+ // dut.io.RegFileB_out.expect(0.U)
1717
18- // Test LUI instruction: lui x1,
19- val lui_instruction = " b00000000000000000001000010110111" .U (32 .W ) // opcode for LUI with rd = x1 and imm = b00000000000000000001 (in decimal: 1)
18+ // // Test LUI instruction: lui x1,
19+ // val lui_instruction = "b00000000000000000001000010110111".U(32.W) // opcode for LUI with rd = x1 and imm = b00000000000000000001 (in decimal: 1)
2020
21- // Attempt loading LUI instruction
22- dut.io.instruction.poke(lui_instruction) // Load the immediate into register x1
21+ // // Attempt loading LUI instruction
22+ // dut.io.instruction.poke(lui_instruction) // Load the immediate into register x1
2323
24- dut.clock.step(1 ) // Step clock to process instruction. Next clock cycle is when the register updates with the write
24+ // dut.clock.step(1) // Step clock to process instruction. Next clock cycle is when the register updates with the write
2525
26- // AFTER WRITING
27- dut.io.instruction.poke(" b00000000000000000000000011111111" .U (32 .W )) // print contents of register 1 instruction for debugging
28- dut.io.RegFileA_out .expect(" b00000000000000000001000000000000" .U (32 .W )) // Expecting imm << 12
29- dut.io.RegFileB_out .expect(" b00000000000000000001000000000000" .U (32 .W ))
26+ // // AFTER WRITING
27+ // dut.io.instruction.poke("b00000000000000000000000011111111".U(32.W)) // print contents of register 1 instruction for debugging
28+ // dut.io.RegFileA_out.expect("b00000000000000000001000000000000".U(32.W)) // Expecting imm << 12
29+ // dut.io.RegFileB_out.expect("b00000000000000000001000000000000".U(32.W))
3030
31- // BEFORE WRITING
32- dut.io.instruction.poke(" b000000000000000000000000101111111" .U (32 .W )) // print contents of register 2 instruction for debugging
33- dut.io.RegFileA_out .expect(0 .U )
34- dut.io.RegFileB_out .expect(0 .U )
31+ // // BEFORE WRITING
32+ // dut.io.instruction.poke("b000000000000000000000000101111111".U(32.W)) // print contents of register 2 instruction for debugging
33+ // dut.io.RegFileA_out.expect(0.U)
34+ // dut.io.RegFileB_out.expect(0.U)
3535
36- // Test ADDI instruction: addi x2, x1, b000000000001 (1 in decimal)
37- // b00000000000000000001000000000000 + b000000000000000000000000000001 = b00000000000000000001000000000001
38- val addi_instruction = " b00000000000100001000000100010011" .U (32 .W ) // opcode for ADDI with rd = x2, rs1 = x1, imm = b000000000001 (1 in decimal)
39- dut.io.instruction.poke(addi_instruction) // Load the ADDI instruction
40- dut.clock.step(1 ) // Step clock to process instruction. Next clock cycle is when the register updates with the write
36+ // // Test ADDI instruction: addi x2, x1, b000000000001 (1 in decimal)
37+ // // b00000000000000000001000000000000 + b000000000000000000000000000001 = b00000000000000000001000000000001
38+ // val addi_instruction = "b00000000000100001000000100010011".U(32.W) // opcode for ADDI with rd = x2, rs1 = x1, imm = b000000000001 (1 in decimal)
39+ // dut.io.instruction.poke(addi_instruction) // Load the ADDI instruction
40+ // dut.clock.step(1) // Step clock to process instruction. Next clock cycle is when the register updates with the write
4141
42- // AFTER WRITING
43- dut.io.instruction.poke(" b000000000000000000000000101111111" .U (32 .W )) // print contents of register 2 instruction for debugging
44- dut.io.RegFileA_out .expect(" b00000000000000000001000000000001" .U (32 .W )) // Expecting result of addition
45- dut.io.RegFileB_out .expect(" b00000000000000000001000000000001" .U (32 .W ))
42+ // // AFTER WRITING
43+ // dut.io.instruction.poke("b000000000000000000000000101111111".U(32.W)) // print contents of register 2 instruction for debugging
44+ // dut.io.RegFileA_out.expect("b00000000000000000001000000000001".U(32.W)) // Expecting result of addition
45+ // dut.io.RegFileB_out.expect("b00000000000000000001000000000001".U(32.W))
4646
47- // prepare for SLTI test
48- val lui_instruction_2 = " b00000000000000000000000010110111" .U (32 .W ) // opcode for LUI with rd = x1 and imm = b00000000000000000000 (in decimal: 0)
49- dut.io.instruction.poke(lui_instruction_2) // Load the immediate into register x1
50- dut.clock.step(1 ) // Step clock to process instruction. Next clock cycle is when the register updates with the write
51- val addi_instruction_2 = " b00000000001100001000001010010011" .U (32 .W ) // opcode for ADDI with rd = x5, rs1 = x1, imm = b000000000011 (3 in decimal)
52- dut.io.instruction.poke(addi_instruction) // Load the ADDI instruction
53- dut.clock.step(1 ) // Step clock to process instruction. Next clock cycle is when the register updates with the write
54- // Now x1 should be 3
47+ // // prepare for SLTI test
48+ // val lui_instruction_2 = "b00000000000000000000000010110111".U(32.W) // opcode for LUI with rd = x1 and imm = b00000000000000000000 (in decimal: 0)
49+ // dut.io.instruction.poke(lui_instruction_2) // Load the immediate into register x1
50+ // dut.clock.step(1) // Step clock to process instruction. Next clock cycle is when the register updates with the write
51+ // val addi_instruction_2 = "b00000000001100001000001010010011".U(32.W) // opcode for ADDI with rd = x5, rs1 = x1, imm = b000000000011 (3 in decimal)
52+ // dut.io.instruction.poke(addi_instruction) // Load the ADDI instruction
53+ // dut.clock.step(1) // Step clock to process instruction. Next clock cycle is when the register updates with the write
54+ // // Now x1 should be 3
5555
56- // verify x1 is 3
57- dut.io.instruction.poke(" b000000000000000000000001011111111" .U (32 .W )) // print contents of register 5 instruction for debugging
58- dut.io.RegFileA_out .expect(3 .U (32 .W )) // Expecting 3
59- dut.io.RegFileB_out .expect(3 .U (32 .W ))
56+ // // verify x1 is 3
57+ // dut.io.instruction.poke("b000000000000000000000001011111111".U(32.W)) // print contents of register 5 instruction for debugging
58+ // dut.io.RegFileA_out.expect(3.U(32.W)) // Expecting 3
59+ // dut.io.RegFileB_out.expect(3.U(32.W))
6060
61- // TEST SLTI instruction: slti x3, x1, 5
62- // x1 = b00000000000000000000000000000011 (3 in decimal)
63- // Since 1 < 3 is true, x3 should be set to 1
64- val slti_instruction = " b00000000010100001010000110010011" .U (32 .W ) // opcode for SLTI with rd = x3, rs1 = x1, imm = 5
65- dut.io.instruction.poke(slti_instruction) // Load the SLTI instruction
66- dut.clock.step(1 ) // Step clock to process instruction
61+ // // TEST SLTI instruction: slti x3, x1, 5
62+ // // x1 = b00000000000000000000000000000011 (3 in decimal)
63+ // // Since 1 < 3 is true, x3 should be set to 1
64+ // val slti_instruction = "b00000000010100001010000110010011".U(32.W) // opcode for SLTI with rd = x3, rs1 = x1, imm = 5
65+ // dut.io.instruction.poke(slti_instruction) // Load the SLTI instruction
66+ // dut.clock.step(1) // Step clock to process instruction
6767
68- // AFTER WRITING
69- dut.io.instruction.poke(" b000000000000000000000000111111111" .U (32 .W )) // print contents of register 3 instruction for debugging
70- dut.io.RegFileA_out .expect(1 .U ) // Expecting 1 since 1 < 3 is true
71- dut.io.RegFileB_out .expect(1 .U )
68+ // // AFTER WRITING
69+ // dut.io.instruction.poke("b000000000000000000000000111111111".U(32.W)) // print contents of register 3 instruction for debugging
70+ // dut.io.RegFileA_out.expect(1.U) // Expecting 1 since 1 < 3 is true
71+ // dut.io.RegFileB_out.expect(1.U)
7272
73- // x1 = b00000000000000000000000000000001 (1 in decimal)
74- // Since 1 < 3 is true, x3 should be set to 1
75- val slti_instruction_2 = " b00000000000100001010001000010011" .U (32 .W ) // opcode for SLTI with rd = x4, rs1 = x1, imm = 1
76- dut.io.instruction.poke(slti_instruction_2) // Load the SLTI instruction
77- dut.clock.step(1 ) // Step clock to process instruction
73+ // // x1 = b00000000000000000000000000000001 (1 in decimal)
74+ // // Since 1 < 3 is true, x3 should be set to 1
75+ // val slti_instruction_2 = "b00000000000100001010001000010011".U(32.W) // opcode for SLTI with rd = x4, rs1 = x1, imm = 1
76+ // dut.io.instruction.poke(slti_instruction_2) // Load the SLTI instruction
77+ // dut.clock.step(1) // Step clock to process instruction
7878
79- // AFTER WRITING
80- dut.io.instruction.poke(" b000000000000000000000001001111111" .U (32 .W )) // print contents of register 4 instruction for debugging
81- dut.io.RegFileA_out .expect(1 .U ) // Expecting 1 since 1 < 3 is true
82- dut.io.RegFileB_out .expect(1 .U )
79+ // // AFTER WRITING
80+ // dut.io.instruction.poke("b000000000000000000000001001111111".U(32.W)) // print contents of register 4 instruction for debugging
81+ // dut.io.RegFileA_out.expect(1.U) // Expecting 1 since 1 < 3 is true
82+ // dut.io.RegFileB_out.expect(1.U)
8383 }
8484 }
8585}
0 commit comments