Skip to content

Commit 2121d13

Browse files
committed
Add fixes to decode and stalled fibonacci sequence
1 parent 7085910 commit 2121d13

File tree

4 files changed

+61
-30
lines changed

4 files changed

+61
-30
lines changed

PROC/Init.dat

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
00000001010010110100100000100000
2-
00100000010000100000000010001010
3-
10001100111110010000000000010001
4-
00010010010000111111111111111101
5-
10101100100010000000000000100110
6-
00111100000111100001001110000010
7-
00000000010000110000100000100100
8-
00000001000000000000000000001000
9-
00000000111010010010000000100111
10-
00000001111100000111000000100101
11-
00000000000001000100000001000000
12-
00000000010000110000100000101010
13-
00000000000001010100000001000010
14-
00000001000000110111000000100010
15-
00000000000001000000000000011010
16-
00000000000000001101100000010010
17-
00000000000000001111000000010000
18-
00000001001100010000000000010100
19-
00000010000010010011100000100110
20-
00000000000001101001110111000011
21-
00100000100001100000000001110101
22-
00110000010000011111111111110110
23-
00010100011010001111111111110101
24-
10000000100100110000000000000000
1+
00100000000010100000000000000100
2+
00100000000000010000000000000001
3+
00100000000000100000000000000001
4+
00100000000010110000011111010000
5+
00100000000011110000000000000100
6+
00100000010000110000000000000000
7+
00100000000000000000000000000000
8+
00000000010000010001000000100000
9+
00100000011000010000000000000000
10+
00000001010011110000000000010100
11+
00000000000000000110000000010010
12+
00100000000000000000000000000000
13+
00100000000000000000000000000000
14+
00000001011011000110100000100000
15+
00100000000000000000000000000000
16+
00100000000000000000000000000000
17+
10101101101000100000000000000000
18+
00100001010010101111111111111111
19+
00010100000010101111111111110011
20+
00100000000000000000000000000000
21+
00010001011010110000000000000000

PROC/TEST2.tcl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ sim:/PROCv2/id_branch_out\
3333
sim:/PROCv2/id_byte_out\
3434
sim:/PROCv2/id_WB_enable_out
3535

36+
add wave -group "Comaprator signals" sim:/procv2/IDstage/reg_comparator/value1\
37+
sim:/procv2/IDstage/reg_comparator/value2\
38+
sim:/procv2/IDstage/reg_comparator/ctl\
39+
sim:/procv2/IDstage/reg_comparator/taken
40+
3641
add wave -group "EX in buffers" sim:/PROCv2/ex_r1_in_buffer\
3742
sim:/PROCv2/ex_r2_in_buffer\
3843
sim:/PROCv2/ex_imm_in_buffer\
@@ -86,7 +91,8 @@ add wave -position end sim:/procv2/EXstage/mux1/A
8691
add wave -position end sim:/procv2/EXstage/mux1/X
8792
add wave -position end sim:/procv2/EXstage/mux1/ctl
8893

89-
94+
add wave -position 6 sim:/procv2/IDstage/branch_dest
95+
add wave -position 5 sim:/procv2/IDstage/branch_taken_internal
9096
}
9197
;
9298

PROC/decode.vhd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ begin
291291
branch_ctl <= "01";
292292
use_imm <= '0';
293293
immediate_out_internal <= To_StdLogicVector(to_bitvector(std_logic_vector(resize(signed(instruction_in(15 downto 0)), immediate_out_internal'length))) sll 2);
294-
r1 <= (others => '0');
295-
r2 <= (others => '0');
294+
-- r1 <= (others => '0');
295+
-- r2 <= (others => '0');
296296
write_back_enable <= '0';
297297

298298
when "000101" =>
@@ -301,8 +301,8 @@ begin
301301
use_imm <= '0';
302302
branch_ctl <= "10";
303303
immediate_out_internal <= To_StdLogicVector(to_bitvector(std_logic_vector(resize(signed(instruction_in(15 downto 0)), immediate_out_internal'length))) sll 2);
304-
r1 <= (others => '0');
305-
r2 <= (others => '0');
304+
-- r1 <= (others => '0');
305+
-- r2 <= (others => '0');
306306
write_back_enable <= '0';
307307

308308
when others =>
@@ -315,7 +315,7 @@ begin
315315
immediate_out <= immediate_out_internal;
316316
reg1_out <= reg1_out_internal;
317317
reg2_out <= reg2_out_internal;
318-
318+
319319
reg1_addr <= r1;
320320
reg2_addr <= r2;
321321

PROC/fib.asm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
###############################################
2+
# This program generates Fibonacci series.
3+
# It stores the generated Fibonacci numbers fisrt into, Reg[2] ($2), and then into memory
4+
# Assume that your data section in memory starts from address 2000
5+
6+
addi $10, $0, 4 # number of generating Fibonacci-numbers
7+
addi $1, $0, 1 # initializing Fib(-1) = 0
8+
addi $2, $0, 1 # initializing Fib(0) = 1
9+
addi $11, $0, 2000 # initializing the beginning of Data Section address in memory
10+
addi $15, $0, 4 # word size in byte
11+
12+
loop: addi $3, $2, 0 # temp = Fib(n-1)
13+
addi $0, $0, 0
14+
add $2, $2, $1 # Fib(n)=Fib(n-1)+Fib(n-2)
15+
addi $1, $3, 0 # Fib(n-2)=temp=Fib(n-1)
16+
mult $10, $15 # $lo=4*$10, for word alignment
17+
mflo $12 # assume small numbers
18+
addi $0, $0, 0
19+
addi $0, $0, 0
20+
add $13, $11, $12 # Make data pointer [2000+($10)*4]
21+
addi $0, $0, 0
22+
addi $0, $0, 0
23+
sw $2, 0($13) # Mem[$10+2000] <-- Fib(n)
24+
addi $10, $10, -1 # loop index
25+
bne $10, $0, loop
26+
addi $0, $0, 0
27+
EoP: beq $11, $11, EoP #end of program (infinite loop)
28+
###############################################

0 commit comments

Comments
 (0)