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

Uniquify module names that are common to Top & Model #1442

Merged
merged 14 commits into from
Apr 21, 2023
Merged

Conversation

joonho3020
Copy link
Contributor

This PR addresses #1388. After running split-module-files.py, it runs a additional script uniqify-module-names.py to uniquify the modules that are common to Model & Top. It updates the model_module_hierarchy.json accordingly.

Related PRs / Issues:

Type of change:

  • Bug fix
  • New feature
  • Other enhancement

Impact:

  • RTL change
  • Software change (RISC-V software)
  • Build system change
  • Other

Contributor Checklist:

  • Did you set main as the base branch?
  • Is this PR's title suitable for inclusion in the changelog and have you added a changelog:<topic> label?
  • Did you state the type-of-change/impact?
  • Did you delete any extraneous prints/debugging code?
  • Did you mark the PR with a changelog: label?
  • (If applicable) Did you update the conda .conda-lock.yml file if you updated the conda requirements file?
  • (If applicable) Did you add documentation for the feature?
  • (If applicable) Did you add a test demonstrating the PR?
  • (If applicable) Did you mark the PR as Please Backport?

@joonho3020 joonho3020 changed the title Uniquify names Uniquify module names that are common to Top & Model Apr 14, 2023
Copy link
Contributor

@harrisonliew harrisonliew left a comment

Choose a reason for hiding this comment

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

This script nominally looks correct. However, I believe that you should roll this into the already existing split-module-files.py script. These 3 lines are already processing the intersection, so might as well perform the uniquification in there?

@joonho3020
Copy link
Contributor Author

This script nominally looks correct. However, I believe that you should roll this into the already existing split-module-files.py script. These 3 lines are already processing the intersection, so might as well perform the uniquification in there?

I agree that that would also work, but I put this as a separate script because we would like to remove this script eventually when CIRCT supports top & harness separation. @abejgonzalez did you file a CIRCT issue regarding this? If not, I'll make a issue.

scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
return fnames

def update_filelist(cur_file, new_file):
sh.sed("-i", f"s/\b{cur_file}\b/{new_file}/", os.path.join(args.gcpath, args.mod_filelist))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any issues with this and paths with /? If so, maybe we should use a different delimiter (;?) for sed

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto for other sed's

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you explain what you mean by issues with paths with /?

Copy link
Contributor

Choose a reason for hiding this comment

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

The default delimiter of sed is /, so if you are replacing things that have a / within them the sed will break. For example, if you want to replace /hi/this/is/abe with /hi/this/is/joonho the following sed command would break: sed -i s//hi/this/is/abe//hi/this/is/joonho/g .... So instead you could do something like sed -i 's#/hi/this/is/abe#/hi/this/is/joonho#g' ... (with # as the new delimiter)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, but the cur_file & new_file here are just files (not paths) so I assume this is okay?

scripts/uniqify-module-names.py Show resolved Hide resolved
scripts/uniqify-module-names.py Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
scripts/uniqify-module-names.py Outdated Show resolved Hide resolved
@harrisonliew
Copy link
Contributor

harrisonliew commented Apr 20, 2023

Also found by @allpan3: in sim.mk, can you make this change (comm no longer needed):

-       for x in $$(comm -23 <(cat $(MODEL_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST) | sort -u) <(sort $(VLSI_RTL))) $(MODEL_SMEMS_FILE) $(SIM_FILE_REQS); do \
+       for x in $$(cat $(MODEL_MODS_FILELIST) $(MODEL_BB_MODS_FILELIST) | sort -u) $(MODEL_SMEMS_FILE) $(SIM_FILE_REQS); do \

@abejgonzalez abejgonzalez mentioned this pull request Apr 20, 2023
16 tasks
Copy link
Contributor

@abejgonzalez abejgonzalez left a comment

Choose a reason for hiding this comment

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

SFTM. Pending @harrisonliew (+co) checking

Copy link
Contributor

@harrisonliew harrisonliew left a comment

Choose a reason for hiding this comment

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

@allpan3 can you give this PR one more try?

generators/testchipip Outdated Show resolved Hide resolved
This reverts commit bb6f8be.
@allpan3
Copy link

allpan3 commented Apr 20, 2023

@allpan3 can you give this PR one more try?

Tested on commit 41592fd.
make buildfile was able to complete. Running synthesis now and will update later.

@allpan3
Copy link

allpan3 commented Apr 21, 2023

@allpan3 can you give this PR one more try?

Tested on commit 41592fd. make buildfile was able to complete. Running synthesis now and will update later.

Encountering this issue in synthesis:

Error   : Could not resolve reference. [CDFG-431] [elaborate]
        : The unresolved reference is for instance 'ram_ext' in file '/bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/gen-collateral/Queue_16.sv' on line 136.
        : Use 'set_db hdl_error_on_blackbox false' (in CUI mode) or 'set_attribute hdl_error_on_blackbox false /' (in legacy mode) to cause a warning, rather than an error, when a blackbox is found.
Info    : Unable to elaborate the design. [ELAB-4]

Looks like ram_combMem_12_TestHarness_UNIQUIFIED is defined in ram_combMem_12_TestHarness_UNIQUIFIED.sv file, which is not part of the file list fed to Genus.

