Skip to content

Commit acab691

Browse files
committed
rename inputoutput to importexport to reflect contents more clearly
1 parent f77c321 commit acab691

File tree

8 files changed

+56
-55
lines changed

8 files changed

+56
-55
lines changed

docs/export.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ Exporting and Importing Designs
66
Exporting Hardware Designs
77
--------------------------
88

9-
.. autofunction:: pyrtl.inputoutput.output_to_verilog
9+
.. autofunction:: pyrtl.importexport.output_to_verilog
1010

11-
.. autofunction:: pyrtl.inputoutput.output_to_firrtl
11+
.. autofunction:: pyrtl.importexport.output_to_firrtl
1212

1313
Exporting Testbenches
1414
------------------------
1515

16-
.. autofunction:: pyrtl.inputoutput.output_verilog_testbench
16+
.. autofunction:: pyrtl.importexport.output_verilog_testbench
1717

1818

1919
Importing Verilog
2020
-----------------
2121

22-
.. autofunction:: pyrtl.inputoutput.input_from_blif
22+
.. autofunction:: pyrtl.importexport.input_from_blif
2323

2424

2525
Outputting for Visualization

pyrtl/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@
9191
from .visualization import trace_to_html
9292
from .visualization import net_graph
9393

94-
# input and output to file format routines
95-
from .inputoutput import output_to_verilog
96-
from .inputoutput import OutputToVerilog
97-
from .inputoutput import output_verilog_testbench
98-
from .inputoutput import input_from_blif
99-
from .inputoutput import output_to_firrtl
94+
# import from and export to file format routines
95+
from .importexport import output_to_verilog
96+
from .importexport import OutputToVerilog
97+
from .importexport import output_verilog_testbench
98+
from .importexport import input_from_blif
99+
from .importexport import output_to_firrtl
100100

101101
# different transform passes
102102
from .passes import common_subexp_elimination

pyrtl/analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .core import working_block
1717
from .wire import Input, Const, Register
1818
from .pyrtlexceptions import PyrtlError, PyrtlInternalError
19-
from .inputoutput import output_to_verilog
19+
from .importexport import output_to_verilog
2020
from .memory import RomBlock
2121
from .helperfuncs import _currently_in_jupyter_notebook, _print_netlist_latex
2222

pyrtl/inputoutput.py renamed to pyrtl/importexport.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Helper functions creating verilog implementations and testbenches.
2+
Helper functions for reading and writing hardware files.
33
44
Each of the functions in inputoutput take a block and a file descriptor.
55
The functions provided either read the file and update the Block
@@ -640,12 +640,6 @@ def _to_verilog_footer(file):
640640
print('endmodule\n', file=file)
641641

642642

643-
# ----------------------------------------------------------------
644-
# ___ ___ __ ___ __ ___ __
645-
# | |__ /__` | |__) |__ |\ | / ` |__|
646-
# | |___ .__/ | |__) |___ | \| \__, | |
647-
#
648-
649643
def output_verilog_testbench(dest_file, simulation_trace=None, toplevel_include=None,
650644
vcd="waveform.vcd", cmd=None, block=None):
651645
""" Output a Verilog testbench for the block/inputs used in the simulation trace.

pyrtl/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .wire import Input, Register, Const, Output, WireVector
1313
from .memory import RomBlock
1414
from .helperfuncs import check_rtl_assertions, _currently_in_jupyter_notebook
15-
from .inputoutput import _VerilogSanitizer
15+
from .importexport import _VerilogSanitizer
1616

1717
# ----------------------------------------------------------------
1818
# __ ___ __

pyrtl/visualization.py

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
2-
Helper functions for reading and writing hardware files.
2+
Helper functions for viewing the block visually.
33
4-
Each of the functions in inputoutput take a block and a file descriptor.
5-
The functions provided either read the file and update the Block
6-
accordingly, or write information from the Block out to the file.
4+
Each of the functions in visualization take a block and a file descriptor.
5+
The functions provided write the block as a given visual format to the file.
76
"""
87

98
from __future__ import print_function, unicode_literals
@@ -13,36 +12,6 @@
1312
from .wire import WireVector, Input, Output, Const, Register
1413

1514

