Skip to content

Commit 9466b54

Browse files
committed
fix: edit verbose flag to debug to match the c header gen and move the parse args to the top of the file
1 parent 0ba1fb9 commit 9466b54

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

backends/generators/sverilog/sverilog_generator.py

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,58 @@
1212
from generator import load_instructions, load_csrs, load_exception_codes
1313

1414

15+
def parse_args():
16+
parser = argparse.ArgumentParser(
17+
description="Generate SystemVerilog package from RISC-V instruction definitions"
18+
)
19+
parser.add_argument(
20+
"--inst-dir",
21+
default="../../../gen/resolved_spec/_/inst/",
22+
help="Directory containing instruction YAML files",
23+
)
24+
parser.add_argument(
25+
"--csr-dir",
26+
default="../../../gen/resolved_spec/_/csr/",
27+
help="Directory containing CSR YAML files",
28+
)
29+
parser.add_argument(
30+
"--ext-dir",
31+
default="../../../arch/ext/",
32+
help="Directory containing extension YAML files",
33+
)
34+
parser.add_argument(
35+
"--output",
36+
default="riscv_decode_package.svh",
37+
help="Output SystemVerilog file name",
38+
)
39+
parser.add_argument(
40+
"--include-all",
41+
action="store_true",
42+
help="Include all instructions and CSRs regardless of extensions",
43+
)
44+
parser.add_argument(
45+
"--debug", "-v", action="store_true", help="Enable debug logging"
46+
)
47+
parser.add_argument(
48+
"--extensions",
49+
"-e",
50+
nargs="+",
51+
default=[],
52+
help="Comma-separated list of enabled extensions.",
53+
)
54+
parser.add_argument(
55+
"--arch",
56+
default="BOTH",
57+
choices=["RV32", "RV64", "BOTH"],
58+
help="Target architecture (RV32, RV64, or BOTH). Default is RV64.",
59+
)
60+
parser.add_argument(
61+
"--resolved-codes",
62+
help="JSON file containing pre-resolved exception codes",
63+
)
64+
return parser.parse_args()
65+
66+
1567
def format_instruction_name(name):
1668
"""Format instruction name for SystemVerilog (uppercase with underscores)."""
1769
# Replace dots with underscores and convert to uppercase
@@ -105,63 +157,11 @@ def generate_sverilog(instructions, csrs, causes, output_file):
105157
f.write("\nendpackage\n")
106158

107159

108-
def parse_args():
109-
parser = argparse.ArgumentParser(
110-
description="Generate SystemVerilog package from RISC-V instruction definitions"
111-
)
112-
parser.add_argument(
113-
"--inst-dir",
114-
default="../../../gen/resolved_spec/_/inst/",
115-
help="Directory containing instruction YAML files",
116-
)
117-
parser.add_argument(
118-
"--csr-dir",
119-
default="../../../gen/resolved_spec/_/csr/",
120-
help="Directory containing CSR YAML files",
121-
)
122-
parser.add_argument(
123-
"--ext-dir",
124-
default="../../../arch/ext/",
125-
help="Directory containing extension YAML files",
126-
)
127-
parser.add_argument(
128-
"--output",
129-
default="riscv_decode_package.svh",
130-
help="Output SystemVerilog file name",
131-
)
132-
parser.add_argument(
133-
"--include-all",
134-
action="store_true",
135-
help="Include all instructions and CSRs regardless of extensions",
136-
)
137-
parser.add_argument(
138-
"--verbose", "-v", action="store_true", help="Enable verbose logging"
139-
)
140-
parser.add_argument(
141-
"--extensions",
142-
"-e",
143-
nargs="+",
144-
default=[],
145-
help="Comma-separated list of enabled extensions.",
146-
)
147-
parser.add_argument(
148-
"--arch",
149-
default="BOTH",
150-
choices=["RV32", "RV64", "BOTH"],
151-
help="Target architecture (RV32, RV64, or BOTH). Default is RV64.",
152-
)
153-
parser.add_argument(
154-
"--resolved-codes",
155-
help="JSON file containing pre-resolved exception codes",
156-
)
157-
return parser.parse_args()
158-
159-
160160
def main():
161161
args = parse_args()
162162

163163
# Set up logging
164-
log_level = logging.DEBUG if args.verbose else logging.INFO
164+
log_level = logging.DEBUG if args.debug else logging.INFO
165165
logging.basicConfig(level=log_level, format="%(levelname)s:: %(message)s")
166166

167167
# Parse extensions

0 commit comments

Comments
 (0)