Skip to content

Commit d01864e

Browse files
committed
Fix or waive Python lint errors and warnings
Signed-off-by: Pirmin Vogel <[email protected]>
1 parent f4c2bb9 commit d01864e

File tree

17 files changed

+91
-104
lines changed

17 files changed

+91
-104
lines changed

hw/formal/tools/vcformal/parse-formal-report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_summary(str_buffer):
8282
summary["pass_rate"] = format_percentage(summary["proven"],
8383
summary["cex"] + summary["undetermined"])
8484
summary["cov_rate"] = format_percentage(summary["covered"],
85-
summary["unreachable"])
85+
summary["unreachable"])
8686

8787
return summary
8888

@@ -125,7 +125,7 @@ def get_cov_results(logpath, dut_name):
125125
else:
126126
cov_results[key] = "N/A"
127127
log.warning("Parse %s coverage error. Expect one matching value, get %s",
128-
key, item)
128+
key, item)
129129
return cov_results
130130

131131
except IOError as err:

hw/ip/clkmgr/util/clkmgr_gen_deprecated.py

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,33 @@
55
r"""Clock Manager Generator
66
"""
77

8-
import argparse
98
import logging as log
109
import sys
11-
import subprocess
1210
from collections import OrderedDict
13-
from io import StringIO
1411
from pathlib import Path
1512

1613
import hjson
17-
from mako import exceptions
1814
from mako.template import Template
1915

16+
2017
# Common header for generated files
2118
def main():
2219

2320
current = Path(__file__).parent.absolute()
2421

2522
hjson_tpl = Template(filename=str(current / '../data/clkmgr.hjson.tpl'))
26-
rtl_tpl = Template(filename=str(current / '../data/clkmgr.sv.tpl'))
27-
pkg_tpl = Template(filename=str(current / '../data/clkmgr_pkg.sv.tpl'))
23+
rtl_tpl = Template(filename=str(current / '../data/clkmgr.sv.tpl'))
24+
pkg_tpl = Template(filename=str(current / '../data/clkmgr_pkg.sv.tpl'))
2825

2926
hjson_out = current / '../data/clkmgr.hjson'
30-
rtl_out = current / '../rtl/clkmgr.sv'
31-
pkg_out = current / '../rtl/clkmgr_pkg.sv'
27+
rtl_out = current / '../rtl/clkmgr.sv'
28+
pkg_out = current / '../rtl/clkmgr_pkg.sv'
3229

33-
cfgpath = current / '../data/clkmgr.cfg.example.hjson'
30+
cfgpath = current / '../data/clkmgr.cfg.example.hjson'
3431

3532
try:
3633
with open(cfgpath, 'r') as cfg:
37-
topcfg = hjson.load(cfg,use_decimal=True,object_pairs_hook=OrderedDict)
34+
topcfg = hjson.load(cfg, use_decimal=True, object_pairs_hook=OrderedDict)
3835
except ValueError:
3936
log.error("{} not found".format(cfgpath))
4037
raise SystemExit(sys.exc_info()[1])
@@ -48,45 +45,44 @@ def main():
4845
sw_clks = OrderedDict()
4946
hint_clks = OrderedDict()
5047

51-
ft_clks = {clk:src for grp in grps for (clk,src) in grp['clocks'].items()
52-
if grp['name'] == 'powerup'}
48+
ft_clks = {clk: src for grp in grps for (clk, src) in grp['clocks'].items()
49+
if grp['name'] == 'powerup'}
5350

5451
# root-gate clocks
55-
rg_clks = {clk:src for grp in grps for (clk,src) in grp['clocks'].items()
56-
if grp['name'] != 'powerup' and grp['sw_cg'] == 'no'}
52+
rg_clks = {clk: src for grp in grps for (clk, src) in grp['clocks'].items()
53+
if grp['name'] != 'powerup' and grp['sw_cg'] == 'no'}
5754

5855
# direct sw control clocks
59-
sw_clks = {clk:src for grp in grps for (clk,src) in grp['clocks'].items()
60-
if grp['sw_cg'] == 'yes'}
56+
sw_clks = {clk: src for grp in grps for (clk, src) in grp['clocks'].items()
57+
if grp['sw_cg'] == 'yes'}
6158

6259
# sw hint clocks
63-
hint_clks = {clk:src for grp in grps for (clk,src) in grp['clocks'].items()
60+
hint_clks = {clk: src for grp in grps for (clk, src) in grp['clocks'].items()
6461
if grp['sw_cg'] == 'hint'}
6562

66-
6763
# generate hjson
6864
hjson_out.write_text(
69-
hjson_tpl.render(cfg=topcfg,
70-
ft_clks=ft_clks,
71-
rg_clks=rg_clks,
72-
sw_clks=sw_clks,
73-
hint_clks=hint_clks))
65+
hjson_tpl.render(cfg=topcfg,
66+
ft_clks=ft_clks,
67+
rg_clks=rg_clks,
68+
sw_clks=sw_clks,
69+
hint_clks=hint_clks))
7470

7571
# generate rtl package
7672
pkg_out.write_text(
77-
pkg_tpl.render(cfg=topcfg,
78-
ft_clks=ft_clks,
79-
rg_clks=rg_clks,
80-
sw_clks=sw_clks,
81-
hint_clks=hint_clks))
73+
pkg_tpl.render(cfg=topcfg,
74+
ft_clks=ft_clks,
75+
rg_clks=rg_clks,
76+
sw_clks=sw_clks,
77+
hint_clks=hint_clks))
8278

8379
# generate top level
8480
rtl_out.write_text(
85-
rtl_tpl.render(cfg=topcfg,
86-
ft_clks=ft_clks,
87-
rg_clks=rg_clks,
88-
sw_clks=sw_clks,
89-
hint_clks=hint_clks))
81+
rtl_tpl.render(cfg=topcfg,
82+
ft_clks=ft_clks,
83+
rg_clks=rg_clks,
84+
sw_clks=sw_clks,
85+
hint_clks=hint_clks))
9086

9187

9288
if __name__ == "__main__":

hw/ip/flash_ctrl/util/flash_ctrl_gen.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def check_values(self):
5656
(self.pages_per_bank <= Flash.max_pages_per_bank))
5757

5858
if not pow2_check:
59-
raise ValueError(f'flash power of 2 check failed. A supplied parameter '
59+
raise ValueError('flash power of 2 check failed. A supplied parameter '
6060
'is not power of 2')
6161

6262
if not limit_check:
63-
raise ValueError(f'flash number of banks and pages per bank too large')
63+
raise ValueError('flash number of banks and pages per bank too large')
6464

6565

6666
# Common header for generated files
@@ -86,7 +86,6 @@ def main():
8686
log.error("{} not found".format(cfgpath))
8787
raise SystemExit(sys.exc_info()[1])
8888

89-
9089
flash_mems = [module for module in topcfg['module'] if module['type'] == 'flash_ctrl']
9190
if len(flash_mems) > 1:
9291
log.error("This design does not currently support multiple flashes")

hw/ip/hmac/model/hmac_model.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import hashlib # for comparison
1212
import logging as log
1313
import sys
14-
from array import array
15-
from io import StringIO
1614

1715
import numpy as np
1816

@@ -57,7 +55,7 @@ def sha256(msg: bin) -> bin:
5755

5856
log.info("Padded message: %s" % (binascii.b2a_hex(new_msg)))
5957
# Convert byte to 32bit array
60-
#w_array = np.array(new_msg, dtype=np.uint32)
58+
# w_array = np.array(new_msg, dtype=np.uint32)
6159
dt = np.dtype(np.uint32)
6260
dt = dt.newbyteorder('>') # bigendian
6361
w_array = np.frombuffer(new_msg, dtype=dt)
@@ -68,7 +66,7 @@ def sha256(msg: bin) -> bin:
6866
# create w
6967
# 16 entry x 32 bit word
7068
w = w_array[i:i + 16]
71-
#for j in range(16):
69+
# for j in range(16):
7270

7371
[a, b, c, d, e, f, g, h] = [h0, h1, h2, h3, h4, h5, h6, h7]
7472
for i in range(64):

hw/ip/otbn/dv/rig/rig/gens/bad_ispr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _gen(self,
106106
# In the case of a randomly generated CSRRW, it is better to have
107107
# UNIMP instead of a write to a random address since it is actually
108108
# an instruction alias.
109-
if self.insns[idx].mnemonic == "csrrw" and random.random() < 0.8:
109+
if self.insns[idx].mnemonic == "csrrw" and random.random() < 0.8:
110110
# UNIMP instruction is equivalent to CSRRW x0, 0xC00, x0
111111
prog_insn.operands = [0, 0xC00, 0]
112112

hw/ip/pinmux/util/reg_pinmux.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def main():
5656
help='Pad attribute data width',
5757
default = 10)
5858

59-
6059
args = parser.parse_args()
6160

6261
# Determine output: if stdin then stdout if not then ??

hw/syn/tools/dc/at-plot.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def main():
6161
action='store_true',
6262
help='semilogy plot.')
6363

64-
l = 0
64+
line = 0
6565
labels = []
6666

6767
# line style and color setup
@@ -105,7 +105,7 @@ def main():
105105
tmp_area[1]) / args.gate_equivalent
106106
else:
107107
print("Error, could not find total cell area in %s" %
108-
(report_area))
108+
(rpt_area))
109109
sys.exit(1)
110110

111111
except IOError as e:
@@ -148,26 +148,26 @@ def main():
148148
if args.semilogy:
149149
plt.semilogy(results[:, 2],
150150
results[:, 1],
151-
color=cmap(l),
152-
linestyle=linestyles[l],
153-
marker=markers[l],
151+
color=cmap(line),
152+
linestyle=linestyles[line],
153+
marker=markers[line],
154154
linewidth=1.5,
155155
markersize=6,
156156
markeredgecolor='k')
157157
else:
158158
plt.plot(results[:, 2],
159159
results[:, 1],
160-
color=cmap(l),
161-
linestyle=linestyles[l],
162-
marker=markers[l],
160+
color=cmap(line),
161+
linestyle=linestyles[line],
162+
marker=markers[line],
163163
linewidth=1.5,
164164
markersize=6,
165165
markeredgecolor='k')
166166

167-
l += 1
167+
line += 1
168168
labels += [report_filebase.name]
169169

170-
print("Parsed %d result series" % l)
170+
print("Parsed %d result series" % line)
171171

172172
plt.xlabel('Period [ns]')
173173
if args.gate_equivalent == 1.0:

sw/device/tests/otbn_data/otbn_test_params.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313

1414
C_DATATYPE = "static const uint8_t"
1515

16+
1617
def print_array(varname: str, val: int, size_bytes: int):
17-
print("%s %s[%d] = {%s};" % (C_DATATYPE, varname, size_bytes, ', '.join(["0x%02x" % i for i in int(val).to_bytes(size_bytes, byteorder="little")])))
18+
print("%s %s[%d] = {%s};" % (C_DATATYPE, varname, size_bytes,
19+
', '.join(["0x%02x" % i for i in int(val).to_bytes(size_bytes, byteorder="little")])))
20+
1821

1922
def print_string(varname: str, val: str, size_bytes: int):
2023
print("%s %s[%d] = {\"%s\"};" % (C_DATATYPE, varname, size_bytes, val))
2124

25+
2226
def print_rsa_params(private_key_file: str, in_str: str) -> None:
2327
in_bytes = in_str.encode("utf-8")
2428
print("Using private key {}, and plaintext message {!r}".format(private_key_file, in_bytes))
@@ -45,6 +49,7 @@ def print_rsa_params(private_key_file: str, in_str: str) -> None:
4549
print_array("kEncryptedExpected", encrypted, private_key.size_in_bytes())
4650
print("")
4751

52+
4853
def print_ecc_params(private_key_file: str, in_str: str) -> None:
4954
in_bytes = in_str.encode("utf-8")
5055
print("Using private key {}, and plaintext message {!r}".format(private_key_file, in_bytes))
@@ -106,5 +111,6 @@ def main() -> int:
106111
else:
107112
raise ValueError("Unknown type {!r}".format(args.type))
108113

114+
109115
if __name__ == "__main__":
110116
sys.exit(main())

util/autogen_testutils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import argparse
1717
import glob
18+
import logging
1819
import sys
1920
from pathlib import Path
2021

util/design/gen-mubi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
from mubi import prim_mubi
88
from secded_gen import format_c_files
99

10+
1011
def main():
1112
prim_mubi.gen()
1213
c_path = prim_mubi.get_c_path()
1314

1415
format_c_files(c_path, c_path)
1516

17+
1618
if __name__ == "__main__":
1719
main()

0 commit comments

Comments
 (0)