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

hdl.ir: Pick up the variable name as a default name for submodules #330

Closed
wants to merge 1 commit into from
Closed

Conversation

galibert
Copy link
Contributor

@galibert galibert commented Mar 5, 2020

The current generated rtlil uses name like U$$ for module names, which is not good for discoverability, implementing debuggers, etc. This patch picks up the variable name as default name for modules, in a similar way than is done for Signals.

I'm not sure what the rules for unicity are, if any. Maybe the name should include the hierarchy in it to avoid collisions. I'm not sure.

@codecov
Copy link

codecov bot commented Mar 5, 2020

Codecov Report

Merging #330 into master will decrease coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #330     +/-   ##
=========================================
- Coverage   82.56%   82.46%   -0.1%     
=========================================
  Files          35       35             
  Lines        5884     5908     +24     
  Branches     1196     1197      +1     
=========================================
+ Hits         4858     4872     +14     
- Misses        864      879     +15     
+ Partials      162      157      -5
Impacted Files Coverage Δ
nmigen/hdl/ir.py 95.04% <100%> (-0.12%) ⬇️
nmigen/_utils.py 79.54% <0%> (-1.14%) ⬇️
nmigen/hdl/ast.py 87.45% <0%> (-1.01%) ⬇️
nmigen/back/pysim.py 91.07% <0%> (-0.36%) ⬇️
nmigen/_unused.py 88.46% <0%> (+3.84%) ⬆️
nmigen/tracer.py 100% <0%> (+10.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a14a572...25548e5. Read the comment docs.

@whitequark
Copy link
Member

whitequark commented Mar 5, 2020

Unfortunately the current behavior exists for a reason: module names are semantically meaningful, and having two modules with the same name is not legal, unlike signals, where it's totally fine. Also, I think it's important that Elaboratable involve as little magic as possible, and your solution makes it considerably more involved.

Have you considered, instead of using:

submod = Submodule()
m.submodules += submod

doing:

m.submodules.submod = submod = Submodule()

That's the suggested syntax and it even has the same amount of typing.

@whitequark whitequark closed this Mar 5, 2020
@galibert
Copy link
Contributor Author

galibert commented Mar 5, 2020

You mean that submodules should not be instanciated in __init__ ?

@whitequark
Copy link
Member

They can be if it makes sense, then you'd do:

m.submodules.submod = self.submod

later.

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.

None yet

2 participants