Skip to content

Commit

Permalink
Example uarch using new API features
Browse files Browse the repository at this point in the history
  • Loading branch information
mmicko committed Nov 29, 2024
1 parent 05e9943 commit 7816fd2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 34 deletions.
2 changes: 2 additions & 0 deletions himbaechel/uarch/example/constids.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ X(LOGIC)
X(BRAM)
X(IO)
X(NULL)

X(SWITCHBOX)
82 changes: 48 additions & 34 deletions himbaechel/uarch/example/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ struct ExampleImpl : HimbaechelAPI
return true;
}

void drawGroup(std::vector<GraphicElement> &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<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override
{
GraphicElement el;
Expand All @@ -147,32 +161,32 @@ struct ExampleImpl : HimbaechelAPI
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.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.55;
el.x2 = el.x1 + 0.25;
el.y1 = loc.y + 0.85 - (loc.z / 2) * 0.1;
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.25;
el.x2 = el.x1 + 0.50;
el.y1 = loc.y + 0.80 - loc.z * 0.40;
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.25;
el.x2 = el.x1 + 0.50;
el.y1 = loc.y + 0.80;
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;
Expand All @@ -192,33 +206,33 @@ struct ExampleImpl : HimbaechelAPI
{
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.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_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.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_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.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_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.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;
Expand All @@ -229,7 +243,7 @@ struct ExampleImpl : HimbaechelAPI
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.y1 = loc.y + 0.90 - i * 0.1 - 0.05;
el.y2 = el.y1 - 0.05;
g.push_back(el);
}
Expand All @@ -241,25 +255,25 @@ struct ExampleImpl : HimbaechelAPI
{
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.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.75;
el.x2 = el.x1 + 0.05;
el.y1 = loc.y + 0.78 - z * 0.015;
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.6;
el.x1 = loc.x + 0.60;
el.x2 = el.x1;
el.y1 = loc.y + 0.20;
el.y2 = el.y1 - 0.05;
el.y1 = loc.y + 0.30;
el.y2 = el.y1 - 0.025;
g.push_back(el);
break;
}
Expand Down
2 changes: 2 additions & 0 deletions himbaechel/uarch/example/example_arch_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7816fd2

Please sign in to comment.