aboutsummaryrefslogtreecommitdiff
path: root/sverilog_utils.py
diff options
context:
space:
mode:
authorTim Hutt <timothy.hutt@codasip.com>2024-11-05 14:32:12 +0000
committerGitHub <noreply@github.com>2024-11-05 06:32:12 -0800
commit359a94356dba415cbd945e56126a326c59878e56 (patch)
treea1cbe073146a64c049db60f615acf6e1c2a94ad8 /sverilog_utils.py
parent6bb00f9056db133a1bea48d2377316f49fb187df (diff)
downloadriscv-opcodes-359a94356dba415cbd945e56126a326c59878e56.zip
riscv-opcodes-359a94356dba415cbd945e56126a326c59878e56.tar.gz
riscv-opcodes-359a94356dba415cbd945e56126a326c59878e56.tar.bz2
Enable Pylint in CI and fix its errors (#311)
* Remove wildcard imports Use explicit imports rather than wildcards. This is more maintainable. * Enable Pylint in CI and fix its errors The main fixes were: * Specify encoding for all file opens. By default it depends on environment variables which is bad. * Use `with` to open files. Otherwise they don't necessarily get closed. There were also a few minor things like using `enumerate`, not using objects as default arguments, etc. In some cases I slightly refactored the code.
Diffstat (limited to 'sverilog_utils.py')
-rw-r--r--sverilog_utils.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/sverilog_utils.py b/sverilog_utils.py
index a3b7571..d2b26b6 100644
--- a/sverilog_utils.py
+++ b/sverilog_utils.py
@@ -1,7 +1,9 @@
import logging
import pprint
+from pathlib import Path
-from shared_utils import *
+from constants import csrs, csrs32
+from shared_utils import InstrDict
pp = pprint.PrettyPrinter(indent=2)
logging.basicConfig(level=logging.INFO, format="%(levelname)s:: %(message)s")
@@ -17,13 +19,12 @@ def make_sverilog(instr_dict: InstrDict):
f" localparam logic [11:0] CSR_{name.upper()} = 12'h{hex(num)[2:]};\n"
)
- sverilog_file = open("inst.sverilog", "w")
- sverilog_file.write(
+ Path("inst.sverilog").write_text(
f"""
/* Automatically generated by parse_opcodes */
package riscv_instr;
{names_str}
endpackage
-"""
+""",
+ encoding="utf-8",
)
- sverilog_file.close()