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

Wiring doesn't check for type match, only length match #457

Open
jameshegarty opened this issue Oct 14, 2019 · 8 comments
Open

Wiring doesn't check for type match, only length match #457

jameshegarty opened this issue Oct 14, 2019 · 8 comments
Labels

Comments

@jameshegarty
Copy link
Collaborator

Ports with bit type, uint type, and sint type can be wired to each other, as long as the length matches. Don't we want to check that they type itself matches, and require an explicit cast?

@jameshegarty jameshegarty changed the title Wiring allows non-matching types to be wired Wiring doesn't check for type match, only length match Oct 14, 2019
@phanrahan
Copy link
Owner

Currently,

Wiring is structural. So, if two types have the same structure, then they can be connected.

If you want to override the behavior or wiring, you can overload the operator on the class to be stricter.

Operators depend on the type. For example, they can add checks the types.

Open to suggestions.

@jameshegarty
Copy link
Collaborator Author

It seem like right now, if you have a signed add module, you can send unsigned inputs to it and it will wire it without an error. IMO I would prefer it to give an error in this case unless you do an explicit cast. A lot of problems of Verilog come up because it doesn't do typechecking like this. Thoughts anybody?

@hofstee
Copy link
Collaborator

hofstee commented Oct 15, 2019

Except wiring is not structural, because I can't wire Bit to Bits[1].

@phanrahan
Copy link
Owner

Wiring a scalar to an array is not normally considered structural.

@phanrahan
Copy link
Owner

I agree that the add should do type checking. Let me look at the code.

@jameshegarty
Copy link
Collaborator Author

That'd be cool, I'd be happy to help too once I clear my plate of some other stuff :)

@phanrahan
Copy link
Owner

Let's move this discussion to hwtypes. And get @leonardt and @cdonovick involved.

@cdonovick
Copy link
Collaborator

I think this discussion would fit well under leonardt/hwtypes#98
Although we can also open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants