-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
module memory ( | ||
input logic clk, | ||
input logic [31:0] mem_addr, | ||
input logic mem_r_enable, | ||
input logic mem_w_enable, | ||
input logic [31:0] mem_wdata, | ||
input logic [31:0] rom_addr, | ||
|
||
output logic [31:0] rom_rdata, | ||
output logic [31:0] mem_rdata | ||
); | ||
|
||
logic [31:0] MEM [0:255]; | ||
// localparam start = 32'h00000000; | ||
logic [7:0] ROM [0: 16384]; | ||
|
||
string input_file; | ||
initial begin | ||
if (!$value$plusargs("INPUT_FILE=%s", input_file)) begin | ||
$display("INPUT_FILE argument not found"); | ||
$finish(); | ||
end | ||
$display("%s", input_file); | ||
$readmemh(input_file, ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-add.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-addi.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-and.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-andi.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-auipc.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-beq.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-bge.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-bgeu.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-blt.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-bltu.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-bne.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-fence_i.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-jal.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-jalr.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-lb.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-lbu.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-lh.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-lhu.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-lui.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-lw.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-ma_data.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-or.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-ori.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sb.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sh.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-simple.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sll.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-slli.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-slt.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-slti.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sltiu.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sltu.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sra.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-srai.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-srl.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-srli.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sub.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-sw.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-xor.hex", ROM); | ||
// $readmemh("../riscv-tests/hex/rv32ui-p-xori.hex", ROM); | ||
end | ||
|
||
|
||
assign rom_rdata = {ROM[rom_addr+3], ROM[rom_addr+2], ROM[rom_addr+1], ROM[rom_addr]}; | ||
|
||
always @(posedge clk) begin | ||
if (mem_r_enable) begin | ||
mem_rdata <= MEM[mem_addr[31:2]]; | ||
end | ||
else if (mem_w_enable) begin | ||
MEM[mem_addr] <= mem_wdata; | ||
end | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
tests=( | ||
"rv32ui-p-add" "rv32ui-p-addi" "rv32ui-p-and" "rv32ui-p-andi" "rv32ui-p-auipc" | ||
"rv32ui-p-beq" "rv32ui-p-bge" "rv32ui-p-bgeu" "rv32ui-p-blt" "rv32ui-p-bltu" "rv32ui-p-bne" | ||
"rv32ui-p-fence_i" | ||
"rv32ui-p-jal" "rv32ui-p-jalr" | ||
) | ||
|
||
iverilog -g2012 -DBENCH testbench_iverilog.sv top.sv memory_for_riscvtests.sv core.sv def.sv | ||
|
||
for test_case in "${tests[@]}" | ||
do | ||
echo "case : $test_case" | ||
testfile="../riscv-tests/hex/$test_case.hex" | ||
if [ ! -e $testfile ]; then | ||
echo "error: not found $test_case.hex from run_riscvtests.sh" | ||
continue | ||
fi | ||
|
||
vvp a.out +INPUT_FILE=$testfile | ||
|
||
echo "-------------" | ||
done |