From 485ffffa0130a1d767ea82b6123c371c93341f86 Mon Sep 17 00:00:00 2001 From: qcorradi Date: Tue, 23 May 2023 09:42:26 +0100 Subject: [PATCH] always kw conversion visits items with attributes * Fixing a bug where always_* are not converted when attributed * Added tests and updated Changelog for the attributed always_* fix --- CHANGELOG.md | 2 ++ src/Convert/AlwaysKW.hs | 2 ++ test/core/always_attr.sv | 10 ++++++++++ test/core/always_attr.v | 10 ++++++++++ 4 files changed, 24 insertions(+) create mode 100644 test/core/always_attr.sv create mode 100644 test/core/always_attr.v diff --git a/CHANGELOG.md b/CHANGELOG.md index b8adf1e..04f07fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ 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 an issue that left `always_comb`, `always_latch`, and `always_ff` + unconverted when tagged with an attribute * 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" diff --git a/src/Convert/AlwaysKW.hs b/src/Convert/AlwaysKW.hs index 62902f4..a3cf0de 100644 --- a/src/Convert/AlwaysKW.hs +++ b/src/Convert/AlwaysKW.hs @@ -198,6 +198,8 @@ traverseModuleItem item@(MIPackageItem (Function _ _ x decls _)) = do traverseModuleItem item@(MIPackageItem (Task _ x decls _)) = do insertElem x $ Proc [] (ports decls) return item +traverseModuleItem (MIAttr attr item) = + MIAttr attr <$> traverseModuleItem item traverseModuleItem other = return other toEvent :: (Bool, [Expr]) -> Event diff --git a/test/core/always_attr.sv b/test/core/always_attr.sv new file mode 100644 index 0000000..0fe91b3 --- /dev/null +++ b/test/core/always_attr.sv @@ -0,0 +1,10 @@ +module top; + reg a, b, c; + (* test *) always_ff @(posedge a) + c <= b; + (* test *) always_latch + if (c) + b <= 1; + (* test *) always_comb + a = b; +endmodule diff --git a/test/core/always_attr.v b/test/core/always_attr.v new file mode 100644 index 0000000..35cce8f --- /dev/null +++ b/test/core/always_attr.v @@ -0,0 +1,10 @@ +module top; + reg a, b, c; + (* test *) always @(posedge a) + c <= b; + (* test *) always @* + if (c) + b <= 1; + (* test *) always @* + a = b; +endmodule