Commit 6c4ee8f4 by Zachary Snow

keep explicitly unconnected port bindings

These are now kept while still supporting optional trailing commas and
without introducing pass-through inconsistencies.
parent 83f2dbde
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* Fixed module-level localparams being needlessly inlined when forming longest * Fixed module-level localparams being needlessly inlined when forming longest
static prefixes, which could cause deep recursion and run out of memory on static prefixes, which could cause deep recursion and run out of memory on
some designs some designs
* Fixed overzealous removal of explicitly unconnected ports (e.g., `.a()`)
* Fixed unneeded scoping of constant function calls used in type lookups * Fixed unneeded scoping of constant function calls used in type lookups
* `/*/` is no longer interpreted as a self-closing block comment, e.g., * `/*/` is no longer interpreted as a self-closing block comment, e.g.,
`$display("a"/*/,"b"/* */);` previously printed "ab", but now prints "a" `$display("a"/*/,"b"/* */);` previously printed "ab", but now prints "a"
......
...@@ -62,9 +62,13 @@ mapInstance parts (Instance m paramBindings x rs portBindings) = ...@@ -62,9 +62,13 @@ mapInstance parts (Instance m paramBindings x rs portBindings) =
paramBindings' = map checkParam $ paramBindings' = map checkParam $
resolveBindings (msg "parameter overrides") paramNames paramBindings resolveBindings (msg "parameter overrides") paramNames paramBindings
portBindings' = filter ((/= Nil) . snd) $ portBindings' = resolveBindings (msg "port connections") portNames $
resolveBindings (msg "port connections") portNames $ concatMap expandStar $
concatMap expandStar portBindings -- drop the trailing comma in positional port bindings
if length portNames + 1 == length portBindings
&& last portBindings == ("", Nil)
then init portBindings
else portBindings
expandStar :: PortBinding -> [PortBinding] expandStar :: PortBinding -> [PortBinding]
expandStar ("*", Nil) = expandStar ("*", Nil) =
......
...@@ -1672,12 +1672,20 @@ missingToken expected = do ...@@ -1672,12 +1672,20 @@ missingToken expected = do
parseErrorM p $ "missing expected `" ++ expected ++ "`" parseErrorM p $ "missing expected `" ++ expected ++ "`"
checkPortBindings :: [PortBinding] -> ParseState [PortBinding] checkPortBindings :: [PortBinding] -> ParseState [PortBinding]
checkPortBindings [] = return [] -- empty port bindings should stay empty
checkPortBindings [("", Nil)] = return []
-- drop the trailing comma in named port bindings
checkPortBindings bindings
| (_ : _, _) <- head bindings
, ("", Nil) <- last bindings
= checkPortBindings' $ init bindings
-- a trailing comma is indistinguishable from an explicit unconnected positional
-- binding, so this is passed-through cleanly and resolved downstream
checkPortBindings bindings = checkPortBindings bindings =
checkBindings "port connections" $ checkPortBindings' bindings
if last bindings == ("", Nil)
then init bindings checkPortBindings' :: [PortBinding] -> ParseState [PortBinding]
else bindings checkPortBindings' = checkBindings "port connections"
checkParamBindings :: [ParamBinding] -> ParseState [ParamBinding] checkParamBindings :: [ParamBinding] -> ParseState [ParamBinding]
checkParamBindings = checkBindings "parameter overrides" checkParamBindings = checkBindings "parameter overrides"
......
// pattern: illegal mix of ordered and named port connections
module example(
input a, b, c
);
endmodule
module top;
wire a, b, c;
example e(.a(1), .b(2), ,);
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