Note
Click here to download the full example code
3.1. Demonstrate how to render basic floorplan¶
This script implements simple floorplanning visualization using SVG images.
The visualizer uses the information stored in each Verilog object (as a PROP) to perform shaping and placement of each block. but there is no explicit routing performed, all the edges are connected from point to point.
Detail of properties of different objects
On Definitions
SHAPE
= Shape of the module [Rect (Default), cross, custom]
Parameters for
Rect
WIDTH
andHEIGHT
= The rectangular dimension of the module
Parameters for
cross
A
,B
,C
,D
,E
,F
= Dimensions of the rectilinear block (as show in figure below)
Parameters for
custom
It is represented by a sequence of numbers <Start_direction(V/H)> <FirstPoint (int int)> <Sequence of vertical and horizontal distance>, and the last point connects to the start point automatically
For example following example creates rectangle: V 0 0 10 20 20
d
┌──────────┐
│ │
c│ │
b │ │ e
┌──────┘ └──────┐
│ │
a│ │
│ │
└──────┐ ┌──────┘
│ │
f│ │
│ │
└──────────┘
cross Shape
On Instances
LOC_X
and LOC_Y
= Location of the component with respect to its parent
Ports Placement:
SIDE
:
Shape size where module port is placed [left/right/bottom/top]
SIDE2
:
Optional and valid only when shape in cross [left/right/bottom/top]
OFFSET
:
Offset from the origin of that side
The first point on the respective side in a clockwise direction is considered as the origin
top/top
┌──────────┐
top/left │ | top/right
│ │
left/top │ │ right/top
┌──────┘ └──────┐
│ │
left/left │ 0 │ right/right
│ │
└──────┐ ┌──────┘
left/bottom │ │ right/bottom
│ │
bottom/left │ | bottom/right
└──────────┘
bottom/bottom
Representing SIDE/SIDE2 parameters
TODO Add Some sort of coordinate transformation which scaleX and scaleY. All the inputs are in multiple SC_HEIGHT and SC_WIDTH, a default value of these variables is set to 1
3.1.1. Output¶
Download final annotated verilog netlist:
_annotate_netlist.v
import logging
import spydrnet as sdn
import spydrnet_physical as sdnphy
from spydrnet_physical.util import FloorPlanViz
PROPERTY = "VERILOG.InlineConstraints"
logger = logging.getLogger('spydrnet_logs')
sdn.enable_file_logging(LOG_LEVEL='DEBUG', filename="01_floorplan_rendering")
netlist = sdnphy.load_netlist_by_name('basic_hierarchy')
top = netlist.top_instance.reference
module1 = next(netlist.get_definitions("module1"))
module2 = next(netlist.get_definitions("module2"))
inst_1_0 = next(top.get_instances("inst_1_0"))
inst_1_1 = next(top.get_instances("inst_1_1"))
inst_2_0 = next(top.get_instances("inst_2_0"))
inst_2_1 = next(top.get_instances("inst_2_1"))
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Set the WIDTH HEIGHT on the defition
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
top.properties["WIDTH"] = "250"
top.properties["HEIGHT"] = "250"
module1.properties["HEIGHT"] = "60"
module1.properties["HEIGHT"] = "60"
module2.properties["HEIGHT"] = "40"
module2.properties["HEIGHT"] = "40"
module1.properties["SHAPE"] = "cross" # cross Shape
module1.properties["POINTS"] = [25, 25, 25, 25, 25, 25] # A, B, C, D , E, F
module2.properties["SHAPE"] = "custom" # cross Shape
module2.properties["POINTS"] = "V 0 0 10 -10 10 30 -20 -20"
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Set the Pin locations on the Modules
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
next(top.get_ports("in0")).properties["SIDE"] = "left"
next(top.get_ports("in0")).properties["OFFSET"] = "10"
next(top.get_ports("in1")).properties["SIDE"] = "left"
next(top.get_ports("in1")).properties["OFFSET"] = "30"
next(top.get_ports("bus_in")).properties["SIDE"] = "left"
next(top.get_ports("bus_in")).properties["OFFSET"] = "50"
next(top.get_ports("out0")).properties["SIDE"] = "right"
next(top.get_ports("out0")).properties["OFFSET"] = "20"
next(top.get_ports("bus_out")).properties["SIDE"] = "right"
next(top.get_ports("bus_out")).properties["OFFSET"] = "40"
next(module1.get_ports("in0")).properties["SIDE"] = "top"
next(module1.get_ports("in0")).properties["SIDE2"] = "right"
next(module1.get_ports("in0")).properties["OFFSET"] = "10"
next(module1.get_ports("in1")).properties["SIDE"] = "left"
next(module1.get_ports("in1")).properties["OFFSET"] = "10"
next(module1.get_ports("out")).properties["SIDE"] = "right"
next(module1.get_ports("out")).properties["OFFSET"] = "20"
next(module2.get_ports("in0")).properties["SIDE"] = "left"
next(module2.get_ports("in0")).properties["OFFSET"] = "10"
next(module2.get_ports("in1")).properties["SIDE"] = "left"
next(module2.get_ports("in1")).properties["OFFSET"] = "30"
next(module2.get_ports("out")).properties["SIDE"] = "right"
next(module2.get_ports("out")).properties["OFFSET"] = "20"
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# Set the LOC_X, LOC_Y on all the instances
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
inst_1_0.properties["LOC_X"] = "50"
inst_1_0.properties["LOC_Y"] = "50"
inst_1_1.properties["LOC_X"] = "50"
inst_1_1.properties["LOC_Y"] = "150"
inst_2_0.properties["LOC_X"] = "150"
inst_2_0.properties["LOC_Y"] = "50"
inst_2_1.properties["LOC_X"] = "150"
inst_2_1.properties["LOC_Y"] = "150"
fp = FloorPlanViz(top)
fp.compose(skip_connections=False)
dwg = fp.get_svg()
dwg.saveas("_basic_hierarchy_floorplan.svg", pretty=True, indent=4)
sdn.compose(netlist, '_annotate_netlist.v')
Total running time of the script: ( 0 minutes 0.000 seconds)