From 284a5fa0f79ae5415d6ab2009193d3bead64d2aa Mon Sep 17 00:00:00 2001 From: Tim Hutt Date: Tue, 29 Oct 2024 21:49:07 +0000 Subject: Add static type hints This makes the code easier to understand and navigate, and also detected a few of bugs: 1. Missing brackets on e.upper. (Fixed) 2. Not strictly related to types, but a lot of the regexes were not raw strings and therefore contained invalid escape sequences. Python prints a warning about these in recent versions. (Fixed) 3. Expression in `process_pseudo_instructions()` that is always false. (Not fixed) 4. Missing definition of `log_and_exit()`. (Fixed) This is validated via pre-commit in CI. --- sverilog_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sverilog_utils.py') diff --git a/sverilog_utils.py b/sverilog_utils.py index ff116cc..a3b7571 100644 --- a/sverilog_utils.py +++ b/sverilog_utils.py @@ -7,7 +7,7 @@ pp = pprint.PrettyPrinter(indent=2) logging.basicConfig(level=logging.INFO, format="%(levelname)s:: %(message)s") -def make_sverilog(instr_dict): +def make_sverilog(instr_dict: InstrDict): names_str = "" for i in instr_dict: names_str += f" localparam [31:0] {i.upper().replace('.','_'):<18s} = 32'b{instr_dict[i]['encoding'].replace('-','?')};\n" -- cgit v1.1