ice40: More Python bindings and examples
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
parent
547d4fe3ee
commit
1d39924c14
@ -161,6 +161,7 @@ int main(int argc, char *argv[])
|
||||
Design design(chipArgs);
|
||||
init_python(argv[0]);
|
||||
python_export_global("design", design);
|
||||
python_export_global("chip", design.chip);
|
||||
|
||||
if (vm.count("test")) {
|
||||
int bel_count = 0, wire_count = 0, pip_count = 0;
|
||||
|
@ -66,7 +66,22 @@ void arch_wrap_python()
|
||||
.def("getBelName", &Chip::getBelName)
|
||||
.def("getWireName", &Chip::getWireName)
|
||||
.def("getBels", &Chip::getBels)
|
||||
.def("getWires", &Chip::getWires);
|
||||
.def("getBelType", &Chip::getBelType)
|
||||
.def("getWireBelPin", &Chip::getWireBelPin)
|
||||
.def("getBelPinUphill", &Chip::getBelPinUphill)
|
||||
.def("getBelPinsDownhill", &Chip::getBelPinsDownhill)
|
||||
.def("getWires", &Chip::getWires)
|
||||
.def("getPipByName", &Chip::getPipByName)
|
||||
.def("getPipName", &Chip::getPipName)
|
||||
.def("getPips", &Chip::getPips)
|
||||
.def("getPipSrcWire", &Chip::getPipSrcWire)
|
||||
.def("getPipDstWire", &Chip::getPipDstWire)
|
||||
.def("getPipDelay", &Chip::getPipDelay)
|
||||
.def("getPipsDownhill", &Chip::getPipsDownhill)
|
||||
.def("getPipsUphill", &Chip::getPipsUphill)
|
||||
.def("getWireAliases", &Chip::getWireAliases)
|
||||
.def("getBelPosition", &Chip::getBelPosition)
|
||||
.def("getWirePosition", &Chip::getWirePosition);
|
||||
|
||||
WRAP_RANGE(Bel);
|
||||
WRAP_RANGE(BelPin);
|
||||
|
@ -1,2 +1,21 @@
|
||||
def test_function():
|
||||
print("Hello World!")
|
||||
def get_drivers(wire):
|
||||
wid = chip.getWireByName(wire)
|
||||
assert not wid.nil(), "wire {} not found".format(wire)
|
||||
bp = chip.getBelPinUphill(wid)
|
||||
if not bp.bel.nil():
|
||||
print("Bel pin: {}.{}".format(chip.getBelName(bp.bel), str(bp.pin)))
|
||||
for pip in sorted(chip.getPipsUphill(wid), key=lambda x: x.index):
|
||||
print("Pip: {}".format(chip.getWireName(chip.getPipSrcWire(pip))))
|
||||
|
||||
|
||||
def get_loads(wire):
|
||||
wid = chip.getWireByName(wire)
|
||||
assert not wid.nil(), "wire {} not found".format(wire)
|
||||
for bp in sorted(chip.getBelPinsDownhill(wid), key=lambda x: (x.bel.index, x.pin)):
|
||||
print("Bel pin: {}.{}".format(chip.getBelName(bp.bel), str(bp.pin)))
|
||||
for pip in sorted(chip.getPipsDownhill(wid), key=lambda x: x.index):
|
||||
print("Pip: {}".format(chip.getWireName(chip.getPipDstWire(pip))))
|
||||
|
||||
|
||||
#get_drivers("12_14_lutff_7/in_3")
|
||||
#get_loads("12_14_lutff_global/clk")
|
||||
|
@ -1,6 +1,2 @@
|
||||
from nextpnrpy_ice40 import Chip, ChipArgs, iCE40Type
|
||||
args = ChipArgs()
|
||||
args.type = iCE40Type.LP384
|
||||
chip = Chip(args)
|
||||
for wire in chip.getWires():
|
||||
print(chip.getWireName(wire))
|
||||
|
Loading…
Reference in New Issue
Block a user