Skip to content

move common sim infra to chipflow-lib #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 11, 2025
Merged

move common sim infra to chipflow-lib #122

merged 15 commits into from
Jul 11, 2025

Conversation

robtaylor
Copy link
Contributor

No description provided.

@robtaylor robtaylor marked this pull request as draft June 24, 2025 16:48
Copy link

github-actions bot commented Jun 24, 2025

Tests Skipped Failures Errors Time
92 7 💤 0 ❌ 0 🔥 1.524s ⏱️

Copy link

github-actions bot commented Jun 24, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-07-11 17:21 UTC

@robtaylor robtaylor force-pushed the sim-common branch 7 times, most recently from ab61ad2 to 73c0bd6 Compare June 25, 2025 22:27
@robtaylor robtaylor force-pushed the sim-common branch 13 times, most recently from 778f36c to 5d9304e Compare June 26, 2025 15:45
@robtaylor robtaylor requested a review from gatecat June 26, 2025 16:43
@robtaylor robtaylor marked this pull request as ready for review June 27, 2025 10:20
for n, t in top.items():
setattr(m.submodules, n, t)

for component, iface in self._platform._pinlock.port_map.items():
Copy link
Contributor

Choose a reason for hiding this comment

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

could some of this code be shared with SiliconTop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know - i didn't originate this so I don't really understand the difference between the code here and the code in SiliconTop.
Leave for now? maybe you understand better and can do a pr after?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's not my code either - I don't know where it came from originally but thought all the IOSignature stuff was yours - but that seems fair enough for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess i must have written it but its all dropped from my mind. i'll have to look again.. a bit worried that they should be the same and that the silicon case is missing something important...

else getattr(iface, name))
port = self._platform._ports[port.port_name]
if hasattr(wire, 'i'):
m.d.comb += wire.i.eq(port.i)
Copy link
Contributor

Choose a reason for hiding this comment

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

Inverted ports should also be inverted here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand this either - it runs... what does inverting here do?

Copy link
Contributor

Choose a reason for hiding this comment

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

it works at the moment because we don't use invert anywhere (because we didn't support it up to now). but with this now inverted ports would behave wrongly in sim

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahha, i see thank you

Copy link
Contributor

@gatecat gatecat left a comment

Choose a reason for hiding this comment

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

Few more comments left


for reset, name in self._config["chipflow"]["resets"].items():
port_data = pinlock.package.resets[name]
port = io.SimulationPort(io.Direction.Input, port_data.width, invert=port.invert, name=f"clock-{name}", )
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be reset- not clock-

raise ChipFlowError(f"Unable to find clock {name} in pinlock")

port_data = pinlock.package.clocks[name]
port = io.SimulationPort(io.Direction.Input, port_data.width, invert=True, name=f"clock-{name}")
Copy link
Contributor

Choose a reason for hiding this comment

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

why is invert=True here? clocks wouldn't normally be inverted


for reset, name in self._config["chipflow"]["resets"].items():
port_data = pinlock.package.resets[name]
port = io.SimulationPort(io.Direction.Input, port_data.width, invert=port.invert, name=f"clock-{name}", )
Copy link
Contributor

Choose a reason for hiding this comment

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

what is port.invert supposed to refer to? port isn't yet set at the time you use it, so it will actually be referring to the last clock or reset....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

random mess, i think, no real way to say if resets are inverted or not, so this should either be always not inverted or always inverted...

m.d.comb += wire.i.eq(port.i ^ inv_mask)
for d in ['o', 'oe']:
if hasattr(wire, d):
m.d.comb += getattr(port, d).eq(getattr(wire, d) ^ inv_mask)
Copy link
Contributor

Choose a reason for hiding this comment

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

oe is never inverted regardless of port.invert, invert only refers to the input/output data

@robtaylor robtaylor requested a review from gatecat July 2, 2025 15:10
if hasattr(wire, 'o'):
m.d.comb += port.o.eq(wire.o)^ inv_mask
if hasattr(wire, 'oe'):
m.d.comb += port.oe.eq(wire.oe)^ inv_mask
Copy link
Contributor

Choose a reason for hiding this comment

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

seems a previous comment was missed - oe should never be inverted

@gatecat
Copy link
Contributor

gatecat commented Jul 8, 2025

one last comment left - then this should be good to go

@robtaylor
Copy link
Contributor Author

robtaylor commented Jul 8, 2025 via email

@robtaylor robtaylor requested a review from gatecat July 8, 2025 13:41
@robtaylor robtaylor merged commit 9e3ad2a into main Jul 11, 2025
6 checks passed
@robtaylor robtaylor deleted the sim-common branch July 11, 2025 17:20
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.

2 participants