Refine hex file index from verialtor c code.
This commit is contained in:
parent
ce40766cbd
commit
e44af58d63
4
Makefile
4
Makefile
|
@ -27,8 +27,8 @@ test_wb_vcd: testbench_wb.vvp firmware/firmware.hex
|
||||||
$(VVP) -N $< +vcd +trace +noerror
|
$(VVP) -N $< +vcd +trace +noerror
|
||||||
|
|
||||||
test_verilator: testbench_verilator firmware/firmware.hex
|
test_verilator: testbench_verilator firmware/firmware.hex
|
||||||
./testbench_verilator 0
|
./testbench_verilator firmware/firmware.hex
|
||||||
./testbench_verilator 1
|
./testbench_verilator dhrystone/dhry.hex
|
||||||
|
|
||||||
testbench_verilator: testbench_wb.v picorv32.v testbench.cc
|
testbench_verilator: testbench_wb.v picorv32.v testbench.cc
|
||||||
$(VERILATOR) --cc --exe -Wno-lint -trace --top-module picorv32_wrapper testbench_wb.v picorv32.v testbench.cc \
|
$(VERILATOR) --cc --exe -Wno-lint -trace --top-module picorv32_wrapper testbench_wb.v picorv32.v testbench.cc \
|
||||||
|
|
15
testbench.cc
15
testbench.cc
|
@ -11,10 +11,17 @@ int main(int argc, char** argv, char** env) {
|
||||||
Verilated::commandArgs(argc, argv);
|
Verilated::commandArgs(argc, argv);
|
||||||
Vpicorv32_wrapper* top = new Vpicorv32_wrapper;
|
Vpicorv32_wrapper* top = new Vpicorv32_wrapper;
|
||||||
|
|
||||||
if (argc > 0 && argv[1][0] == '1')
|
std::string hexfile;
|
||||||
top->testcase = 1;
|
if (argc > 1) {
|
||||||
else
|
hexfile = std::string(argv[1]);
|
||||||
top->testcase = 0;
|
} else {
|
||||||
|
hexfile = std::string("firmware/firmware.hex");
|
||||||
|
}
|
||||||
|
auto hex = (uint8_t*)(top->hex_file.data());
|
||||||
|
auto csr = hexfile.c_str();
|
||||||
|
for (int i = 0; i < hexfile.size(); i += 1) {
|
||||||
|
*(hex + (128 - i)) = *(uint8_t*)(csr + i);
|
||||||
|
}
|
||||||
|
|
||||||
// Tracing (vcd)
|
// Tracing (vcd)
|
||||||
VerilatedVcdC* tfp = NULL;
|
VerilatedVcdC* tfp = NULL;
|
||||||
|
|
|
@ -62,7 +62,7 @@ module picorv32_wrapper #(
|
||||||
output trap,
|
output trap,
|
||||||
output trace_valid,
|
output trace_valid,
|
||||||
output [35:0] trace_data,
|
output [35:0] trace_data,
|
||||||
input testcase
|
input [1024:0] hex_file
|
||||||
);
|
);
|
||||||
wire exit;
|
wire exit;
|
||||||
reg [31:0] irq = 0;
|
reg [31:0] irq = 0;
|
||||||
|
@ -98,13 +98,9 @@ module picorv32_wrapper #(
|
||||||
.wb_rst_i(wb_rst),
|
.wb_rst_i(wb_rst),
|
||||||
);
|
);
|
||||||
|
|
||||||
reg [1023:0] firmware_file;
|
|
||||||
initial begin
|
initial begin
|
||||||
if (!testcase) firmware_file = "firmware/firmware.hex";
|
$readmemh(hex_file, uut.memory);
|
||||||
else firmware_file = "dhrystone/dhry.hex";
|
$display("HEX File : %s", hex_file);
|
||||||
// if (!$value$plusargs("firmware=%s", firmware_file))
|
|
||||||
// firmware_file = "firmware/firmware.hex";
|
|
||||||
$readmemh(firmware_file, uut.memory);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
integer cycle_counter;
|
integer cycle_counter;
|
||||||
|
|
Loading…
Reference in New Issue