16-
# -----------------------------------------------------------------
17-
# __ ___
18-
# | |\ | |__) | | |
19-
# | | \| | \__/ |
20-
21-
# ----------------------------------------------------------------
22-
# __ ___ __ ___
23-
# / \ | | | |__) | | |
24-
# \__/ \__/ | | \__/ |
25-
#
26-
27-
28-
def _trivialgraph_default_namer(thing, is_edge=True):
29-
""" Returns a "good" string for thing in printed graphs. """
30-
if is_edge:
31-
if thing.name is None or thing.name.startswith('tmp'):
32-
return ''
33-
else:
34-
return '/'.join([thing.name, str(len(thing))])
35-
elif isinstance(thing, Const):
36-
return str(thing.val)
37-
elif isinstance(thing, WireVector):
38-
return thing.name or '??'
39-
else:
40-
try:
41-
return thing.op + str(thing.op_param or '')
42-
except AttributeError:
43-
raise PyrtlError('no naming rule for "%s"' % str(thing))
44-
45-
4615
def net_graph(block=None, split_state=False):
4716
""" Return a graph representation of the given block.
4817
@@ -107,6 +76,29 @@ def net_graph(block=None, split_state=False):
10776
return graph
10877

10978

79+
# -----------------------------------------------------------------
80+
# ___ __ ___
81+
# | / _` |___
82+
# | \__> |
83+
84+
def _trivialgraph_default_namer(thing, is_edge=True):
85+
""" Returns a "good" string for thing in printed graphs. """
86+
if is_edge:
87+
if thing.name is None or thing.name.startswith('tmp'):
88+
return ''
89+
else:
90+
return '/'.join([thing.name, str(len(thing))])
91+
elif isinstance(thing, Const):
92+
return str(thing.val)
93+
elif isinstance(thing, WireVector):
94+
return thing.name or '??'
95+
else:
96+
try:
97+
return thing.op + str(thing.op_param or '')
98+
except AttributeError:
99+
raise PyrtlError('no naming rule for "%s"' % str(thing))
100+
101+
110102
def output_to_trivialgraph(file, namer=_trivialgraph_default_namer, block=None, split_state=False):
111103
""" Walk the block and output it in trivial graph format to the open file.
112104
@@ -139,6 +131,11 @@ def output_to_trivialgraph(file, namer=_trivialgraph_default_namer, block=None,
139131
print('%d %d %s' % (from_index, to_index, namer(edge)), file=file)
140132

141133

134+
# -----------------------------------------------------------------
135+
# __ __ __ __ __
136+
# / _` |__) |__| |__) |__| \ / | /
137+
# \__> | \ | | | | | \/ | /__
138+
142139
def _default_edge_namer(edge, is_to_splitmerge=False, extra_edge_info=None):
143140
"""
144141
A function for naming an edge for use in the graphviz graph.
@@ -376,6 +373,11 @@ def block_to_graphviz_string(block=None, namer=_graphviz_default_namer, split_st
376373
return rstring
377374

378375

376+
# -----------------------------------------------------------------
377+
# __ __
378+
# /__` \ / / _`
379+
# .__/ \/ \__>
380+
379381
def output_to_svg(file, block=None, split_state=True):
380382
""" Output the block as an SVG to the open file.
381383
@@ -400,6 +402,11 @@ def block_to_svg(block=None, split_state=True):
400402
raise PyrtlError('need graphviz installed (try "pip install graphviz")')
401403

402404

405+
# -----------------------------------------------------------------
406+
# ___
407+
# |__| | |\/| |
408+
# | | | | | |___
409+
403410
def trace_to_html(simtrace, trace_list=None, sortkey=None):
404411
""" Return a HTML block showing the trace.
405412

tests/test_inputoutput.py renamed to tests/test_importexport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io
44
import six
55
import pyrtl
6-
from pyrtl.inputoutput import _VerilogSanitizer
6+
from pyrtl.importexport import _VerilogSanitizer
77
from pyrtl.rtllib import testingutils as utils
88

99

tests/test_visualization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import random
33
import io
44
import pyrtl
5-
from .test_inputoutput import full_adder_blif
5+
from .test_importexport import full_adder_blif
66

77

88
graphviz_string = """

0 commit comments

Comments
 (0)