Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datapath #2

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore : simulation works, added READMEs for reproducing both sim and syn
  • Loading branch information
Vincenzo-Petrolo committed Jun 8, 2022
commit 81bf985f4d1b99bb910ba16bd5c1f83789a485e7
Binary file added sim/.bin
Binary file not shown.
47 changes: 47 additions & 0 deletions sim/.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
line address contents
1 00000000 20010051 addi r1, r0, #81
2 00000004 20020009 addi r2, r0, #9
3 00000008 0c000014 jal proc_iterative_division
4 0000000c 54000000 nop
5 00000010 54000000 nop
6 00000014 after_division_proc:
7 00000014 08000068 j stop
8 00000018 54000000 nop
9 0000001c 54000000 nop
12 ; =====Procedure Iterative Division=====
13 ;Gets on r1,r2 dividend and divisor
14 ;and store the result both in memory at address 0 and
15 ;and on register r5
17 00000020 proc_iterative_division:
18 00000020 00631826 xor r3, r3, r3
19 00000024 54000000 nop
20 00000028 54000000 nop
21 0000002c 54000000 nop
22 00000030 divide:
23 00000030 00222829 sne r5, r1, r2
24 00000034 54000000 nop
25 00000038 54000000 nop
26 0000003c 10a0001c beqz r5, finish
27 00000040 54000000 nop
28 00000044 54000000 nop
29 00000048 00220822 sub r1, r1, r2
30 0000004c 20630001 addi r3, r3, 1
31 00000050 0bffffdc j divide
32 00000054 54000000 nop
33 00000058 54000000 nop
34 0000005c finish:
35 0000005c 00012020 add r4, r0, r1
36 00000060 54000000 nop
37 00000064 54000000 nop
38 00000068 54000000 nop
39 0000006c ac040000 sw 0(r0), r4
40 00000070 8c050000 lw r5, 0(r0)
41 00000074 0bffff9c j after_division_proc
42 00000078 54000000 nop
43 0000007c 54000000 nop
44 ; =====End Procedure Iterative Division=====
47 00000080 stop:
48 00000080 0bfffffc j stop
49 00000084 54000000 nop
50 00000088 54000000 nop
51 0000008c 54000000 nop
12 changes: 12 additions & 0 deletions sim/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Steps for the simulation:
1) bash ./scripts/assembler.sh ./assembly_programs/<program>.asm
2) cp ./assembly_programs/<program>_dump.txt ./scripts/test.asm.mem
3) cd scripts
4) setmentor
5) vsim &
6) bash compile.bash
7) Set the parameters, resolution 10ps, apply full visibility and choose tb_cpu design
8) After design is loaded, add waves (Useful waves are tipically CLK,RST,CU/OPCODE, DP/RF/REGS, DATAMEM/MEM)
8) run simulation (for long programs such as division it is better to go straight to run 2us)

While design is loaded, to run other programs move in the main directory for simulation: DLX-Risc-uProcessor/sim and perform steps 1 and 2 and run "restart -f" in questasim, then perform step 8.
50 changes: 34 additions & 16 deletions sim/assembly_programs/division_custom.asm
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
addi r1, r0, 81
addi r2, r0, 9
xor r3, r3, r3
addi r1, r0, #81
addi r2, r0, #9
jal proc_iterative_division
nop
nop
after_division_proc:
j stop
nop
nop


; =====Procedure Iterative Division=====
;Gets on r1,r2 dividend and divisor
;and store the result both in memory at address 0 and
;and on register r5

proc_iterative_division:
xor r3, r3, r3
nop
nop
nop
divide:
sne r5, r1, r2
nop
nop
nop
beqz r5, finish
nop
nop
nop
sub r1, r1, r2
addi r3, r3, 1
j divide
nop
nop
nop
finish:
add r4, r0, r1
nop
nop
nop
sw 0(r0), r4
lw r5, 0(r0)
add r4, r0, r1
nop
nop
nop
sw 0(r0), r4
lw r5, 0(r0)
j after_division_proc
nop
nop
; =====End Procedure Iterative Division=====


