All circuits have ports, either input or output.
Bidirectional ports are supported, but not recommended, in py4hw.
The InPort and OutPort classes have similar fields and methods.
| Field | Description |
|---|---|
| name | The name of the port |
| parent | The parent circuit (Logic derived object) containing the port |
| wire | The wire currently connected to the port |
| Field | Description |
|---|---|
| getFullPath | Returns the name (with the full path) of the port |
import py4hw
sys = py4hw.HWSystem()
a = sys.wire('a', 32)
reset = sys.wire('reset')
inc = sys.wire('inc', 1)
cnt = py4hw.Counter(sys, 'count', reset=reset, inc=inc, q=a)
py4hw.CircuitAnalysis.getAllPortNames(cnt)
['reset', 'inc', 'q']
Input ports is just a list of InPort objects
cnt.inPorts
[<py4hw.base.InPort at 0x17b02fa0950>, <py4hw.base.InPort at 0x17b031022d0>]
cnt.inPorts[0].__dict__
{'name': 'reset',
'parent': <py4hw.logic.arithmetic.Counter at 0x17b03102150>,
'wire': <py4hw.base.Wire at 0x17b02d29350>}
Similarly, output ports is another list of OutPort objects
cnt.outPorts
[<py4hw.base.OutPort at 0x17b03101fd0>]
cnt.outPorts[0].__dict__
{'name': 'q',
'parent': <py4hw.logic.arithmetic.Counter at 0x17b03102150>,
'wire': <py4hw.base.Wire at 0x17b0276b110>}