Skip to content

Commit

Permalink
mux fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinChung2000 committed Oct 21, 2024
1 parent dbe4c22 commit 9c02485
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions FABulous/fabric_generator/fabric_gen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/env python3
# Copyright 2021 University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -644,45 +643,26 @@ def genTileSwitchMatrix(self, tile: Tile) -> None:
elif muxSize >= 2:
# this is the case for a configurable switch matrix multiplexer
old_ConfigBitstreamPosition = configBitstreamPosition
# len(connections[portName]).bit_length()-1 tells us how many configuration bits a multiplexer takes

numGnd = 0
muxComponentName = ""
if (self.fabric.multiplexerStyle == MultiplexerStyle.CUSTOM) and (
muxSize == 2
):
muxComponentName = "my_mux2"
elif (self.fabric.multiplexerStyle == MultiplexerStyle.CUSTOM) and (
2 < muxSize <= 4
):
muxComponentName = "cus_mux41_buf"
numGnd = 4 - muxSize
elif (self.fabric.multiplexerStyle == MultiplexerStyle.CUSTOM) and (
4 < muxSize <= 8
):
muxComponentName = "cus_mux81_buf"
numGnd = 8 - muxSize
elif (self.fabric.multiplexerStyle == MultiplexerStyle.CUSTOM) and (
8 < muxSize <= 16
):
muxComponentName = "cus_mux161_buf"
numGnd = 16 - muxSize
# Pad mux size to the next power of 2
paddedMuxSize = 2 ** (muxSize - 1).bit_length()
muxComponentName = f"cus_mux{paddedMuxSize}1_buf"

portsPairs = []
start = 0
for start in range(muxSize):
portsPairs.append((f"A{start}", f"{portName}_input[{start}]"))

for end in range(start, numGnd):
for end in range(start + 1, paddedMuxSize):
portsPairs.append((f"A{end}", "GND0"))

if self.fabric.multiplexerStyle == MultiplexerStyle.CUSTOM:
if muxSize == 2:
if paddedMuxSize == 2:
portsPairs.append(
("S", f"ConfigBits[{configBitstreamPosition}+0]")
)
else:
for i in range(muxSize.bit_length() - 1):
for i in range(paddedMuxSize.bit_length() - 1):
portsPairs.append(
(f"S{i}", f"ConfigBits[{configBitstreamPosition}+{i}]")
)
Expand Down Expand Up @@ -710,8 +690,8 @@ def genTileSwitchMatrix(self, tile: Tile) -> None:
portsPairs=portsPairs,
)
if muxSize != 2 and muxSize != 4 and muxSize != 8 and muxSize != 16:
print(
f"HINT: creating a MUX-{muxSize} for port {portName} using MUX-{muxSize} in switch matrix for tile {tile.name}"
logger.warning(
f"creating a MUX-{muxSize} for port {portName} using MUX-{muxSize} in switch matrix for tile {tile.name}"
)
else:
# generic multiplexer
Expand Down Expand Up @@ -2521,9 +2501,9 @@ def generateBitsStreamSpec(self) -> Dict[str, Dict]:
curTileMapNoMask[pip] = {}

curTileMap[pip][encodeDict[curBitOffset + c]] = curChar
curTileMapNoMask[pip][
encodeDict[curBitOffset + c]
] = curChar
curTileMapNoMask[pip][encodeDict[curBitOffset + c]] = (
curChar
)

curBitOffset += controlWidth

Expand Down

0 comments on commit 9c02485

Please sign in to comment.