Queue_16.sv:  ram_combMem_12_TestHarness_UNIQUIFIED ram_ext (	// @[Decoupled.scala:273:95]
ram_combMem_12_TestHarness_UNIQUIFIED.sv:module ram_combMem_12_TestHarness_UNIQUIFIED(	// @[Decoupled.scala:273:95]

None of the *_UNIQUIFIED.sv files are in the file list. Is this the issue?

@allpan3
Copy link

allpan3 commented Apr 21, 2023

Was 57d7e55 supposed to address this issue?
Still hitting the same error.

Looks like all input files are listed in /bwrcq/C/allpan/chipyard/vlsi/build/chipyard.TestHarness.HPURocketConfig-ChipTop/inputs.yml, but the *_UNIQUIFIED.sv files aren't.

./example-vlsi -e /bwrcq/C/allpan/chipyard/vlsi/env-bwrc.yml -p /bwrcq/C/allpan/chipyard/vlsi/example-tools.yml -p /bwrcq/C/allpan/chipyard/vlsi/tstech28.yml -p /bwrcq/C/allpan/chipyard/vlsi/build/chipyard.TestHarness.HPURocketConfig-ChipTop/inputs.yml -p /bwrcq/C/allpan/chipyard/vlsi/build/chipyard.TestHarness.HPURocketConfig-ChipTop/sram_generator-output.json -p /bwrcq/C/allpan/chipyard/vlsi/tstech28_sram_macros/sram_generator-output.yml --obj_dir /bwrcq/C/allpan/chipyard/vlsi/build/chipyard.TestHarness.HPURocketConfig-ChipTop syn

@joonho3020
Copy link
Contributor Author

Can you tell me what file is fed into genus?

@allpan3
Copy link

allpan3 commented Apr 21, 2023

Can you tell me what file is fed into genus?

This is what hammer takes
/bwrcq/C/allpan/chipyard/vlsi/build/chipyard.TestHarness.HPURocketConfig-ChipTop/inputs.yml
It contains the list of files used for simulation and synthesis.

And here is the log file /bwrcq/C/allpan/chipyard/vlsi/syn.log. You can search for read_hdl.

@allpan3
Copy link

allpan3 commented Apr 21, 2023

Can you tell me what file is fed into genus?

I'm guessing something related to these lines needs to be changed?
syn.f needs to contain the uniquified files.

@joonho3020
Copy link
Contributor Author

I think the uniquified files are not suppose to be fed into synthesis tools. The problem is that Queue_16.sv should use ram_combMem_12 instead of ram_combMem_12_TestHarness_UNIQUIFIED, but the suffix was added for some reason. Can you come up with a config that replicates this issue? @allpan3

@allpan3
Copy link

allpan3 commented Apr 21, 2023

I think the default RocketConfig will hit this issue. The project I was running was just an accelerator on top of the rocket chip. @joey0320

@joonho3020
Copy link
Contributor Author

I think the default RocketConfig will hit this issue. The project I was running was just an accelerator on top of the rocket chip. @joey0320

I checked with RocketConfig & don't see cases where the above error happens. Can you post your {top, model}_module_hierarchy.json?

@allpan3
Copy link

allpan3 commented Apr 21, 2023

hmm yea you are right. I tried RocketConfig and it's good.
Somehow I'm hitting this issue when I'm running my project.
Here are the files.

/bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/model_module_hierarchy.json
/bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/top_module_hierarchy.json

And I see these lines printed:

/bwrcq/C/allpan/chipyard/scripts/uniqify-module-names.py \
	--top-filelist /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/chipyard.TestHarness.HPURocketConfig.top.f \
	--mod-filelist /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/chipyard.TestHarness.HPURocketConfig.model.f \
	--gen-collateral-path /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/gen-collateral \
	--model-hier-json /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/model_module_hierarchy.json \
	--out-model-hier-json /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/model_module_hierarchy.uniquified.json \
	--dut ChipTop \
	--model TestHarness
......
sed -i s/"module ram_combMem_12"/"module ram_combMem_12_TestHarness_UNIQUIFIED"/ /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/gen-collateral/ram_combMem_12_TestHarness_UNIQUIFIED.sv
echo "/bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/gen-collateral/ram_combMem_12_TestHarness_UNIQUIFIED.sv" >> /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/chipyard.TestHarness.HPURocketConfig.model.f
sed -i s/"ram_combMem_12"/"ram_combMem_12_TestHarness_UNIQUIFIED"/ /bwrcq/C/allpan/chipyard/vlsi/generated-src/chipyard.TestHarness.HPURocketConfig/gen-collateral/Queue_16.sv

@joonho3020
Copy link
Contributor Author

Oh I meant the json files themselves lol

@allpan3
Copy link

allpan3 commented Apr 21, 2023

Oh I meant the json files themselves lol

np. There you go.
model_module_hierarchy.json.txt
top_module_hierarchy.json.txt

@joonho3020
Copy link
Contributor Author

Oh I meant the json files themselves lol

np. There you go. model_module_hierarchy.json.txt top_module_hierarchy.json.txt

Thanks, I pushed a fixed version, can you try with this one?

@abejgonzalez
Copy link
Contributor

PR https://github.com/ucb-bar/chipyard/pull/1448/files addresses the CI failures. So can ignore the current CI failures in this PR

@allpan3
Copy link

allpan3 commented Apr 21, 2023

Oh I meant the json files themselves lol

np. There you go. model_module_hierarchy.json.txt top_module_hierarchy.json.txt

Thanks, I pushed a fixed version, can you try with this one?

Synthesis looks good now.

@joonho3020 joonho3020 merged commit 15e22d9 into main Apr 21, 2023
@joonho3020 joonho3020 deleted the uniquify-names branch April 21, 2023 22:47
@joonho3020 joonho3020 restored the uniquify-names branch April 21, 2023 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants