check for unknown named bindings

This commit is contained in:
Zachary Snow 2021-06-01 13:09:36 -04:00
parent e52de9d4a6
commit e0e296349a
4 changed files with 34 additions and 0 deletions

View File

@ -17,6 +17,7 @@ module Convert.ResolveBindings
) where
import Control.Monad.Writer.Strict
import Data.List (intercalate, (\\))
import qualified Data.Map.Strict as Map
import Convert.ExprUtils (simplify)
@ -121,5 +122,12 @@ resolveBindings location available bindings =
error $ "too many bindings specified for " ++ location
else if null $ fst $ head bindings then
zip available $ map snd bindings
else if not $ null unknowns then
error $ "unknown binding" ++ unknownsPlural ++ " "
++ unknownsStr ++ " specified for " ++ location
else
bindings
where
unknowns = map fst bindings \\ available
unknownsPlural = if length unknowns == 1 then "" else "s"
unknownsStr = intercalate ", " $ map show unknowns

View File

@ -0,0 +1,10 @@
// pattern: unknown binding "R" specified for parameters in class specialization of "example"
class example #(
parameter P = 1,
parameter Q = 1
);
typedef logic [P * Q:0] T;
endclass
module top;
example#(.P(1), .R(2))::T x;
endmodule

View File

@ -0,0 +1,8 @@
// pattern: unknown binding "R" specified for parameter overrides in instance "e" of "example"
module example;
parameter P = 1;
parameter Q = 1;
endmodule
module top;
example #(.P(1), .R(2)) e();
endmodule

View File

@ -0,0 +1,8 @@
// pattern: unknown bindings "w", "z" specified for port connections in instance "e" of "example"
module example(
input x, y
);
endmodule
module top;
example e(.w(1), .z(1'b0));
endmodule