mirror of https://github.com/zachjs/sv2v.git
keep explicitly unconnected port bindings
These are now kept while still supporting optional trailing commas and without introducing pass-through inconsistencies.
This commit is contained in:
parent
83f2dbde6b
commit
6c4ee8f4bc
|
|
@ -7,6 +7,7 @@
|
|||
* Fixed module-level localparams being needlessly inlined when forming longest
|
||||
static prefixes, which could cause deep recursion and run out of memory on
|
||||
some designs
|
||||
* Fixed overzealous removal of explicitly unconnected ports (e.g., `.a()`)
|
||||
* Fixed unneeded scoping of constant function calls used in type lookups
|
||||
* `/*/` is no longer interpreted as a self-closing block comment, e.g.,
|
||||
`$display("a"/*/,"b"/* */);` previously printed "ab", but now prints "a"
|
||||
|
|
|
|||
|
|
@ -62,9 +62,13 @@ mapInstance parts (Instance m paramBindings x rs portBindings) =
|
|||
|
||||
paramBindings' = map checkParam $
|
||||
resolveBindings (msg "parameter overrides") paramNames paramBindings
|
||||
portBindings' = filter ((/= Nil) . snd) $
|
||||
resolveBindings (msg "port connections") portNames $
|
||||
concatMap expandStar portBindings
|
||||
portBindings' = resolveBindings (msg "port connections") portNames $
|
||||
concatMap expandStar $
|
||||
-- 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 ("*", Nil) =
|
||||
|
|
|
|||
|
|
@ -1672,12 +1672,20 @@ missingToken expected = do
|
|||
parseErrorM p $ "missing expected `" ++ expected ++ "`"
|
||||
|
||||
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 =
|
||||
checkBindings "port connections" $
|
||||
if last bindings == ("", Nil)
|
||||
then init bindings
|
||||
else bindings
|
||||
checkPortBindings' bindings
|
||||
|
||||
checkPortBindings' :: [PortBinding] -> ParseState [PortBinding]
|
||||
checkPortBindings' = checkBindings "port connections"
|
||||
|
||||
checkParamBindings :: [ParamBinding] -> ParseState [ParamBinding]
|
||||
checkParamBindings = checkBindings "parameter overrides"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
// 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
|
||||
Loading…
Reference in New Issue