stop:
j stop
nop
nop
nop
j stop
nop
nop
nop
Binary file modified sim/assembly_programs/division_custom.bin
Binary file not shown.
73 changes: 43 additions & 30 deletions sim/assembly_programs/division_custom.list
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
line address contents
1 00000000 20010051 addi r1, r0, 81
2 00000004 20020009 addi r2, r0, 9
3 00000008 00631826 xor r3, r3, r3
1 00000000 20010051 addi r1, r0, #81
2 00000004 20020009 addi r2, r0, #9
3 00000008 0c000014 jal proc_iterative_division
4 0000000c 54000000 nop
5 00000010 54000000 nop
6 00000014 54000000 nop
7 00000018 divide:
8 00000018 00222829 sne r5, r1, r2
6 00000014 after_division_proc:
7 00000014 08000068 j stop
8 00000018 54000000 nop
9 0000001c 54000000 nop
10 00000020 54000000 nop
11 00000024 54000000 nop
12 00000028 10a00024 beqz r5, finish
13 0000002c 54000000 nop
14 00000030 54000000 nop
15 00000034 54000000 nop
16 00000038 00220822 sub r1, r1, r2
17 0000003c 20630001 addi r3, r3, 1
18 00000040 0bffffd4 j divide
19 00000044 54000000 nop
20 00000048 54000000 nop
21 0000004c 54000000 nop
22 00000050 finish:
23 00000050 00012020 add r4, r0, r1
24 00000054 54000000 nop
25 00000058 54000000 nop
26 0000005c 54000000 nop
27 00000060 ac040000 sw 0(r0), r4
28 00000064 8c050000 lw r5, 0(r0)
29 00000068 stop:
30 00000068 0bfffffc j stop
31 0000006c 54000000 nop
32 00000070 54000000 nop
33 00000074 54000000 nop
12 ; =====Procedure Iterative Division=====
13 ;Gets on r1,r2 dividend and divisor
14 ;and store the result both in memory at address 0 and
15 ;and on register r5
17 00000020 proc_iterative_division:
18 00000020 00631826 xor r3, r3, r3
19 00000024 54000000 nop
20 00000028 54000000 nop
21 0000002c 54000000 nop
22 00000030 divide:
23 00000030 00222829 sne r5, r1, r2
24 00000034 54000000 nop
25 00000038 54000000 nop
26 0000003c 10a0001c beqz r5, finish
27 00000040 54000000 nop
28 00000044 54000000 nop
29 00000048 00220822 sub r1, r1, r2
30 0000004c 20630001 addi r3, r3, 1
31 00000050 0bffffdc j divide
32 00000054 54000000 nop
33 00000058 54000000 nop
34 0000005c finish:
35 0000005c 00012020 add r4, r0, r1
36 00000060 54000000 nop
37 00000064 54000000 nop
38 00000068 54000000 nop
39 0000006c ac040000 sw 0(r0), r4
40 00000070 8c050000 lw r5, 0(r0)
41 00000074 0bffff9c j after_division_proc
42 00000078 54000000 nop
43 0000007c 54000000 nop
44 ; =====End Procedure Iterative Division=====
47 00000080 stop:
48 00000080 0bfffffc j stop
49 00000084 54000000 nop
50 00000088 54000000 nop
51 0000008c 54000000 nop
16 changes: 11 additions & 5 deletions sim/assembly_programs/division_custom_dump.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
20010051
20020009
00631826
0C000014
54000000
54000000
08000068
54000000
00222829
54000000
00631826
54000000
54000000
10A00024
54000000
00222829
54000000
54000000
10A0001C
54000000
54000000
00220822
20630001
0BFFFFD4
54000000
0BFFFFDC
54000000
54000000
00012020
Expand All @@ -24,6 +27,9 @@
54000000
AC040000
8C050000
0BFFFF9C
54000000
54000000
0BFFFFFC
54000000
54000000
Expand Down
16 changes: 11 additions & 5 deletions sim/scripts/test.asm.mem
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
20010051
20020009
00631826
0C000014
54000000
54000000
08000068
54000000
00222829
54000000
00631826
54000000
54000000
10A00024
54000000
00222829
54000000
54000000
10A0001C
54000000
54000000
00220822
20630001
0BFFFFD4
54000000
0BFFFFDC
54000000
54000000
00012020
Expand All @@ -24,6 +27,9 @@
54000000
AC040000
8C050000
0BFFFF9C
54000000
54000000
0BFFFFFC
54000000
54000000
Expand Down
Loading