Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ jobs:
- name: Install Icarus Verilog
run: sudo apt-get update && sudo apt-get install -y iverilog

- name: Run Verilog read tests
run: |
mkdir -p "$RUNNER_TEMP/verilog/in1"
iverilog -g2012 -I. -o "$RUNNER_TEMP/verilog/test_read_simtime" tests/verilog/test_read_simtime.v
cd "$RUNNER_TEMP/verilog" && vvp test_read_simtime

- name: Run Verilog interop tests
run: julia --color=yes tests/julia/test_verilog_interop.jl

Expand Down
6 changes: 5 additions & 1 deletion concore.v
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ module concore;
input [`CONCORE_MAXLEN*8-1:0] name;
input [`CONCORE_MAXLEN*8-1:0] initstr;
reg datavalid;
real readtime;
reg [(`CONCORE_MAXLEN+`INPATHLEN)*8-1:0] fname; //room for 6 extra chars
reg [7:0] asciiport;
integer i;
Expand Down Expand Up @@ -189,13 +190,16 @@ module concore;
$fclose(fin);
end
//parse
literal_eval(datavalid,simtime);
literal_eval(datavalid,readtime);
if (datavalid == 0)
begin
retrycount = retrycount + 1;
end
//time
end //datavalid
// keep simtime monotonic like the other bindings, an older file or the
// init string used for a missing file must not move it back
if (readtime > simtime) simtime = readtime;
end
endtask

Expand Down
6 changes: 5 additions & 1 deletion concoredocker.v
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ module concore;
input [`CONCORE_MAXLEN*8-1:0] name;
input [`CONCORE_MAXLEN*8-1:0] initstr;
reg datavalid;
real readtime;
reg [(`CONCORE_MAXLEN+`INPATHLEN)*8-1:0] fname; //room for 6 extra chars
reg [7:0] asciiport;
integer i;
Expand Down Expand Up @@ -189,13 +190,16 @@ module concore;
$fclose(fin);
end
//parse
literal_eval(datavalid,simtime);
literal_eval(datavalid,readtime);
if (datavalid == 0)
begin
retrycount = retrycount + 1;
end
//time
end //datavalid
// keep simtime monotonic like the other bindings, an older file or the
// init string used for a missing file must not move it back
if (readtime > simtime) simtime = readtime;
end
endtask

Expand Down
8 changes: 4 additions & 4 deletions tests/protocol_fixtures/cross_runtime_matrix.phase2.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@
"note": "Audit planned in phase 2."
},
"verilog": {
"status": "not_audited",
"status": "observed_pass",
"classification": "implementation_defined",
"note": "May require binding-specific interpretation."
"note": "readdata() falls back to the init string, so data and simtime match the fixture. concore.v has no success flag to return, so the ok=False part has no equivalent. Checked by tests/verilog/test_read_simtime.v."
}
}
},
Expand Down Expand Up @@ -304,9 +304,9 @@
"note": "Audit planned in phase 2."
},
"verilog": {
"status": "not_audited",
"status": "observed_pass",
"classification": "implementation_defined",
"note": "May require binding-specific interpretation."
"note": "readdata() only moves simtime forward, an older file timestamp leaves it unchanged. Checked by tests/verilog/test_read_simtime.v."
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/test_protocol_conformance_phase2.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ def test_phase2_matrix_cpp_status_is_recorded_for_each_case():
assert cpp_result["status"] == "observed_fail"
else:
assert cpp_result["status"] == "observed_pass"


# concore.v only has the file based read path, so the read_file cases are the
# ones that apply to it. tests/verilog/test_read_simtime.v checks both in CI.
def test_phase2_matrix_verilog_read_file_cases_pass():
for row in _phase2_matrix()["cases"]:
if row["target"] == "read_file":
assert row["runtime_results"]["verilog"]["status"] == "observed_pass"
29 changes: 29 additions & 0 deletions tests/verilog/test_read_simtime.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
`include "concore.v"

// read_file cases from tests/protocol_fixtures/python_phase1_cases.json
// run from a directory that has an empty in1/ folder
module test_read_simtime;
reg [8*10-1:0] missing_init = "[0.0, 5.0]";
reg [8*10-1:0] ym_init = "[0.0, 0.0]";
integer f;

initial begin
// read_file/missing_file_returns_default_and_false
concore.simtime = 4;
concore.readdata(1, "missing", missing_init);
if (concore.simtime != 4) $fatal(1, "missing file: simtime is %f, expected 4", concore.simtime);
if (concore.data[0] != 5.0) $fatal(1, "missing file: data[0] is %f, expected 5.0", concore.data[0]);

// read_file/older_timestamp_does_not_decrease_simtime
f = $fopen("in1/ym", "w");
$fwrite(f, "[7.0, 3.14]");
$fclose(f);
concore.simtime = 10;
concore.readdata(1, "ym", ym_init);
if (concore.simtime != 10) $fatal(1, "older timestamp: simtime is %f, expected 10", concore.simtime);
if (concore.data[0] != 3.14) $fatal(1, "older timestamp: data[0] is %f, expected 3.14", concore.data[0]);

$display("read simtime tests passed");
$finish;
end
endmodule
Loading