Skip to content

Commit

Permalink
Gowin. Turn a variable into a set of flags
Browse files Browse the repository at this point in the history
Signed-off-by: YRabbit <[email protected]>
  • Loading branch information
yrabbit committed Jan 29, 2025
1 parent 4b4d0b0 commit 55647b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion himbaechel/uarch/gowin/gowin.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ NPNR_PACKED_STRUCT(struct Tile_extra_data_POD {
int32_t class_id;
int16_t io16_x_off;
int16_t io16_y_off;
int32_t i3c_capable;
int32_t tile_flags;
// tile flags
static constexpr int32_t TILE_I3C_CAPABLE_IO = 1;
});

NPNR_PACKED_STRUCT(struct Bottom_io_cnd_POD {
Expand Down
9 changes: 6 additions & 3 deletions himbaechel/uarch/gowin/gowin_arch_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
CHIP_NEED_BLKSEL_FIX = 0x8
CHIP_HAS_BANDGAP = 0x10

# Tile flags
TILE_I3C_CAPABLE_IO = 0x1

# Z of the bels
# sync with C++ part!
LUT0_Z = 0 # z(DFFx) = z(LUTx) + 1
Expand Down Expand Up @@ -126,15 +129,15 @@ class TileExtraData(BBAStruct):
# then we assign them to the same LOGIC class.
io16_x_off: int = 0 # OSER16/IDES16 offsets to the aux cell
io16_y_off: int = 0
i3c_capable: int = 0 # IO can be used as I3C
tile_flags: int = 0

def serialise_lists(self, context: str, bba: BBAWriter):
pass
def serialise(self, context: str, bba: BBAWriter):
bba.u32(self.tile_class.index)
bba.u16(self.io16_x_off)
bba.u16(self.io16_y_off)
bba.u32(self.i3c_capable)
bba.u32(self.tile_flags)

@dataclass
class BottomIOCnd(BBAStruct):
Expand Down Expand Up @@ -585,7 +588,7 @@ def create_extra_funcs(tt: TileType, db: chipdb, x: int, y: int):
else:
tt.add_bel_pin(bel, port, wire, PinType.INPUT)
elif func == 'i3c_capable':
tt.extra_data.i3c_capable = 1
tt.extra_data.tile_flags |= TILE_I3C_CAPABLE_IO
elif func == 'mipi_obuf':
bel = tt.create_bel('MIPI_OBUF', 'MIPI_OBUF', MIPIOBUF_Z)
elif func == 'mipi_ibuf':
Expand Down
2 changes: 1 addition & 1 deletion himbaechel/uarch/gowin/gowin_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool GowinUtils::get_i3c_capable(int x, int y)
int tile = tile_by_xy(ctx->chip_info, x, y);
const Tile_extra_data_POD *extra =
reinterpret_cast<const Tile_extra_data_POD *>(chip_tile_info(ctx->chip_info, tile).extra_data.get());
return extra->i3c_capable != 0;
return extra->tile_flags & Tile_extra_data_POD::TILE_I3C_CAPABLE_IO;
}

// pin functions: GCLKT_4, SSPI_CS, READY etc
Expand Down

0 comments on commit 55647b8

Please sign in to comment.