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 35b711b commit b5e341a
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 140 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)
288 changes: 148 additions & 140 deletions himbaechel/uarch/example/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,166 +139,175 @@ 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;
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<GraphicElement> &g, GraphicElement::style_t style, Loc loc, IdString wire_type, int32_t tilewire, IdString tile_type)
void drawWire(std::vector<GraphicElement> &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<GraphicElement> &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<GraphicElement> &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;
Expand All @@ -311,7 +320,6 @@ struct ExampleImpl : HimbaechelAPI
el.x2 = loc.x + 0.50;
el.y2 = el.y1;
g.push_back(el);

}
}
};
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 b5e341a

Please sign in to comment.