Py4Hw User Guide> 6.1 Schematic Visualization¶

Next: 6.2 Manipulating Schematics¶

The visualization of circuit schematics is implemented from scratch in the framework.

In [1]:
import py4hw
import matplotlib.pyplot as plt

The schematic object allows to control various things of the visualization process. For instance, we can observe the internal occupancy grid used by the place & route algorithm

In [2]:
sys = py4hw.HWSystem()
reset = sys.wire('reset')
inc = sys.wire('inc')
q = sys.wire('q', 8)
co = sys.wire('co')

counter = py4hw.ModuloCounter(sys, 'mod7', 7, reset, inc, q, co)
sch = py4hw.Schematic(counter)

#q2 = sys.wire('q2', 8)
#count = sys.wire('count', 8)


#py4hw.Sequence(sys, 'inc', [0, 1], inc)
#py4hw.Add(sys, 'counter', q, inc, count)
#py4hw.Reg(sys, 'reg2', d=count, enable=inc, q=q2)
#py4hw.Reg(sys, 'reg', d=q2, enable=inc, q=q)
#py4hw.Scope(sys, 'q', q)
    
#sch = py4hw.Schematic(sys)
#sch.createRender((20,5), dpi=100)
#sch.draw()
grid = sch.getOccupancyGrid()
plt.imshow(grid)
plt.show()
In [3]:
sch.createRender()
sch.draw()
#sch.drawAll()

Disecting the Place and Route process

In [12]:
sch = py4hw.Schematic(counter, placeAndRoute=False)

sch.placeInputPorts()
sch.placeInstances()
sch.placeOutputPorts()
sch.replaceAsColRow()

sch.columnAssignment()
sch.replaceAsColRow()

#sch.createNetsWithMaxFanout(3)
sch.createNets()
sch.replaceAsColRow()
sch.passthroughCreation(debug=False)
sch.replaceAsColRow()
#sch.removeArrowsSpecialCases()


#for idx, net in enumerate(sch.nets):
#    print('net {} - sourcecol: {}'.format(idx, net.sourcecol))
    
sch.trackAssignment()
sch.replaceAsColRow()

#self.replaceByAdjacencyMatrix()

# self.replaceByDependency()

#self.replaceVerticalCompress()
# #self.replaceHorizontalCompress()


sch.routeNets(mode='direct')

sch.draw()
In [5]:
sch.channels[2]
Out[5]:
{'tracks': 5,
 'track': {<py4hw.base.Wire at 0x2b36596c5d0>: {'num': 0,
   'nets': [<py4hw.schematic_symbols.NetSymbol at 0x2b3664d7e50>]},
  <py4hw.base.Wire at 0x2b36596c4d0>: {'num': 1,
   'nets': [<py4hw.schematic_symbols.NetSymbol at 0x2b3664d5a10>]},
  <py4hw.base.Wire at 0x2b36596c6d0>: {'num': 2,
   'nets': [<py4hw.schematic_symbols.NetSymbol at 0x2b3664d5810>]},
  <py4hw.base.Wire at 0x2b36596c550>: {'num': 3,
   'nets': [<py4hw.schematic_symbols.NetSymbol at 0x2b3664d4850>]},
  <py4hw.base.Wire at 0x2b36596c310>: {'num': 4,
   'nets': [<py4hw.schematic_symbols.NetSymbol at 0x2b3664d4090>]}},
 'sourcewidth': 30}

Summary¶

  • The schematic visualizer is implemented from scratch
  • It is open so that we can implement custom steps and improvements