Skip to content

Commit

Permalink
Fix width/height calculation of fabric + small fixes (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobTernes authored Oct 3, 2023
1 parent c4699d3 commit e369f5e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fabric_generator/fabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def __repr__(self) -> str:
fabric += f"numberOfRows: {self.numberOfRows}\n"
fabric += f"configBitMode: {self.configBitMode}\n"
fabric += f"frameBitsPerRow: {self.frameBitsPerRow}\n"
fabric += f"frameBitsPerColumn: {self.maxFramesPerCol}\n"
fabric += f"maxFramesPerCol: {self.maxFramesPerCol}\n"
fabric += f"package: {self.package}\n"
fabric += f"generateDelayInSwitchMatrix: {self.generateDelayInSwitchMatrix}\n"
fabric += f"multiplexerStyle: {self.multiplexerStyle}\n"
Expand Down
28 changes: 24 additions & 4 deletions geometry_generator/fabric_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,30 @@ def generateGeometry(self) -> None:

# this step is for figuring out the fabric dimensions
# as tile dimensions are fixed by now.
bottomRightTile = self.fabric.tile[-1][-1]
bottomRightTileGeom = self.tileGeomMap[bottomRightTile.name]
self.width = self.tileLocs[-1][-1].x + bottomRightTileGeom.width
self.height = self.tileLocs[-1][-1].y + bottomRightTileGeom.height
# Because of the top left point of the fabric being
# the origin (0, 0), the fabrics dimensions can be
# figured out by determining the rightmost and
# bottommost points of the fabric.
rightMostX = 0
bottomMostY = 0
for i in range(self.fabric.numberOfRows):
tile = self.fabric.tile[i][-1]
if tile is not None:
tileGeom = self.tileGeomMap[tile.name]
tileLoc = self.tileLocs[i][-1]
tileRightmostX = tileLoc.x + tileGeom.width
rightMostX = max(rightMostX, tileRightmostX)

for j in range(self.fabric.numberOfColumns):
tile = self.fabric.tile[-1][j]
if tile is not None:
tileGeom = self.tileGeomMap[tile.name]
tileLoc = self.tileLocs[-1][j]
tileBottommostY = tileLoc.y + tileGeom.height
bottomMostY = max(bottomMostY, tileBottommostY)

self.width = rightMostX
self.height = bottomMostY

# this step is for rearranging the switch matrices by setting
# the relX/relY appropriately. This is done to ensure that
Expand Down
4 changes: 2 additions & 2 deletions geometry_generator/sm_geometry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List
from fabric_generator.fabric import Port, Tile, Direction, Side
from fabric_generator.fabric import Port, Tile, Direction, Side, IO
from geometry_generator.geometry_obj import Border
from geometry_generator.bel_geometry import BelGeometry
from geometry_generator.port_geometry import PortGeometry, PortType
Expand Down Expand Up @@ -186,7 +186,7 @@ def preprocessPorts(self, tileBorder: Border) -> None:
firstPort.destinationName,
firstPort.wireCount,
firstPortName,
firstPort.inOut,
IO.INOUT,
firstPort.sideOfTile
)
mergedJumpPorts.append(mergedPort)
Expand Down

0 comments on commit e369f5e

Please sign in to comment.