Commit ac95c5b0 by Zachary Snow

support for multiple param/localparams in one declaration

parent 39ee2257
......@@ -92,7 +92,7 @@ instance Show ModuleItem where
Parameter r n e -> printf "parameter %s%s = %s;" (showRange r) n (showExprConst e)
Localparam r n e -> printf "localparam %s%s = %s;" (showRange r) n (showExprConst e)
PortDecl d r x -> printf "%s %s%s;" (show d) (showRange r) x
LocalNet t x v -> (show t) ++ " " ++ x ++ assignment ++ ";"
LocalNet t x v -> printf "%s%s%s;" (show t) x assignment
where
assignment =
if v == Nothing
......
......@@ -211,8 +211,8 @@ MaybeTypeOrRange :: { Either Type (Maybe Range) }
| "wire" MaybeRange { Left $ Wire $2 }
ModuleItem :: { [ModuleItem] }
: "parameter" MaybeRange Identifier "=" Expr ";" { [Parameter $2 $3 $5] }
| "localparam" MaybeRange Identifier "=" Expr ";" { [Localparam $2 $3 $5] }
: "parameter" MaybeRange DeclAsgns ";" { map (uncurry $ Parameter $2) $3 }
| "localparam" MaybeRange DeclAsgns ";" { map (uncurry $ Localparam $2) $3 }
| PortDecl(";") { $1 }
| "reg" MaybeRange WireDeclarations ";" { map (uncurry $ LocalNet $ Reg $2) $3 }
| "wire" MaybeRange WireDeclarations ";" { map (uncurry $ LocalNet $ Wire $2) $3 }
......@@ -225,6 +225,13 @@ ModuleItem :: { [ModuleItem] }
| "always" "@*" Stmt { [Always (Just SenseStar) $3] }
| Identifier ParameterBindings Identifier Bindings ";" { [Instance $1 $2 $3 $4] }
DeclAsgns :: { [(Identifier, Expr)] }
: DeclAsgn { [$1] }
| DeclAsgn "," DeclAsgns { $1 : $3 }
DeclAsgn :: { (Identifier, Expr) }
: Identifier "=" Expr { ($1, $3) }
RegDeclarations :: { [(Identifier, Maybe Range)] }
: Identifier MaybeRange { [($1, $2)] }
| RegDeclarations "," Identifier MaybeRange { $1 ++ [($3, $4)] }
......
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