diff --git a/src/Convert/Interface.hs b/src/Convert/Interface.hs index bb82fcd..0e16c3d 100644 --- a/src/Convert/Interface.hs +++ b/src/Convert/Interface.hs @@ -302,12 +302,12 @@ convertDescription parts (Part attrs extern Module lifetime name ports items) = collectDecl _ = return () extractModportInfo :: Type -> Maybe (Identifier, Identifier) - extractModportInfo (InterfaceT "" "" []) = Just ("", "") - extractModportInfo (InterfaceT interfaceName modportName []) = + extractModportInfo (InterfaceT "" "" _) = Just ("", "") + extractModportInfo (InterfaceT interfaceName modportName _) = if isInterface interfaceName then Just (interfaceName, modportName) else Nothing - extractModportInfo (Alias interfaceName []) = + extractModportInfo (Alias interfaceName _) = if isInterface interfaceName then Just (interfaceName, "") else Nothing @@ -496,15 +496,17 @@ inlineInstance global ranges modportBindings items partName Variable d t x a e else if makeBindingBaseExpr modportE == Nothing then CommentDecl $ "removed modport instance " ++ x - else if null a then + else if null modportDims then localparam (modportBaseName x) bindingBaseExpr else localparam (modportBaseName x) $ - BinOp Sub bindingBaseExpr (sliceLo NonIndexed $ head a) + BinOp Sub bindingBaseExpr (sliceLo NonIndexed modportDim) where maybeModportBinding = lookup x modportBindings Just (_, modportE) = maybeModportBinding bindingBaseExpr = Ident $ bindingBaseName ++ x + modportDims = a ++ snd (typeRanges t) + [modportDim] = modportDims removeModportInstance other = other diff --git a/src/Convert/UnpackedArray.hs b/src/Convert/UnpackedArray.hs index 2fa93b3..918a6cc 100644 --- a/src/Convert/UnpackedArray.hs +++ b/src/Convert/UnpackedArray.hs @@ -29,25 +29,25 @@ convert :: [AST] -> [AST] convert = map $ traverseDescriptions convertDescription convertDescription :: Description -> Description -convertDescription (description @ (Part _ _ Module _ _ _ _)) = +convertDescription (description @ (Part _ _ Module _ _ ports _)) = evalState (operation description) Set.empty where - operation = - partScoperT traverseDeclM traverseModuleItemM noop traverseStmtM >=> + operation = partScoperT + (traverseDeclM ports) traverseModuleItemM noop traverseStmtM >=> partScoperT rewriteDeclM noop noop noop noop = return convertDescription other = other -- tracks multi-dimensional unpacked array declarations -traverseDeclM :: Decl -> ST Decl -traverseDeclM (decl @ (Variable _ _ _ [] _)) = return decl -traverseDeclM (decl @ (Variable dir _ x _ e)) = do +traverseDeclM :: [Identifier] -> Decl -> ST Decl +traverseDeclM _ (decl @ (Variable _ _ _ [] _)) = return decl +traverseDeclM ports (decl @ (Variable _ _ x _ e)) = do insertElem x decl - if dir /= Local || e /= Nil + if elem x ports || e /= Nil then flatUsageM x else return () return decl -traverseDeclM other = return other +traverseDeclM _ other = return other -- pack decls marked for packing rewriteDeclM :: Decl -> ST Decl diff --git a/test/basic/interface_delay_2.sv b/test/basic/interface_delay_2.sv new file mode 100644 index 0000000..faf56e0 --- /dev/null +++ b/test/basic/interface_delay_2.sv @@ -0,0 +1,18 @@ +interface Interface; + logic [0:1][0:2] arr; +endinterface + +module Module(intf); + Interface intf [3:3][1:2]; + assign intf[3][2].arr[1] = 1; + assign intf[3][2].arr[0][0] = 0; + initial $display("2: %b", intf[3][2].arr); +endmodule + +module top; + Interface intf [1:1][1:2] (); + Module mod (intf); + assign intf[1][1].arr[1] = 6; + assign intf[1][1].arr[0][0] = 1; + initial $display("1: %b", intf[1][1].arr); +endmodule diff --git a/test/basic/interface_delay_2.v b/test/basic/interface_delay_2.v new file mode 100644 index 0000000..28673b4 --- /dev/null +++ b/test/basic/interface_delay_2.v @@ -0,0 +1,14 @@ +module top; + if (1) begin : intf1 + wire [0:1][0:2] arr; + end + if (1) begin : intf2 + wire [0:1][0:2] arr; + end + assign intf2.arr[1] = 1; + assign intf2.arr[0][0] = 0; + initial $display("2: %b", intf2.arr); + assign intf1.arr[1] = 6; + assign intf1.arr[0][0] = 1; + initial $display("1: %b", intf1.arr); +endmodule