diff --git a/CHANGELOG.md b/CHANGELOG.md index de6ac44..63a6d8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ * Added elaboration for accesses to fields of struct constants, which can substantially improve performance on some designs * Added constant folding for comparisons involving string literals +* Port connection attributes (e.g., [pulp_soc.sv]) are now ignored with a + warning rather than failing to parse + +[pulp_soc.sv]: https://github.com/pulp-platform/pulp_soc/blob/0573a85c/rtl/pulp_soc/pulp_soc.sv#L733 ## v0.0.10 diff --git a/src/Language/SystemVerilog/Parser/Parse.y b/src/Language/SystemVerilog/Parser/Parse.y index bf4c9b2..113a383 100644 --- a/src/Language/SystemVerilog/Parser/Parse.y +++ b/src/Language/SystemVerilog/Parser/Parse.y @@ -820,6 +820,8 @@ AttributeInstances :: { [Attr] } | AttributeInstance AttributeInstances { $1 : $2 } AttributeInstance :: { Attr } : AttributeInstanceP { snd $1 } +AttributeInstancesP :: { (Position, [Attr]) } + : AttributeInstanceP AttributeInstances { (fst $1, snd $1 : $2) } AttributeInstanceP :: { (Position, Attr) } : "(*" AttrSpecs "*)" { withPos $1 $ Attr $2 } AttrSpecs :: { [AttrSpec] } @@ -1068,6 +1070,7 @@ PortBindingsInside :: { [PortBinding] } OptPortBinding :: { PortBinding } : {- empty -} { ("", Nil) } | PortBinding { $1 } + | AttributeInstancesP PortBinding {% portBindingAttrs $1 >> return $2 } PortBinding :: { PortBinding } : "." Identifier "(" ExprOrNil ")" { ($2, $4) } @@ -1752,10 +1755,15 @@ readNumber :: Position -> String -> ParseState Number readNumber pos str = do oversizedNumbers <- gets pOversizedNumbers let (num, msg) = parseNumber oversizedNumbers str - when (not $ null msg) $ lift $ lift $ - hPutStrLn stderr $ show pos ++ ": Warning: " ++ msg + when (not $ null msg) $ + parseWarning pos msg return num +parseWarning :: Position -> String -> ParseState () +parseWarning pos msg = + lift $ lift $ hPutStrLn stderr $ + show pos ++ ": Warning: " ++ msg + expectZeroDelay :: Token -> a -> ParseState a expectZeroDelay tok a = do num <- readNumber pos str @@ -1813,4 +1821,9 @@ makeIncrExprAsgn True (pos, op) expr = do return $ BinOp op expr' minusOne where minusOne = Number $ Decimal 1 True 1 +portBindingAttrs :: (Position, [Attr]) -> ParseState () +portBindingAttrs (pos, attrs) = parseWarning pos msg + where msg = "Ignored port connection attributes " + ++ concatMap show attrs ++ "." + } diff --git a/test/warning/attr.sv b/test/warning/attr.sv new file mode 100644 index 0000000..cedf00a --- /dev/null +++ b/test/warning/attr.sv @@ -0,0 +1,7 @@ +module mod(output logic out); + assign out = 1; +endmodule +module top; + logic x; + mod m((* foo *)(* bar *).out(x)); +endmodule diff --git a/test/warning/run.sh b/test/warning/run.sh index fae529e..1d34f33 100755 --- a/test/warning/run.sh +++ b/test/warning/run.sh @@ -3,9 +3,10 @@ NO_FILES_WARNING="Warning: No input files specified (try \`sv2v --help\`)" PACKAGE_WARNING="Warning: Source includes packages but no modules. Please convert packages alongside the modules that use them." INTERFACE_WARNING="Warning: Source includes an interface but output is empty because there is no top-level module which has no ports which are interfaces." +PORT_CONN_ATTR_WARNING="attr.sv:6:11: Warning: Ignored port connection attributes (* foo *)(* bar *)." test_default() { - runAndCapture *.sv + runAndCapture interface.sv module.sv package.sv assertTrue "default conversion should succeed" $result assertNotNull "stdout should not be empty" "$stdout" assertNull "stderr should be empty" "$stderr" @@ -18,6 +19,13 @@ test_no_files() { assertEquals "stderr should should have warning" "$NO_FILES_WARNING" "$stderr" } +test_port_conn_attr() { + runAndCapture attr.sv + assertTrue "conversion should succeed" $result + assertNotNull "stdout should not be empty" "$stdout" + assertEquals "stderr should should have warning" "$PORT_CONN_ATTR_WARNING" "$stderr" +} + test_only_package() { runAndCapture package.sv assertTrue "conversion should succeed" $result