Commit 8537a9ef by Zachary Snow

fix scoping of single-item generate conditionals

parent 5ad8de9e
...@@ -361,16 +361,13 @@ evalScoperT declMapper moduleItemMapper genItemMapper stmtMapper topName items = ...@@ -361,16 +361,13 @@ evalScoperT declMapper moduleItemMapper genItemMapper stmtMapper topName items =
let genItems = map GenModuleItem injected' ++ [genItem''] let genItems = map GenModuleItem injected' ++ [genItem'']
return $ GenBlock "" genItems return $ GenBlock "" genItems
scopeGenItemMapper :: GenItem -> ScoperT a m GenItem scopeGenItemMapper :: GenItem -> ScoperT a m GenItem
scopeGenItemMapper (GenFor (index, a) b c (GenBlock name genItems)) = do
enterScope name index
genItems' <- mapM fullGenItemMapper genItems
exitScope name index
return $ GenFor (index, a) b c (GenBlock name genItems')
scopeGenItemMapper (GenFor (index, a) b c genItem) = do scopeGenItemMapper (GenFor (index, a) b c genItem) = do
enterScope "" index genItem' <- scopeGenItemBranchMapper index genItem
genItem' <- fullGenItemMapper genItem
exitScope "" index
return $ GenFor (index, a) b c genItem' return $ GenFor (index, a) b c genItem'
scopeGenItemMapper (GenIf cond thenItem elseItem) = do
thenItem' <- scopeGenItemBranchMapper "" thenItem
elseItem' <- scopeGenItemBranchMapper "" elseItem
return $ GenIf cond thenItem' elseItem'
scopeGenItemMapper (GenBlock name genItems) = do scopeGenItemMapper (GenBlock name genItems) = do
enterScope name "" enterScope name ""
genItems' <- mapM fullGenItemMapper genItems genItems' <- mapM fullGenItemMapper genItems
...@@ -381,6 +378,18 @@ evalScoperT declMapper moduleItemMapper genItemMapper stmtMapper topName items = ...@@ -381,6 +378,18 @@ evalScoperT declMapper moduleItemMapper genItemMapper stmtMapper topName items =
scopeGenItemMapper genItem = scopeGenItemMapper genItem =
traverseSinglyNestedGenItemsM fullGenItemMapper genItem traverseSinglyNestedGenItemsM fullGenItemMapper genItem
scopeGenItemBranchMapper :: Identifier -> GenItem -> ScoperT a m GenItem
scopeGenItemBranchMapper index (GenBlock name genItems) = do
enterScope name index
genItems' <- mapM fullGenItemMapper genItems
exitScope name index
return $ GenBlock name genItems'
scopeGenItemBranchMapper index genItem = do
enterScope "" index
genItem' <- fullGenItemMapper genItem
exitScope "" index
return genItem'
partScoper partScoper
:: MapperM (Scoper a) Decl :: MapperM (Scoper a) Decl
-> MapperM (Scoper a) ModuleItem -> MapperM (Scoper a) ModuleItem
......
module top;
parameter WIDTH = 5;
logic [WIDTH-1:0] x, y;
if (WIDTH > 0)
initial
x = WIDTH'(0);
initial
y = WIDTH'(0);
endmodule
module top;
parameter WIDTH = 5;
reg [WIDTH-1:0] x, y;
if (WIDTH > 0)
initial
x = 0;
initial
y = 0;
endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment