Skip to content

Commit 61c2e5c

Browse files
committed
Move logic from genwrap and genstub to hdl_controller
1 parent cbe3152 commit 61c2e5c

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

hdltools/apps/genstub.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
from hdltools.cli_parser import cli_parser
1010
from hdltools.hdl_controller import HDLController
1111

12-
args = cli_parser('wrap')
13-
ctrl = HDLController('wrap')
14-
code = ctrl.generate(args.file, args.top, args.suffix)
1512

16-
if not args.output:
17-
print(code)
18-
else:
19-
ctrl.write(args.output)
13+
args = cli_parser('stub')
14+
ctrl = HDLController('stub')
15+
ctrl.generate(args.file, args.top, args.suffix)
16+
ctrl.write(args.output)

hdltools/apps/genwrap.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
from hdltools.cli_parser import cli_parser
1010
from hdltools.hdl_controller import HDLController
1111

12+
1213
args = cli_parser('wrap')
1314
ctrl = HDLController('wrap')
14-
code = ctrl.generate(args.file, args.top, args.suffix)
15-
16-
if not args.output:
17-
print(code)
18-
else:
19-
ctrl.write(args.output)
15+
ctrl.generate(args.file, args.top, args.suffix)
16+
ctrl.write(args.output)

hdltools/hdl_controller.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ def generate(self, filepath, top=None, suffix=None):
5454
return self.writer.get_code()
5555

5656
def write(self, filepath):
57-
"""Writes the generated HDL code to the specified file."""
58-
self.writer.write_file(filepath)
57+
"""Writes the generated HDL code."""
58+
if not filepath:
59+
print(self.writer.get_code())
60+
else:
61+
self.writer.write_file(filepath)
5962

6063
@staticmethod
6164
def _error(message, ecode=1):

0 commit comments

Comments
 (0)