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

Simple numbers with data constructor #5

Open
yjwen opened this issue Sep 18, 2017 · 0 comments
Open

Simple numbers with data constructor #5

yjwen opened this issue Sep 18, 2017 · 0 comments
Assignees

Comments

@yjwen
Copy link
Owner

yjwen commented Sep 18, 2017

To translate

module MaybePlus where
maybe_plus :: Maybe Int -> Maybe Int -> Maybe Int
maybe_plus (Just a) (Just b) = Just (a + b)
maybe_plus _ _ = Nothing

to

typedef struct {
   logic ctor;
   logic [63 : 0] body;
} MaybeInt;

module maybe_plus(MaybeInt a, MaybeInt b, output MaybeInt o);
   assign o.ctor = a.ctor && b.ctor;
   assign o.body = o.ctor ? a.body + b.body : 'x;
endmodule
@yjwen yjwen self-assigned this Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant