mirror of
https://github.com/riscv/riscv-opcodes.git
synced 2025-10-15 12:57:22 +08:00
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.
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user