From b5e341a287cf940bdabe81ea56d50095e9216fd4 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 29 Nov 2024 20:13:59 +0100 Subject: [PATCH] Example uarch using new API features --- himbaechel/uarch/example/constids.inc | 2 + himbaechel/uarch/example/example.cc | 288 ++++++++++--------- himbaechel/uarch/example/example_arch_gen.py | 2 + 3 files changed, 152 insertions(+), 140 deletions(-) diff --git a/himbaechel/uarch/example/constids.inc b/himbaechel/uarch/example/constids.inc index eca9b10827..c5e30f3537 100644 --- a/himbaechel/uarch/example/constids.inc +++ b/himbaechel/uarch/example/constids.inc @@ -41,3 +41,5 @@ X(LOGIC) X(BRAM) X(IO) X(NULL) + +X(SWITCHBOX) \ No newline at end of file diff --git a/himbaechel/uarch/example/example.cc b/himbaechel/uarch/example/example.cc index 42b7608668..6a51fc464c 100644 --- a/himbaechel/uarch/example/example.cc +++ b/himbaechel/uarch/example/example.cc @@ -139,166 +139,175 @@ struct ExampleImpl : HimbaechelAPI return true; } + void drawGroup(std::vector &g, IdString group_type, Loc loc) override + { + if (group_type == id_SWITCHBOX) { + GraphicElement el; + el.type = GraphicElement::TYPE_BOX; + el.style = GraphicElement::STYLE_FRAME; + + el.x1 = loc.x + 0.1; + el.x2 = el.x1 + 0.4; + el.y1 = loc.y + 0.1; + el.y2 = el.y1 + 0.8; + g.push_back(el); + } + } void drawBel(std::vector &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override { GraphicElement el; el.type = GraphicElement::TYPE_BOX; el.style = style; - switch (bel_type.index) - { - case id_LUT4.index : - el.x1 = loc.x + 0.15; - el.x2 = el.x1 + 0.25; - el.y1 = loc.y + 0.85 - (loc.z / 2) * 0.1; - el.y2 = el.y1 - 0.05; - g.push_back(el); - break; - case id_DFF.index : - el.x1 = loc.x + 0.55; - el.x2 = el.x1 + 0.25; - el.y1 = loc.y + 0.85 - (loc.z / 2) * 0.1; - el.y2 = el.y1 - 0.05; - g.push_back(el); - break; - case id_GND_DRV.index : - case id_VCC_DRV.index : - case id_IOB.index : - el.x1 = loc.x + 0.25; - el.x2 = el.x1 + 0.50; - el.y1 = loc.y + 0.80 - loc.z * 0.40; - el.y2 = el.y1 - 0.25; - g.push_back(el); - break; - case id_BRAM_512X16.index : - el.x1 = loc.x + 0.25; - el.x2 = el.x1 + 0.50; - el.y1 = loc.y + 0.80; - el.y2 = el.y1 - 0.60; - g.push_back(el); - break; + switch (bel_type.index) { + case id_LUT4.index: + el.x1 = loc.x + 0.55; + el.x2 = el.x1 + 0.15; + el.y1 = loc.y + 0.90 - (loc.z / 2) * 0.1; + el.y2 = el.y1 - 0.05; + g.push_back(el); + break; + case id_DFF.index: + el.x1 = loc.x + 0.75; + el.x2 = el.x1 + 0.15; + el.y1 = loc.y + 0.90 - (loc.z / 2) * 0.1; + el.y2 = el.y1 - 0.05; + g.push_back(el); + break; + case id_GND_DRV.index: + case id_VCC_DRV.index: + case id_IOB.index: + el.x1 = loc.x + 0.55; + el.x2 = el.x1 + 0.35; + el.y1 = loc.y + 0.90 - loc.z * 0.40; + el.y2 = el.y1 - 0.25; + g.push_back(el); + break; + case id_BRAM_512X16.index: + el.x1 = loc.x + 0.55; + el.x2 = el.x1 + 0.35; + el.y1 = loc.y + 0.90; + el.y2 = el.y1 - 0.60; + g.push_back(el); + break; } } - void drawWire(std::vector &g, GraphicElement::style_t style, Loc loc, IdString wire_type, int32_t tilewire, IdString tile_type) + void drawWire(std::vector &g, GraphicElement::style_t style, Loc loc, IdString wire_type, + int32_t tilewire, IdString tile_type) { GraphicElement el; el.type = GraphicElement::TYPE_LINE; el.style = style; int z; - switch(tile_type.index) - { - case id_LOGIC.index: - switch (wire_type.index) - { - case id_LUT_INPUT.index: - z = (tilewire - GFX_WIRE_L0_I0) / 4; - el.x1 = loc.x + 0.10; - el.x2 = el.x1 + 0.05; - el.y1 = loc.y + 0.85 - z * 0.1 - ((tilewire - GFX_WIRE_L0_I0) % 4 + 1) * 0.01; - el.y2 = el.y1; - g.push_back(el); - break; - case id_LUT_OUT.index: - z = tilewire - GFX_WIRE_L0_O; - el.x1 = loc.x + 0.40; - el.x2 = el.x1 + 0.05; - el.y1 = loc.y + 0.85 - z * 0.1 - 0.025; - el.y2 = el.y1; - g.push_back(el); - break; - case id_FF_DATA.index: - z = tilewire - GFX_WIRE_L0_D; - el.x1 = loc.x + 0.50; - el.x2 = el.x1 + 0.05; - el.y1 = loc.y + 0.85 - z * 0.1 - 0.025; - el.y2 = el.y1; - g.push_back(el); - break; - case id_FF_OUT.index: - z = tilewire - GFX_WIRE_L0_Q; - el.x1 = loc.x + 0.80; - el.x2 = el.x1 + 0.05; - el.y1 = loc.y + 0.85 - z * 0.1 - 0.025; - el.y2 = el.y1; - g.push_back(el); - break; - case id_TILE_CLK.index: - for(int i=0;i<8; i++) { - GraphicElement el; - el.type = GraphicElement::TYPE_LINE; - el.style = style; - el.x1 = loc.x + 0.6; - el.x2 = el.x1; - el.y1 = loc.y + 0.85 - i * 0.1 - 0.05; - el.y2 = el.y1 - 0.05; - g.push_back(el); - } - break; - } + switch (tile_type.index) { + case id_LOGIC.index: + switch (wire_type.index) { + case id_LUT_INPUT.index: + z = (tilewire - GFX_WIRE_L0_I0) / 4; + el.x1 = loc.x + 0.54; + el.x2 = el.x1 + 0.01; + el.y1 = loc.y + 0.90 - z * 0.1 - ((tilewire - GFX_WIRE_L0_I0) % 4 + 1) * 0.01; + el.y2 = el.y1; + g.push_back(el); break; - case id_BRAM.index: - switch (wire_type.index) - { - case id_RAM_IN.index: - z = tilewire - GFX_WIRE_RAM_WA0; - el.x1 = loc.x + 0.20; - el.x2 = el.x1 + 0.05; - el.y1 = loc.y + 0.78 - z * 0.015; - el.y2 = el.y1; - g.push_back(el); - break; - case id_RAM_OUT.index: - z = tilewire - GFX_WIRE_RAM_DO0; - el.x1 = loc.x + 0.75; - el.x2 = el.x1 + 0.05; - el.y1 = loc.y + 0.78 - z * 0.015; - el.y2 = el.y1; - g.push_back(el); - break; - case id_TILE_CLK.index: - el.x1 = loc.x + 0.6; - el.x2 = el.x1; - el.y1 = loc.y + 0.20; - el.y2 = el.y1 - 0.05; - g.push_back(el); - break; - } + case id_LUT_OUT.index: + z = tilewire - GFX_WIRE_L0_O; + el.x1 = loc.x + 0.70; + el.x2 = el.x1 + 0.01; + el.y1 = loc.y + 0.90 - z * 0.1 - 0.025; + el.y2 = el.y1; + g.push_back(el); break; - case id_IO.index: - switch (wire_type.index) - { - case id_IO_I.index: - break; - case id_IO_O.index: - break; - case id_IO_T.index: - break; - case id_IO_PAD.index: - break; - case id_TILE_CLK.index: - break; - case id_GCLK.index: - break; - } + case id_FF_DATA.index: + z = tilewire - GFX_WIRE_L0_D; + el.x1 = loc.x + 0.74; + el.x2 = el.x1 + 0.01; + el.y1 = loc.y + 0.90 - z * 0.1 - 0.025; + el.y2 = el.y1; + g.push_back(el); break; - case id_NULL.index: - switch (wire_type.index) - { - case id_CLK_ROUTE.index: - break; - case id_GND.index: - break; - case id_VCC.index: - break; - case id_TILE_CLK.index: - break; + case id_FF_OUT.index: + z = tilewire - GFX_WIRE_L0_Q; + el.x1 = loc.x + 0.90; + el.x2 = el.x1 + 0.01; + el.y1 = loc.y + 0.90 - z * 0.1 - 0.025; + el.y2 = el.y1; + g.push_back(el); + break; + case id_TILE_CLK.index: + for (int i = 0; i < 8; i++) { + GraphicElement el; + el.type = GraphicElement::TYPE_LINE; + el.style = style; + el.x1 = loc.x + 0.6; + el.x2 = el.x1; + el.y1 = loc.y + 0.90 - i * 0.1 - 0.05; + el.y2 = el.y1 - 0.05; + g.push_back(el); } break; + } + break; + case id_BRAM.index: + switch (wire_type.index) { + case id_RAM_IN.index: + z = tilewire - GFX_WIRE_RAM_WA0; + el.x1 = loc.x + 0.54; + el.x2 = el.x1 + 0.01; + el.y1 = loc.y + 0.90 - z * 0.015 - 0.025; + el.y2 = el.y1; + g.push_back(el); + break; + case id_RAM_OUT.index: + z = tilewire - GFX_WIRE_RAM_DO0; + el.x1 = loc.x + 0.90; + el.x2 = el.x1 + 0.01; + el.y1 = loc.y + 0.90 - z * 0.015 - 0.025; + el.y2 = el.y1; + g.push_back(el); + break; + case id_TILE_CLK.index: + el.x1 = loc.x + 0.60; + el.x2 = el.x1; + el.y1 = loc.y + 0.30; + el.y2 = el.y1 - 0.025; + g.push_back(el); + break; + } + break; + case id_IO.index: + switch (wire_type.index) { + case id_IO_I.index: + break; + case id_IO_O.index: + break; + case id_IO_T.index: + break; + case id_IO_PAD.index: + break; + case id_TILE_CLK.index: + break; + case id_GCLK.index: + break; + } + break; + case id_NULL.index: + switch (wire_type.index) { + case id_CLK_ROUTE.index: + break; + case id_GND.index: + break; + case id_VCC.index: + break; + case id_TILE_CLK.index: + break; + } + break; } } - void drawPip(std::vector &g,GraphicElement::style_t style, Loc loc, - WireId src, IdString src_type, int32_t src_id, WireId dst, IdString dst_type, int32_t dst_id) + void drawPip(std::vector &g, GraphicElement::style_t style, Loc loc, WireId src, IdString src_type, + int32_t src_id, WireId dst, IdString dst_type, int32_t dst_id) { GraphicElement el; el.type = GraphicElement::TYPE_ARROW; @@ -311,7 +320,6 @@ struct ExampleImpl : HimbaechelAPI el.x2 = loc.x + 0.50; el.y2 = el.y1; g.push_back(el); - } } }; diff --git a/himbaechel/uarch/example/example_arch_gen.py b/himbaechel/uarch/example/example_arch_gen.py index d36ae22e63..ec7a1187cd 100644 --- a/himbaechel/uarch/example/example_arch_gen.py +++ b/himbaechel/uarch/example/example_arch_gen.py @@ -62,6 +62,8 @@ def create_switch_matrix(tt: TileType, inputs: list[str], outputs: list[str]): tt.create_wire(f"CLK_PREV", "CLK_ROUTE") tt.create_pip(f"CLK_PREV", f"CLK") + tt.create_group("SWITCHBOX", "SWITCHBOX") + def create_logic_tiletype(chip: Chip): tt = chip.create_tile_type("LOGIC") # setup wires