VPR Netlist¶
-
template<typename
BlockId, typenamePortId, typenamePinId, typenameNetId>
classNetlist¶ Public Types
-
typedef std::unordered_map<std::string, std::string>::const_iterator
attr_iterator¶
-
typedef std::unordered_map<std::string, std::string>::const_iterator
param_iterator¶
-
typedef vtr::Range<block_iterator>
block_range¶
-
typedef vtr::Range<attr_iterator>
attr_range¶
-
typedef vtr::Range<param_iterator>
param_range¶
-
typedef vtr::Range<net_iterator>
net_range¶
-
typedef vtr::Range<pin_iterator>
pin_range¶
-
typedef vtr::Range<port_iterator>
port_range¶
Public Functions
-
Netlist(std::string name = "", std::string id = "")¶
-
~Netlist()¶
-
const std::string &
netlist_name() const¶ Retrieve the name of the netlist.
-
const std::string &
netlist_id() const¶ Retrieve the unique identifier for this netlist This is typically a secure digest of the input file.
-
bool
verify() const¶ Sanity check for internal consistency (throws an exception on failure)
-
bool
is_dirty() const¶ Returns true if the netlist has invalid entries due to modifications (e.g. from remove_*() calls)
-
bool
is_compressed() const¶ Returns true if the netlist has no invalid entries due to modifications (e.g. from remove_*() calls)
- Note
This is a convenience method which is the logical inverse of is_dirty()
-
void
print_stats() const¶ Item counts and container info (for debugging)
-
bool
block_is_combinational(const BlockId blk_id) const¶ Returns true if the block is purely combinational (i.e. no input clocks and not a primary input.
-
attr_range
block_attrs(const BlockId blk_id) const¶ Returns a range of all attributes associated with the specified block.
-
param_range
block_params(const BlockId blk_id) const¶ Returns a range of all parameters associated with the specified block.
-
pin_range
block_pins(const BlockId blk_id) const¶ Returns a range of all pins associated with the specified block.
-
pin_range
block_input_pins(const BlockId blk_id) const¶ Returns a range of all input pins associated with the specified block.
-
pin_range
block_output_pins(const BlockId blk_id) const¶ Returns a range of all output pins associated with the specified block.
- Note
This is typically only data pins, but some blocks (e.g. PLLs) can produce outputs which are clocks.
-
pin_range
block_clock_pins(const BlockId blk_id) const¶ Returns a range of all clock pins associated with the specified block.
-
port_range
block_ports(const BlockId blk_id) const¶ Returns a range of all ports associated with the specified block.
-
port_range
block_input_ports(const BlockId blk_id) const¶ Returns a range consisting of the input ports associated with the specified block.
-
port_range
block_output_ports(const BlockId blk_id) const¶ Returns a range consisting of the output ports associated with the specified block.
- Note
This is typically only data ports, but some blocks (e.g. PLLs) can produce outputs which are clocks.
-
port_range
block_clock_ports(const BlockId blk_id) const¶ Returns a range consisting of the input clock ports associated with the specified block.
-
void
remove_block(const BlockId blk_id)¶ Removes a block from the netlist. This will also remove the associated ports and pins.
- Parameters
blk_id: The block to be removed
-
BlockId
port_block(const PortId port_id) const¶ Returns the block associated with the specified port.
-
pin_range
port_pins(const PortId port_id) const¶ Returns the set of valid pins associated with the port.
-
PinId
port_pin(const PortId port_id, const BitIndex port_bit) const¶ Returns the pin (potentially invalid) associated with the specified port and port bit index.
- Note
This function is a synonym for find_pin()
- Parameters
port_id: The ID of the associated portport_bit: The bit index of the pin in the port
-
NetId
port_net(const PortId port_id, const BitIndex port_bit) const¶ Returns the net (potentially invalid) associated with the specified port and port bit index.
- Parameters
port_id: The ID of the associated portport_bit: The bit index of the pin in the port
-
BitIndex
port_width(const PortId port_id) const¶ Returns the width (number of bits) in the specified port.
-
void
remove_port(const PortId port_id)¶ Removes a port from the netlist.
The port’s pins are also marked invalid and removed from any associated nets
- Parameters
port_id: The ID of the port to be removed
-
std::string
pin_name(const PinId pin_id) const¶ Returns the constructed name (derived from block and port) for the specified pin.
-
int
pin_net_index(const PinId pin_id) const¶ Returns the index of the specified pin within it’s connected net.
-
BitIndex
pin_port_bit(const PinId pin_id) const¶ Returns the port bit index associated with the specified pin.
-
PortType
pin_port_type(const PinId pin_id) const¶ Returns the port type associated with the specified pin.
-
bool
pin_is_constant(const PinId pin_id) const¶ Returns true if the pin is a constant (i.e. its value never changes)
-
void
remove_pin(const PinId pin_id)¶ Removes a pin from the netlist.
The pin is marked invalid, and removed from any assoicated nets
- Parameters
pin_id: The pin_id of the pin to be removed
-
pin_range
net_pins(const NetId net_id) const¶ Returns a range consisting of all the pins in the net (driver and sinks)
The first element in the range is the driver (and may be invalid) The remaining elements (potentially none) are the sinks
-
PinId
net_pin(const NetId net_id, int net_pin_index) const¶ Returns the net_pin_index’th pin of the specified net.
-
BlockId
net_pin_block(const NetId net_id, int net_pin_index) const¶ Returns the block associated with the net_pin_index’th pin of the specified net.
-
BlockId
net_driver_block(const NetId net_id) const¶ Returns the (potentially invalid) net driver block.
-
pin_range
net_sinks(const NetId net_id) const¶ Returns a (potentially empty) range consisting of net’s sink pins.
-
bool
net_is_constant(const NetId net_id) const¶ Returns true if the net is driven by a constant pin (i.e. its value never changes)
-
void
remove_net(const NetId net_id)¶ Removes a net from the netlist.
This will mark the net’s pins as having no associated.
- Parameters
net_id: The net to be removed
-
void
remove_net_pin(const NetId net_id, const PinId pin_id)¶ Removes a connection betwen a net and pin.
The pin is removed from the net and the pin will be marked as having no associated net
- Parameters
net_id: The net from which the pin is to be removedpin_id: The pin to be removed from the net
-
block_range
blocks() const¶ Returns a range consisting of all blocks in the netlist.
-
port_range
ports() const¶ Returns a range consisting of all ports in the netlist.
-
BlockId
find_block(const std::string &name) const¶ Returns the BlockId of the specified block or BlockId::INVALID() if not found.
- Parameters
name: The name of the block
-
PortId
find_port(const BlockId blk_id, const std::string &name) const¶ Returns the PortId of the specifed port if it exists or PortId::INVALID() if not.
- Note
This method is typically less efficient than searching by a t_model_port With the overloaded AtomNetlist method
- Parameters
blk_id: The ID of the block who’s ports will be checkedname: The name of the port to look for
-
NetId
find_net(const std::string &name) const¶ Returns the NetId of the specified net or NetId::INVALID() if not found.
- Parameters
name: The name of the net
-
PinId
find_pin(const PortId port_id, BitIndex port_bit) const¶ Returns the PinId of the specified pin or PinId::INVALID() if not found.
- Parameters
port_id: The ID of the associated portport_bit: The bit index of the pin in the port
-
PinId
find_pin(const std::string name) const¶ Returns the PinId of the specified pin or PinId::INVALID() if not found.
- Note
This method is SLOW, O(num_pins) avoid if possible
- Parameters
name: The name of the pin
-
void
set_pin_net(const PinId pin, PinType pin_type, const NetId net)¶ Add the specified pin to the specified net as pin_type.
Automatically removes any previous net connection for this pin.
- Parameters
pin: The pin to addpin_type: The type of the pin (i.e. driver or sink)net: The net to add the pin to
-
void
set_pin_is_constant(const PinId pin_id, const bool value)¶ Mark a pin as being a constant generator.
There are some cases where a pin can not be identified as a is constant until after the full netlist has been built; so we expose a way to mark existing pins as constants.
- Parameters
pin_id: The pin to be markedvalue: The boolean value to set the pin_is_constant attribute
-
void
set_block_name(const BlockId blk_id, const std::string new_name)¶ Re-name a block.
- Parameters
blk_id: : The block to be renamednew_name: : The new name for the specified block
-
void
set_block_attr(const BlockId blk_id, const std::string &name, const std::string &value)¶ Set a block attribute.
- Parameters
blk_id: The block to which the attribute is attachedname: The name of the attribute to setvalue: The new value for the specified attribute on the specified block
-
void
set_block_param(const BlockId blk_id, const std::string &name, const std::string &value)¶ Set a block parameter.
- Parameters
blk_id: The block to which the parameter is attachedname: The name of the parameter to setvalue: The new value for the specified parameter on the specified block
-
void
merge_nets(const NetId driver_net, const NetId sink_net)¶ Merges sink_net into driver_net.
After merging driver_net will contain all the sinks of sink_net
- Parameters
driver_net: The net which includes the driver pinsink_net: The target net to be merged into driver_net (must have no driver pin)
-
IdRemapper
remove_and_compress()¶ Wrapper for remove_unused() & compress()
This function should be used in the case where a netlist is fully modified
-
void
remove_unused()¶ This should be called after completing a series of netlist modifications (e.g. removing blocks/ports/pins/nets).
Marks netlist components which have become redundant due to other removals (e.g. ports with only invalid pins) as invalid so they will be destroyed during compress()
-
IdRemapper
compress()¶ Compresses the netlist, removing any invalid and/or unreferenced blocks/ports/pins/nets.
- Note
this invalidates all existing IDs!
-
typedef std::unordered_map<std::string, std::string>::const_iterator