Skip to content

Commit ed363d7

Browse files
feat: fabric name (#627)
* feat: better fabric name * chore: add test * chore: clean to simple test
1 parent 017447c commit ed363d7

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

fabulous/fabric_generator/gen_fabric/gen_fabric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def generateFabric(writer: CodeGenerator, fabric: Fabric) -> None:
3434
# we first scan all tiles if those have IOs that have to go to top
3535
# the order of this scan is later maintained when instantiating the actual tiles
3636
# header
37-
fabricName = "eFPGA"
37+
fabricName = fabric.name
3838
writer.addHeader(fabricName)
3939
writer.addParameterStart(indentLevel=1)
4040
writer.addParameter(

fabulous/fabric_generator/gen_fabric/gen_top_wrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ def split_port(p: str) -> tuple[tuple[int, int], tuple[int, ...], str]:
192192
)
193193
if not (basePath / "eFPGA_Config.vhdl").exists():
194194
raise FileExistsError("Config.vhdl not found in the 'Fabric' directory.")
195-
if not (basePath / "eFPGA.vhdl").exists():
195+
if not (basePath / f"{fabric.name}.vhdl").exists():
196196
raise FileExistsError(
197-
"eFPGA.vhdl not found in the 'Fabric' directory, "
198-
"need to generate the eFPGA first."
197+
f"{fabric.name}.vhdl not found in the 'Fabric' directory, "
198+
f"need to generate the {fabric.name} first."
199199
)
200200
if not (basePath / "BlockRAM_1KB.vhdl").exists():
201201
raise FileExistsError(
@@ -204,7 +204,7 @@ def split_port(p: str) -> tuple[tuple[int, int], tuple[int, ...], str]:
204204
writer.addComponentDeclarationForFile(f"{basePath}/Frame_Data_Reg.vhdl")
205205
writer.addComponentDeclarationForFile(f"{basePath}/Frame_Select.vhdl")
206206
writer.addComponentDeclarationForFile(f"{basePath}/eFPGA_Config.vhdl")
207-
writer.addComponentDeclarationForFile(f"{basePath}/eFPGA.vhdl")
207+
writer.addComponentDeclarationForFile(f"{basePath}/{fabric.name}.vhdl")
208208
writer.addComponentDeclarationForFile(f"{basePath}/BlockRAM_1KB.vhdl")
209209

210210
writer.addLogicStart()

fabulous/fabulous_cli/fabulous_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def do_load_fabric(self, args: argparse.Namespace) -> None:
469469
raise ValueError
470470

471471
proj_dir = get_context().proj_dir
472-
if (proj_dir / "eFPGA_geometry.csv").exists():
472+
if (proj_dir / f"{self.fabulousAPI.fabric.name}_geometry.csv").exists():
473473
self.enable_category(CMD_GUI)
474474

475475
self.enable_category(CMD_FABRIC_FLOW)

tests/fabric_gen_test/fabric_test/__init__.py

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Tests for fabric generation with custom fabric names."""
2+
3+
import pytest
4+
from pytest_mock import MockerFixture
5+
6+
from fabulous.fabric_definition.define import ConfigBitMode
7+
from fabulous.fabric_definition.fabric import Fabric
8+
from fabulous.fabric_generator.code_generator.code_generator import CodeGenerator
9+
from fabulous.fabric_generator.gen_fabric.gen_fabric import generateFabric
10+
11+
12+
def test_generate_fabric_uses_fabric_name(mocker: MockerFixture) -> None:
13+
"""generateFabric should use fabric.name as the module name."""
14+
fabric = mocker.create_autospec(Fabric)
15+
fabric.name = "test_fabric"
16+
fabric.tile = []
17+
fabric.configBitMode = ConfigBitMode.FLIPFLOP_CHAIN
18+
fabric.maxFramesPerCol = 20
19+
fabric.frameBitsPerRow = 32
20+
fabric.numberOfRows = 0
21+
fabric.numberOfColumns = 0
22+
23+
writer = mocker.create_autospec(CodeGenerator)
24+
25+
generateFabric(writer, fabric)
26+
27+
writer.addHeader.assert_called_once_with("test_fabric")

0 commit comments

Comments
 (0)