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

platform: add a mechanism for AFU's to set platform macros #3130

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

michael-adler
Copy link
Member

Due to the order that SystemVerilog header files are processed, setting a macro in an AFU's sources file may not affect the FIM's afu_main(). Add support for writing macros to the PIM interface header file that afu_main() includes explicity.

Due to the order that SystemVerilog header files are processed,
setting a macro in an AFU's sources file may not affect the FIM's
afu_main(). Add support for writing macros to the PIM interface
header file that afu_main() includes explicity.

Signed-off-by: Michael Adler <michael.adler@intel.com>
@michael-adler michael-adler requested a review from a team as a code owner June 11, 2024 22:54
Comment on lines +289 to +292
if ('define' in afu_ifc_db):
afu_ifc_db['define'] += afu_ifc_req['define']
else:
afu_ifc_db['define'] = afu_ifc_req['define']
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is concatenating lists, would this pattern work?

Suggested change
if ('define' in afu_ifc_db):
afu_ifc_db['define'] += afu_ifc_req['define']
else:
afu_ifc_db['define'] = afu_ifc_req['define']
afu_ifc_db.setdefault('define', []) += afu_ifc_req['define']

Copy link
Member Author

Choose a reason for hiding this comment

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

Yours does look better, but the base object doesn't have setdefault(). I think it's just a list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

You are of course right, it's a dict. But it looks like setdefault() can't be used as an l-value, so can't be the left side of +=.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, thanks. This should work:

Suggested change
if ('define' in afu_ifc_db):
afu_ifc_db['define'] += afu_ifc_req['define']
else:
afu_ifc_db['define'] = afu_ifc_req['define']
afu_ifc_db.setdefault('define', []).extend(afu_ifc_req['define'])

Copy link
Member Author

Choose a reason for hiding this comment

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

I find that harder to understand than the original. Is it important to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not important; merely a preference to avoid repetition.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the first suggestion had actually worked I'd be totally on board. Thanks for trying.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a small semantic difference; the first list afu_ifc_req['define'] is modified as well when a second list afu_ifc_req['define'] is concatenated, since = does not create a deep copy. I assume it does not make a difference here though.

@coveralls
Copy link

coveralls commented Jun 11, 2024

Pull Request Test Coverage Report for Build 9473843507

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 64.641%

Totals Coverage Status
Change from base Build 9424841313: 0.0%
Covered Lines: 15826
Relevant Lines: 24483

💛 - Coveralls

@michael-adler michael-adler merged commit 046b40f into OFS:master Jun 11, 2024
23 checks passed
@michael-adler michael-adler deleted the mcadler/afu_define branch June 11, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants