Exporting and Importing Designs

Helper functions for reading and writing hardware files.

Each of the functions in inputoutput take a block and a file descriptor. The functions provided either read the file and update the Block accordingly, or write information from the Block out to the file.

pyrtl.inputoutput.input_from_blif(blif, block=None, merge_io_vectors=True)

Read an open blif file or string as input, updating the block appropriately

Assumes the blif has been flattened and their is only a single module. Assumes that there is only one single shared clock and reset Assumes that output is generated by Yosys with formals in a particular order Ignores reset signal (which it assumes is input only to the flip flops)

pyrtl.inputoutput.output_to_firrtl(open_file, rom_blocks=None, block=None)

Output the block as firrtl code to the output file.

Output_to_firrtl(open_file, rom_block, block) If rom is intialized in pyrtl code, you can pass in the rom_blocks as a list [rom1, rom2, …]

pyrtl.inputoutput.net_graph(block=None, split_state=False)

Return a graph representation of the current block.

Graph has the following form:
{ node1: { nodeA: edge1A, nodeB: edge1B},
node2: { nodeB: edge2B, nodeC: edge2C}, …

}

aka: edge = graph[source][dest]

Each node can be either a logic net or a WireVector (e.g. an Input, and Output, a Const or even an undriven WireVector (which acts as a source or sink in the network) Each edge is a WireVector or derived type (Input, Output, Register, etc.) Note that inputs, consts, and outputs will be both “node” and “edge”. WireVectors that are not connected to any nets are not returned as part of the graph.

pyrtl.inputoutput.output_to_trivialgraph(file, namer=<function _trivialgraph_default_namer>, block=None)

Walk the block and output it in trivial graph format to the open file.

pyrtl.inputoutput.output_to_graphviz(file, namer=<function _graphviz_default_namer>, block=None)

Walk the block and output it in graphviz format to the open file.

pyrtl.inputoutput.block_to_graphviz_string(block=None, namer=<function _graphviz_default_namer>)

Return a graphviz string for the block.

pyrtl.inputoutput.block_to_svg(block=None)

Return an SVG for the block.

pyrtl.inputoutput.trace_to_html(simtrace, trace_list=None, sortkey=None)

Return a HTML block showing the trace.

pyrtl.inputoutput.output_to_verilog(dest_file, block=None)

A function to walk the block and output it in verilog format to the open file

class pyrtl.inputoutput.OutputToVerilog(dest_file, block=None)

Bases: object

__init__(dest_file, block=None)

A class implementing the output of a block in verilog format to an open file

pyrtl.inputoutput.output_verilog_testbench(dest_file, simulation_trace=None, block=None)

Output a verilog testbanch for the block/inputs used in the simulation trace.