Skip to content

ice40_dsp: fix log_assert issue #4942

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 4 commits into from
Mar 28, 2025
Merged

Conversation

Anhijkt
Copy link
Contributor

@Anhijkt Anhijkt commented Mar 15, 2025

What are the reasons/motivation for this change?
#4865
Explain how this is achieved.
This code iterates not from the beginning but from the end of output signal, leaving only bits that are currently in use with unused bits needed for offset.

sigH.append(O[i]);
}
for (i = GetSize(O) - 1; i > 0 && nusers(O[i]) <= 1; i--)
;
// This sigM could have no users if downstream sinks (e.g. $add) is
// narrower than $mul result, for example
if (i == 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this bit still correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

also this makes for a good opportunity to figure out what the comment referencing a non-existent sigM is actually supposed to say

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point of original, pre-patch code was to cut unused bits from the end of output port. This code does the same but starts iterating from the end of the port. Seems like the outputs of SB_MAC16 needs to be connected with empty wire, so this piece is used to group all unused bits into one wire.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So the weird comment actually points to this being copied from xilinx_dsp where this check is written pretty much the same way as of this PR

wire_width++;
else {
if (wire_width) { // add empty wires for bit offset if needed
sigH.append(module->addWire(NEW_ID, wire_width));
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems odd to append to sigH a wire of wire_width width in each iteration. Is that the intended behavior?

Copy link
Contributor Author

@Anhijkt Anhijkt Mar 25, 2025

Choose a reason for hiding this comment

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

The reason for this is this line, as far as I understand, unused output ports on this type of cells should be connected with wires, so this code add them between wires of used ports.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually misread this loop before, my bad, I get it now

@widlarizer widlarizer merged commit 1b25e1c into YosysHQ:main Mar 28, 2025
25 checks passed
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