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

[Types] Support wiring Bit and Bits[1] #1070

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

[Types] Support wiring Bit and Bits[1] #1070

wants to merge 7 commits into from

Conversation

leonardt
Copy link
Collaborator

@leonardt leonardt commented May 9, 2022

Two implementation issues:

  1. Should we support wiring T to Array[1, T] in general? Or have this be
    a Bits/Bit specific feature
  2. Is there a way to avoid a circular import in this logic? The naive
    solution is to have Bit check if the driver is Bits[1], but this
    clearly requires a circular import. Perhaps we could use some sort
    of T.convert_to(other_T) API?

Two implementation issues:
1. Should we support wiring T to Array[1, T] in general? Or have this be
   a Bits/Bit specific feature
2. Is there a way to avoid a circular import in this logic? The naive
   solution is to have Bit check if the driver is Bits[1], but this
   clearly requires a circular import.  Perhaps we could use some sort
   of `T.convert_to(other_T)` API?
@leonardt leonardt requested a review from rsetaluri May 9, 2022 19:02
@codecov-commenter
Copy link

codecov-commenter commented May 9, 2022

Codecov Report

Merging #1070 (efbc823) into master (266aaee) will increase coverage by 0.01%.
The diff coverage is 100.00%.

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

@@            Coverage Diff             @@
##           master    #1070      +/-   ##
==========================================
+ Coverage   85.31%   85.33%   +0.01%     
==========================================
  Files         144      144              
  Lines       15162    15178      +16     
==========================================
+ Hits        12936    12952      +16     
  Misses       2226     2226              
Impacted Files Coverage Δ
magma/backend/mlir/compile_to_mlir_opts.py 100.00% <100.00%> (ø)
magma/backend/mlir/hardware_module.py 94.81% <100.00%> (+0.05%) ⬆️
magma/bit.py 84.04% <100.00%> (+0.89%) ⬆️
magma/bits.py 94.10% <100.00%> (+0.21%) ⬆️
magma/t.py 89.55% <100.00%> (+0.15%) ⬆️
magma/backend/coreir/insert_wrap_casts.py 95.77% <0.00%> (-1.41%) ⬇️
magma/syntax/verilog_utils.py 34.87% <0.00%> (-0.85%) ⬇️
magma/backend/coreir/coreir_utils.py 88.27% <0.00%> (-0.69%) ⬇️
magma/circuit.py 91.70% <0.00%> (-0.03%) ⬇️
magma/simulator/mdb.py 35.71% <0.00%> (+0.14%) ⬆️
... and 2 more

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 266aaee...acb8b8b. Read the comment docs.

@rsetaluri
Copy link
Collaborator

I'm still not sure if we really want to support this pattern (our original ideas about type strictness).

But if we do, I think we definitely should support all T <-> Array[1, T] wirings.

@@ -113,11 +110,20 @@ def ite(self, t_branch, f_branch):

@debug_wire
def wire(self, o, debug_info):
Copy link
Collaborator

Choose a reason for hiding this comment

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

btw, why is this not in Digital? why do we need to override it in Bit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right now this is just for Bit <-> Bits[1], if we wanted T <-> Array[1, T] then we would move it to Digital.

@leonardt
Copy link
Collaborator Author

Perhaps we can investigate other options with the designers to avoid the issue without making this fundamental change.

@rsetaluri rsetaluri changed the title Support wiring Bit and Bits[1] [Types] Support wiring Bit and Bits[1] Aug 23, 2022
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.

3 participants