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

[WIP]wishbone.Connector class #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Fatsie
Copy link
Contributor

@Fatsie Fatsie commented Jul 1, 2020

Currently pull request as WIP:

@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #21 (ec94f31) into master (c754caf) will not change coverage.
The diff coverage is 100.00%.

❗ Current head ec94f31 differs from pull request most recent head 3db2a83. Consider uploading reports for the commit 3db2a83 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##            master       #21   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         6    -1     
  Lines          693       725   +32     
  Branches       145       160   +15     
=========================================
+ Hits           693       725   +32     
Impacted Files Coverage Δ
nmigen_soc/wishbone/bus.py 100.00% <100.00%> (ø)
nmigen_soc/periph.py

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 ecfad4d...3db2a83. Read the comment docs.

@Fatsie
Copy link
Contributor Author

Fatsie commented Jul 1, 2020

* Connecting initiator bus with data width greater than data width of subordinate bus is not implemented. Would PR be acceptable without this implementation ?

Reason I ask is that I don't need this feature for my use case and implementation of it may take some time.

@whitequark whitequark requested a review from jfng July 1, 2020 19:25
@whitequark
Copy link
Member

Reason I ask is that I don't need this feature for my use case and implementation of it may take some time.

In general my preference is to have a complete solution even if it takes a bit longer, but let's get the review started before you put more time into that.

Copy link
Member

@jfng jfng left a comment

Choose a reason for hiding this comment

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

We should also add support for memory maps. If the subordinate bus has a memory map, it should be exposed to the initiator bus. Something like this:

try:
    sub_map  = sub_bus.memory_map
    intr_map = MemoryMap(...)
    intr_map.add_window(sub_map, addr=0, sparse=False)
    self.intr_bus.memory_map = intr_map
except NotImplementedError:
    # Subordinate bus does not have a memory map.
    pass

nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved
@@ -166,6 +167,147 @@ def memory_map(self, memory_map):
self._map = memory_map


class Connector(Elaboratable):
Copy link
Member

Choose a reason for hiding this comment

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

Connector seems too generic for a width up-converter. How about Upconverter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in #18 I did use Connector because the functionality is broader then upconverting, it's functionality is to connect a single initiator to a single subordinate. Upconverting will be done when necessary.
You will need to agree with @whitequark what to go for.

Copy link
Member

Choose a reason for hiding this comment

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

Could the Connector class be composed internally of two separate up- and down-converter classes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can see during implementation of the feature if it makes sense to do that but current feeling is that it will cause unnecessary code duplication with negligible improvement in code clarity or maintainability.

nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved
raise NotImplementedError(
"Support for multi-cycle bus operation when initiator data_width is"
"bigger than the subordinate one is not implemented."
)
Copy link
Member

Choose a reason for hiding this comment

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

This should be a ValueError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Plan is to later also implement downsizing in this class therefor NotImlementedError. This is thus alsot related to discussion in #18.

nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved
nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved
nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved
nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved
nmigen_soc/wishbone/bus.py Outdated Show resolved Hide resolved

m = Module()

common_addr_width = min(intr_bus.addr_width, sub_bus.addr_width)
Copy link
Member

Choose a reason for hiding this comment

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

Could this be simplified to sub_bus.addr_width ? intr_bus.addr_width >= sub_bus.addr_width is asserted later is the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the assert now, it was planned to be removed if multi-cycle bus was implemented.
Kept the common_addr_width definition as it is already future proof.

@Fatsie
Copy link
Contributor Author

Fatsie commented Jul 7, 2020

We should also add support for memory maps. If the subordinate bus has a memory map, it should be exposed to the initiator bus. Something like this:

try:
    sub_map  = sub_bus.memory_map
    intr_map = MemoryMap(...)
    intr_map.add_window(sub_map, addr=0, sparse=False)
    self.intr_bus.memory_map = intr_map
except NotImplementedError:
    # Subordinate bus does not have a memory map.
    pass

Actually in the first version I even enforced a memory map on subordinate bus like the Decoder does. But I removed all memory map code after I got problems with the unit test for different granularity. I based the data_width of the memory maps on the granularity of each bus. Then you get an error when adding the subordinate memorymap to the initiator one due to different data_width.

Implementation of a module that allows to connect one initiator to one
subordinate.bus. Currently connecting initiator bus with data width
greater than the subordinate bus is not implemented. Implementation
of that feature will need to instantiate multiple subordinate bus cycles
for one initiator bus cycle.
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@217d4ea). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head ec94f31 differs from pull request most recent head 1c7e14f. Consider uploading reports for the commit 1c7e14f to get more accurate results

Impacted file tree graph

@@           Coverage Diff            @@
##             main       #21   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         6           
  Lines           ?       725           
  Branches        ?       160           
========================================
  Hits            ?       725           
  Misses          ?         0           
  Partials        ?         0           

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 217d4ea...1c7e14f. Read the comment docs.

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

4 participants