Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TABLE_GEN := scripts/gen_control_table.py

# Stubs whose lint warnings are not enforced yet. Remove a module from this
# list in the PR that implements it.
LINT_SKIP := control_unit data_mem reg_file top
LINT_SKIP := data_mem reg_file top

.PHONY: all lint l1 table-check ci clean

Expand Down
13 changes: 13 additions & 0 deletions scripts/gen_control_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,19 @@ def render(specific, default):
for n, p, v in specific)
name_cases = "\n".join(
f" {sv_case_label(p)}: ctrl_name = \"{n}\";" for n, p, _ in specific)
diff_checks = "\n".join(
f" if (((actual.{n} ^ expected.{n}) & mask.{n}) !== '0)\n"
f" s = {{s, s == \"\" ? \"\" : \", \", "
f"$sformatf(\"{n} exp %0d got %0d\", expected.{n}, actual.{n})}};"
for n, _ in SIGNALS)
args = "input logic [6:0] opcode, input logic [2:0] funct3, input logic instr30"

return f"""/*
Generated by scripts/gen_control_table.py from docs/control_table.csv.
Do not edit by hand. Testbench use only: the control unit RTL must not include this file.
ctrl_mask has 1s on the bits to check; a field that is x in the CSV is 0 in both
ctrl_expected and ctrl_mask. Check with: ((actual ^ ctrl_expected(...)) & ctrl_mask(...)) !== '0
ctrl_diff lists the checked fields that differ, for failure messages.
*/

`ifndef CONTROL_TABLE_SVH
Expand Down Expand Up @@ -155,6 +161,13 @@ def render(specific, default):
endcase
endfunction

function automatic string ctrl_diff(input ctrl_t actual, input ctrl_t expected, input ctrl_t mask);
string s;
s = "";
{diff_checks}
return s;
endfunction

`endif
"""

Expand Down
Loading
Loading