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

Added an optimized popcount TDM generator to bsg_misc #653

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

klundblad
Copy link

@klundblad klundblad commented Apr 13, 2023

This is a python script that generates a popcount .v file. It attempts to do a more optimized adder tree using the Three Dimensional Method (TDM). The following PPA analysis compares the original bsg_popcount.v to the generated popcount_tdm.v for widths 8, 32, 64, 128, and 1024.

Screenshot 2023-04-13 024636

The full PPA spreadsheet can be found here: https://docs.google.com/spreadsheets/d/1FjDbuVNZ45XHxjTXhP-kz8AH1CuP96d7sxJkHXT-KGA/edit?usp=sharing

@dpetrisko
Copy link
Contributor

Hi can you commit the .v as well?

@stdavids stdavids self-requested a review April 13, 2023 18:22
Copy link
Contributor

@stdavids stdavids left a comment

Choose a reason for hiding this comment

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

Let's rename the script bsg_popcount_tdm.py and make the generated module name also bsg_popcount_tdm.

The round robin arb does something similar, we can take some inspiration from:
https://github.com/bespoke-silicon-group/basejump_stl/blob/master/bsg_misc/bsg_round_robin_arb.py
https://github.com/bespoke-silicon-group/basejump_stl/blob/master/bsg_misc/bsg_round_robin_arb.v

The arb script takes the max size as an argument and then from 1 to the max size it generates a single module that uses generate-if statements to select the generated module. Rather than sweeping all widths from 1 to max size, maybe we just take all of the widths on the command line and generate those -- so the usage would be something like python3 ./bsg_popcount_tdm.py 32 64 1000 > bsg_popcount_tdm.v and it would generate a single modules with 3 generate-if statements.

print_end_module( 'popcount_tdm', s_o, c_o) # calculate sum in verilog file

if __name__ == '__main__':
popcount_gen(8) # generates a "popcount_tdm.v" file for width of 8
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's expose the width as a command line argument

@@ -0,0 +1,259 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a header comment with what the script does and how to use it.

@taylor-bsg
Copy link
Contributor

Let's try to get to the bottom of why we are not winning on frequency, especially for popcount <= 32.

@taylor-bsg
Copy link
Contributor

You can compare the two netlists and also the STA reports.

…ed .v file from running python .\bsg_popcount_tdm.py 1 2 4 8 bsg_popcount_tdm.v
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.

4 participants