mirror of https://github.com/zachjs/sv2v.git
support multi-dimensional modports
This commit is contained in:
parent
e0e296349a
commit
24a79ffebe
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue