mirror of https://github.com/zachjs/sv2v.git
fix struct typing of ternary expressions (resolves #73)
This commit is contained in:
parent
b124a561f2
commit
fe8839eaec
|
|
@ -261,6 +261,11 @@ convertAsgn structs types (lhs, expr) =
|
||||||
|
|
||||||
-- try expression conversion by looking at the *outermost* type first
|
-- try expression conversion by looking at the *outermost* type first
|
||||||
convertExpr :: Type -> Expr -> Expr
|
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
|
-- TODO: This is really a conversion for using default patterns to
|
||||||
-- populate arrays. Maybe this should be somewhere else?
|
-- populate arrays. Maybe this should be somewhere else?
|
||||||
convertExpr (IntegerVector t sg (r:rs)) (Pattern [(":default", e)]) =
|
convertExpr (IntegerVector t sg (r:rs)) (Pattern [(":default", e)]) =
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
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
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
module Example(flag, out);
|
||||||
|
output wire [1:0] out;
|
||||||
|
input wire flag;
|
||||||
|
assign out = flag ? 2'b10 : 2'b11;
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
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
|
||||||
Loading…
Reference in New Issue