fix type lookup of yet-unresolved types (resolves #111)

This commit is contained in:
Zachary Snow 2020-07-20 17:06:13 -06:00
parent 7eed2fc58e
commit e88a6b9d84
3 changed files with 36 additions and 2 deletions

View File

@ -90,12 +90,14 @@ typeof (Call (Ident x) _) =
typeof (orig @ (Bit e _)) = do
t <- typeof e
case t of
TypeOf _ -> lookupTypeOf orig
TypeOf{} -> lookupTypeOf orig
Alias{} -> return $ TypeOf orig
_ -> return $ popRange t
typeof (orig @ (Range e mode r)) = do
t <- typeof e
return $ case t of
TypeOf _ -> TypeOf orig
TypeOf{} -> TypeOf orig
Alias{} -> TypeOf orig
_ -> replaceRange (lo, hi) t
where
lo = fst r

View File

@ -0,0 +1,18 @@
package P;
typedef logic [1:0][2:0] T;
endpackage
module top;
P::T w;
type(w[0]) x;
type(x[0]) y;
type(w[0][0]) z;
type(w[1:0]) a;
type(w[0][1:0]) b;
initial begin
$display("%b %b %b %b", w, x, y, z);
$display("%b %b", a, b);
end
endmodule

14
test/basic/typeof_alias.v Normal file
View File

@ -0,0 +1,14 @@
module top;
wire [5:0] w;
wire [2:0] x;
wire y;
wire z;
wire [5:0] a;
wire [1:0] b;
initial begin
$display("%b %b %b %b", w, x, y, z);
$display("%b %b", a, b);
end
endmodule