Commits

David Lin committed b2cf906

Fibonacci Tested

Comments (0)

Files changed (4)

project1/Makefile

 run: CPU
 	@vvp CPU
 
-SOURCES := source/*.v
+SOURCES := code/*.v
 
 CPU: $(SOURCES)
-	iverilog -I source -o $@ $^
+	iverilog -I code -o $@ $^
 
 clean:
 	rm -f CPU output.txt

project1/code/benchmark.v

   
   always @ (negedge clock)
   begin
-    if (counter >= 19)
+    //if (counter >= 128)
+    //  $finish;
+    if ((cpu.PC.pc_o>>2) >= cpu.IMem.SIZE)
       $finish;
     
     $fdisplay(outfile, "cycle = %d, Start = %d, Stall = %d, Flush = %d", 

project1/instruction.txt

-000000_00000_00000_01000_00000_100000 //PC= 0  add $t0,$0,$0
-001000_00000_01001_0000000000001010   //PC= 4  addi $t1,$0,10
-101011_01000_00000_0000000000000000   //PC= 8  sw $0,0($t0)
-101011_01000_01001_0000000000000100   //PC=12  sw $t1,4($t0)
-100011_01000_01101_0000000000000100   //PC=16  lw $t5,4($t0)
-000000_01101_01001_01111_00000_100000 //PC=20  add $t7,$t5,$t1  (hazard!)  
-001000_00000_01010_0000000000001101   //PC=24  addi $t2,$0,13   (stall 1 cycle)
-000000_01001_01001_01011_00000_011000 //PC=28  mul $t3,$t1,$t1
-000010_00000000000000000000001011     //PC=32  j Jump
-001000_01001_01001_0000000000000001   //PC=36  addi $t1,$t1,1   (flush)
-001000_01001_01001_0000000000000001   //PC=40  addi $t1,$t1,1
-000000_01010_01001_01010_00000_100010 //PC=44  Jump: sub $t2,$t2,$t1
-000000_01001_01010_01011_00000_100100 //PC=48  and $t3,$t1,$t2
-000000_01010_01011_01100_00000_100101 //PC=52  or $t4,$t2,$t3
-
-//001000_01001_01001_0000000000001010   //PC= 0  addi $t1,$t1,10
-//001000_01001_01001_1111111111111111   //PC= 4  Loop: addi $t1,$t1,-1
-//000000_00000_00000_00000_00000_000000 //PC= 8  nop
-//000000_00000_00000_00000_00000_000000 //PC=12  nop
-//000000_00000_00000_00000_00000_000000 //PC=16  nop
-//000000_00000_00000_00000_00000_000000 //PC=20  nop
-//000100_01001_00000_1111111111111000   //PC=24  beq $t1,$0,Loop
-//001000_01010_01010_0000000000001010   //PC=28  addi $t2,$t2,10
-
-//000100_01000_01000_0000000000000010   //PC= 0  beq $t0,$t0, Label
-//001000_01001_01001_0000000000001010   //PC= 4  addi $t1,$t1,10
-//001000_01001_01001_0000000000001010   //PC= 8  addi $t1,$t1,10
-//001000_01001_01001_0000000000001010   //PC=12  Label: addi $t1,$t1,10
-
-//000000_00000_00000_00000_00000_000000 //PC= 0  nop
-
-//000010_00000000000000000000000011     //PC= 0  j Label
-//001000_01001_01001_0000000000001010   //PC= 4  addi $t1,$t1,10
-//001000_01001_01001_0000000000001010   //PC= 8  addi $t1,$t1,10
-//001000_01001_01001_0000000000000101   //PC=12  Label: addi $t1,$t1,5
-
-//100011_00000_01001_0000000000000000   //PC= 0  lw $t1,0($0)
-//001000_01001_01010_0000000000001010   //PC= 4  addi $t2,$t1,10
-
-//001000_00000_01001_0000000000001010   //PC= 0  addi $t1,$0,10
-//001000_01001_01001_0000000000001010   //PC= 4  addi $t1,$t1,10
-//001000_01001_01001_0000000000001010   //PC= 8  addi $t1,$t1,10
-//001000_01001_01001_0000000000001010   //PC=12  addi $t1,$t1,10
-
-//001000_00000_01000_0000000000000100   //PC= 0  addi $t0,$0,4
-//001000_00000_01001_0000000000001010   //PC= 4  addi $t1,$0,10
-//000000_01001_01000_01010_00000_100000 //PC= 8  add $t2,$t1,$t0
-//101011_00000_01000_0000000000000000   //PC=12  sw $t0,0($0)
-//101011_00000_01001_0000000000000100   //PC=16  sw $t1,4($0)
-//101011_00000_01010_0000000000001000   //PC=20  sw $t2,8($0)
-
+001000_00000_00100_0000000000000000   //  0: addi $a0, $0, 0
+001000_00000_01000_0000000000000000   //  4: addi $t0, $0, 0
+001000_00000_01001_0000000000000001   //  8: addi $t1, $0, 1
+001000_00000_10001_0000000000000000   // 12: addi $s1, $0, 0
+001000_00000_10010_0000000000000001   // 16: addi $s2, $0, 1
+
+100011_00100_10000_0000000000000000   // 20: lw $s0, 0($a0)
+001000_10000_10100_0000000000000000   // 24: addi $s4, $s0, 0
+
+000000_10000_01001_10000_00000_100010 // 28: loop: sub $s0, $s0, $t1
+000000_10001_10010_10001_00000_100000 // 32: add $s1, $s1, $s2
+001000_10010_10011_0000000000000000 // 36: addi $s3, $s2, 0
+001000_10001_10010_0000000000000000 // 40: addi $s2, $s1, 0
+001000_10011_10001_0000000000000000 // 44: addi $s1, $s3, 0
+000100_01000_10000_0000000000000001 // 48: beq $s0, $t0, finish
+000010_00000000000000000000000111 // 52: j loop
+101011_00100_10001_0000000000000100 // 56: finish: sw $s1, 4($a0)
+
+000000_10001_00000_01010_00000_100100 // 60: and $t2, $s1, $0
+000000_10001_00000_01011_00000_100101 // 64: or $t3, $s1, $0
+000000_10001_01100_01100_00000_100000 // 68: add $t4, $s1, $t4
+000000_10001_01100_01101_00000_100010 // 72: sub $t5, $s1, $t4
+000000_10001_01100_01110_00000_011000 // 76: mul $t6, $s1, $t4
+101011_00100_01010_0000000000001000 // 80: sw $t2, 8($a0)
+101011_00100_01011_0000000000001100 // 84: sw $t3, 12($a0)
+101011_00100_01100_0000000000010000 // 88: sw $t4, 16($a0)
+101011_00100_01101_0000000000010100 // 92: sw $t5, 20($a0)
+101011_00100_01110_0000000000011000 // 96: sw $t6, 24($a0)

project1/test.txt

+000000_00000_00000_01000_00000_100000 //PC= 0  add $t0,$0,$0
+001000_00000_01001_0000000000001010   //PC= 4  addi $t1,$0,10
+101011_01000_00000_0000000000000000   //PC= 8  sw $0,0($t0)
+101011_01000_01001_0000000000000100   //PC=12  sw $t1,4($t0)
+100011_01000_01101_0000000000000100   //PC=16  lw $t5,4($t0)
+000000_01101_01001_01111_00000_100000 //PC=20  add $t7,$t5,$t1  (hazard!)  
+001000_00000_01010_0000000000001101   //PC=24  addi $t2,$0,13   (stall 1 cycle)
+000000_01001_01001_01011_00000_011000 //PC=28  mul $t3,$t1,$t1
+000010_00000000000000000000001011     //PC=32  j Jump
+001000_01001_01001_0000000000000001   //PC=36  addi $t1,$t1,1   (flush)
+001000_01001_01001_0000000000000001   //PC=40  addi $t1,$t1,1
+000000_01010_01001_01010_00000_100010 //PC=44  Jump: sub $t2,$t2,$t1
+000000_01001_01010_01011_00000_100100 //PC=48  and $t3,$t1,$t2
+000000_01010_01011_01100_00000_100101 //PC=52  or $t4,$t2,$t3
+
+//001000_01001_01001_0000000000001010   //PC= 0  addi $t1,$t1,10
+//001000_01001_01001_1111111111111111   //PC= 4  Loop: addi $t1,$t1,-1
+//000000_00000_00000_00000_00000_000000 //PC= 8  nop
+//000000_00000_00000_00000_00000_000000 //PC=12  nop
+//000000_00000_00000_00000_00000_000000 //PC=16  nop
+//000000_00000_00000_00000_00000_000000 //PC=20  nop
+//000100_01001_00000_1111111111111000   //PC=24  beq $t1,$0,Loop
+//001000_01010_01010_0000000000001010   //PC=28  addi $t2,$t2,10
+
+//000100_01000_01000_0000000000000010   //PC= 0  beq $t0,$t0, Label
+//001000_01001_01001_0000000000001010   //PC= 4  addi $t1,$t1,10
+//001000_01001_01001_0000000000001010   //PC= 8  addi $t1,$t1,10
+//001000_01001_01001_0000000000001010   //PC=12  Label: addi $t1,$t1,10
+
+//000000_00000_00000_00000_00000_000000 //PC= 0  nop
+
+//000010_00000000000000000000000011     //PC= 0  j Label
+//001000_01001_01001_0000000000001010   //PC= 4  addi $t1,$t1,10
+//001000_01001_01001_0000000000001010   //PC= 8  addi $t1,$t1,10
+//001000_01001_01001_0000000000000101   //PC=12  Label: addi $t1,$t1,5
+
+//100011_00000_01001_0000000000000000   //PC= 0  lw $t1,0($0)
+//001000_01001_01010_0000000000001010   //PC= 4  addi $t2,$t1,10
+
+//001000_00000_01001_0000000000001010   //PC= 0  addi $t1,$0,10
+//001000_01001_01001_0000000000001010   //PC= 4  addi $t1,$t1,10
+//001000_01001_01001_0000000000001010   //PC= 8  addi $t1,$t1,10
+//001000_01001_01001_0000000000001010   //PC=12  addi $t1,$t1,10
+
+//001000_00000_01000_0000000000000100   //PC= 0  addi $t0,$0,4
+//001000_00000_01001_0000000000001010   //PC= 4  addi $t1,$0,10
+//000000_01001_01000_01010_00000_100000 //PC= 8  add $t2,$t1,$t0
+//101011_00000_01000_0000000000000000   //PC=12  sw $t0,0($0)
+//101011_00000_01001_0000000000000100   //PC=16  sw $t1,4($0)
+//101011_00000_01010_0000000000001000   //PC=20  sw $t2,8($0)
+