Skip to content

Commit 9d4bc46

Browse files
committed
fixed data_memory in sequential
1 parent 0c283ba commit 9d4bc46

File tree

4 files changed

+621
-16
lines changed

4 files changed

+621
-16
lines changed

sequential/modules/data_memory.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module data_memory(
1515
end
1616

1717
always @(posedge clk) begin
18-
if (address > 1016) begin
18+
if (address > 1016 && mem_write) begin
1919
$fatal(1, "\n\nError: Invalid memory address %d\n", address);
2020
end
2121
if (mem_write && address <= 1016) begin
@@ -31,7 +31,7 @@ module data_memory(
3131
end
3232

3333
always @(*) begin
34-
if (address > 1016) begin
34+
if (address > 1016 && mem_read) begin
3535
$fatal(1, "\n\nError: Invalid memory address %d\n", address);
3636
end
3737
if (mem_read && address <= 1016) begin

sequential/testcases/8.s

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
begin:
2-
beq x0, x0, end
2+
beq x0, x0, L1
3+
addi x6, x0, 4
4+
5+
L2:
6+
addi x7, x0, 8
37

48
L1:
59
addi x5, x0, 4
610

7-
L2:
8-
addi x6, x0, 4
11+
end:
12+
nop
913

10-
L3:
11-
addi x7, x0, 4
1214

13-
end:
14-
nop
15+
# only x5

sequential/verilog/testbench_sequential.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nb`timescale 1ns/1ps
1+
`timescale 1ns/1ps
22

33
module testbench_sequential();
44
reg clk;
@@ -26,10 +26,10 @@ module testbench_sequential();
2626
);
2727

2828
initial begin
29-
cpu.imem.memory[0] = 32'b00000000000000000000100001100011;
30-
cpu.imem.memory[1] = 32'b00000000010000000000001010010011;
31-
cpu.imem.memory[2] = 32'b00000000010000000000001100010011;
32-
cpu.imem.memory[3] = 32'b00000000010000000000001110010011;
29+
cpu.imem.memory[0] = 32'b00000000000000000000011001100011;
30+
cpu.imem.memory[1] = 32'b00000000010000000000001100010011;
31+
cpu.imem.memory[2] = 32'b00000000100000000000001110010011;
32+
cpu.imem.memory[3] = 32'b00000000010000000000001010010011;
3333
cpu.imem.memory[4] = 32'b00000000000000000000000000000000;
3434
end
3535

0 commit comments

Comments
 (0)