Skip to content

fix: enforce canonical ordering for tile port directions#698

Draft
KelvinChung2000 wants to merge 5 commits into
FPGA-Research:mainfrom
KelvinChung2000:fix/direction-canonical-ordering
Draft

fix: enforce canonical ordering for tile port directions#698
KelvinChung2000 wants to merge 5 commits into
FPGA-Research:mainfrom
KelvinChung2000:fix/direction-canonical-ordering

Conversation

@KelvinChung2000

Copy link
Copy Markdown
Collaborator

Make Direction orderable in canonical (NORTH, EAST, SOUTH, WEST, JUMP) order and sort tile ports by direction in parseTilesCSV so generated wire orderings are deterministic regardless of input row order.

Make ``Direction`` orderable in canonical (NORTH, EAST, SOUTH, WEST,
JUMP) order and sort tile ports by direction in ``parseTilesCSV`` so
generated wire orderings are deterministic regardless of input row
order.
@read-the-docs-community

read-the-docs-community Bot commented Apr 30, 2026

Copy link
Copy Markdown

@IAmMarcelJung IAmMarcelJung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments, rest LGTM. Also, the functool docs mention that also __eq__ should be defined, but probably we don't need it here since we won't have this case anyway (and it's a should, not a must after all)?

Comment thread fabulous/fabric_generator/parser/parse_csv.py Outdated
Comment thread fabulous/fabric_definition/define.py Outdated
Comment thread fabulous/fabric_generator/parser/parse_csv.py Outdated
@EverythingElseWasAlreadyTaken

Copy link
Copy Markdown
Collaborator

This breaks the bitstream spec for FABulous 2.0 fabrics.

His is a diff of a fabric build with main and then let this PR version run over it again:

image

I'm not sure why, but for some reason, for FABulous 1.0 fabrics, this is not the case, the bistream spec is the same there. Thats why the reference tests did not catch this.

@KelvinChung2000

Copy link
Copy Markdown
Collaborator Author

I thought this was safe since Python's sorting is stable. It is probably that we do not sort at 1.0. Then sorting starts at 2.0 but that sort on sort changes something. This is looking like sorting at "W,E,b", not "b,W,E"

@KelvinChung2000

Copy link
Copy Markdown
Collaborator Author

At some point, we need to update the bitstream spec generation so that it remains stable regardless of how we change the front side from a random value. This is too annoying to deal with.

@EverythingElseWasAlreadyTaken

Copy link
Copy Markdown
Collaborator

At some point, we need to update the bitstream spec generation so that it remains stable regardless of how we change the front side from a random value. This is too annoying to deal with.

Yes, this is really annoying.
For 3.0 we can rethink the whole bitstream spec, but for now, we can't break it.

@KelvinChung2000

Copy link
Copy Markdown
Collaborator Author

I did this one because https://github.com/FPGA-Research/fabulous-tiles/blob/main/tiles/classic/E_IO/E_IO.csv is not in the correct order of NESW, the sort is to make this not matter. I will see what should be done.

@EverythingElseWasAlreadyTaken

Copy link
Copy Markdown
Collaborator

I did this one because https://github.com/FPGA-Research/fabulous-tiles/blob/main/tiles/classic/E_IO/E_IO.csv is not in the correct order of NESW, the sort is to make this not matter. I will see what should be done.

Overall the sort makes sense, but sadly this breaks things.
We could either go for a version check or just postpone this after official 2.0 release.

I've added FABulous 2.0b4 demos to the reference tests, to ensure that we don't add regression in the spec generation in the future.
FPGA-Research/FABulous-demo-projects#9

@KelvinChung2000 KelvinChung2000 marked this pull request as draft May 6, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants