Skip to content
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

[rtl] Fix non-DSP reset in ibex_counter #2228

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

nasahlpa
Copy link
Member

@nasahlpa nasahlpa commented Nov 29, 2024

When targeting Xilinx FPGAs, we utilize a DSP for counters with a width of less than 49-bit. In this case, a sync. reset is needed. However, currently, there is a bug in the RTL where also a sync. reset is used for the non-DSP counters on the FPGA.

@nasahlpa
Copy link
Member Author

nasahlpa commented Nov 29, 2024

Apologies, I should have re-generated the bitstream after addressing this review comment. I assumed this is purely cosmetically but it actually led to a Vivado synthesis failure :/

@nasahlpa nasahlpa force-pushed the counter_ibex branch 2 times, most recently from fdccb6c to d92213a Compare December 2, 2024 11:45
Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this @nasahlpa .

To me it looks like this PR adds a lot more code and makes things much less readable and more complex. It negatively impacts maintenance. I think what we should do:

  1. Revert the previous PR which introduced the issue.
  2. Do a PR that maybe doesn't address the comment you mentioned but that implements the change without making it much more complex.

@nasahlpa nasahlpa changed the title [rtl] Move counter_q definition [rtl] Dedicated ibex_counter_flop modules Dec 2, 2024
@nasahlpa
Copy link
Member Author

nasahlpa commented Dec 2, 2024

As discussed offline:

  • I've reverted the previous commit in PR Revert "[rtl] Fix counter reset value on FPGA" #2229
  • Tried to create a submodule for the Xilinx specific flop. However, with this Vivado decided to ignore the use_dsp pragma. The solution now in this PR is the only implementation that (i) uses DSPs when it should and (ii) does not trigger a Vivado warning.

@nasahlpa nasahlpa changed the title [rtl] Dedicated ibex_counter_flop modules [rtl] Dedicated ibex_counter_flop module Dec 3, 2024
@nasahlpa nasahlpa marked this pull request as draft December 4, 2024 06:47
@nasahlpa nasahlpa changed the title [rtl] Dedicated ibex_counter_flop module WIP [rtl] Dedicated ibex_counter_flop module Dec 4, 2024
@nasahlpa nasahlpa changed the title WIP [rtl] Dedicated ibex_counter_flop module [rtl] Fix non-DSP reset in ibex_counter Dec 4, 2024
@nasahlpa nasahlpa marked this pull request as ready for review December 4, 2024 20:48
@nasahlpa nasahlpa requested a review from vogelpi December 4, 2024 20:49
Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

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

Thanks @nasahlpa , this is pretty elegant :-)

`else
localparam string UseDsp = "no";
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to use an int type here as well for consistency. Thanks for adding the comment on Vivado requiring int instead of string.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks.

counter_q <= '0;
end else begin
counter_q <= counter_d;
generate
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use generate regions, some tools don't support this and this is why our style guide doesn't permit it: https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md#generate-constructs

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks.

@vogelpi vogelpi requested a review from GregAC December 5, 2024 13:40
When targeting Xilinx FPGAs, we utilize a DSP for counters
with a width of less than 49-bit. In this case, a sync. reset
is needed. However, currently, there is a bug in the RTL
where also a sync. reset is used for the non-DSP counters
on the FPGA.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
@vogelpi
Copy link
Contributor

vogelpi commented Dec 6, 2024

Thanks Pascal for addressing the remaining comments, I think we can merge this today.

@vogelpi vogelpi added this pull request to the merge queue Dec 6, 2024
Merged via the queue into lowRISC:master with commit 667fd20 Dec 6, 2024
11 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