Commit fe8839ea by Zachary Snow

fix struct typing of ternary expressions (resolves #73)

parent b124a561
......@@ -261,6 +261,11 @@ convertAsgn structs types (lhs, expr) =
-- try expression conversion by looking at the *outermost* type first
convertExpr :: Type -> Expr -> Expr
convertExpr t (Mux c e1 e2) =
Mux c e1' e2'
where
e1' = convertExpr t e1
e2' = convertExpr t e2
-- TODO: This is really a conversion for using default patterns to
-- populate arrays. Maybe this should be somewhere else?
convertExpr (IntegerVector t sg (r:rs)) (Pattern [(":default", e)]) =
......
module Example(flag, out);
typedef struct packed {
logic a, b;
} T;
output T out;
input logic flag;
assign out =
flag
? '{ a: 1'b1, b: 1'b0 }
: '{ a: 1'b1, b: 1'b1 }
;
endmodule
module Example(flag, out);
output wire [1:0] out;
input wire flag;
assign out = flag ? 2'b10 : 2'b11;
endmodule
module top;
reg flag;
wire [1:0] out;
Example example(flag, out);
initial begin
$monitor("%2d %b %b", $time, flag, out);
#1 flag = 0;
#1 flag = 1;
#1 flag = 0;
#1 flag = 1;
end
endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment