Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
1472ea0c
Commit
1472ea0c
authored
Aug 29, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert unpacked parameter dimensions (closes #18)
parent
1d216a2e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
7 deletions
+44
-7
src/Language/SystemVerilog/Parser/Parse.y
+20
-7
test/basic/unpacked_localparam.sv
+12
-0
test/basic/unpacked_localparam.v
+12
-0
No files found.
src/Language/SystemVerilog/Parser/Parse.y
View file @
1472ea0c
...
...
@@ -633,11 +633,12 @@ Dimension :: { Range }
: Range { $1 }
| "[" Expr "]" { (simplify $ BinOp Sub $2 (Number "1"), Number "0") }
DeclAsgns :: { [(Identifier, Expr)] }
DeclAsgns :: { [(Identifier, Expr
, [Range]
)] }
: DeclAsgn { [$1] }
| DeclAsgns "," DeclAsgn { $1 ++ [$3] }
DeclAsgn :: { (Identifier, Expr) }
: Identifier "=" Expr { ($1, $3) }
DeclAsgn :: { (Identifier, Expr, [Range]) }
: Identifier "=" Expr { ($1, $3, []) }
| Identifier DimensionsNonEmpty "=" Expr { ($1, $4, $2) }
Range :: { Range }
: "[" Expr ":" Expr "]" { ($2, $4) }
...
...
@@ -730,10 +731,10 @@ DeclOrStmt :: { ([Decl], [Stmt]) }
| ParameterDecl(";") { ($1, []) }
ParameterDecl(delim) :: { [Decl] }
: ParameterDeclKW DeclAsgns delim { ma
p (uncurry $ $1 (Implicit Unspecified [])
) $2 }
| ParameterDeclKW ParamType DeclAsgns delim { ma
p (uncurry $ $1 ($2 )
) $3 }
| ParameterDeclKW Identifier Dimensions DeclAsgns delim { ma
p (uncurry $ $1 (Alias (Nothing) $2 $3)
) $4 }
| ParameterDeclKW Identifier "::" Identifier Dimensions DeclAsgns delim { ma
p (uncurry $ $1 (Alias (Just $2) $4 $5)
) $6 }
: ParameterDeclKW DeclAsgns delim { ma
keParamDecls $1 (Implicit Unspecified []
) $2 }
| ParameterDeclKW ParamType DeclAsgns delim { ma
keParamDecls $1 ($2
) $3 }
| ParameterDeclKW Identifier Dimensions DeclAsgns delim { ma
keParamDecls $1 (Alias (Nothing) $2 $3
) $4 }
| ParameterDeclKW Identifier "::" Identifier Dimensions DeclAsgns delim { ma
keParamDecls $1 (Alias (Just $2) $4 $5
) $6 }
ParameterDeclKW :: { Type -> Identifier -> Expr -> Decl }
: "parameter" { Parameter }
| "localparam" { Localparam }
...
...
@@ -995,4 +996,16 @@ toLHS expr =
Just lhs -> lhs
Nothing -> error $ "Parse error: cannot convert expression to LHS: "
++ show expr
makeParamDecls
:: (Type -> Identifier -> Expr -> Decl)
-> Type
-> [(Identifier, Expr, [Range])]
-> [Decl]
makeParamDecls kw t items =
map mapper items
where
(tf, rs) = typeRanges t
mapper (x, e, a) = kw (tf $ a ++ rs) x e
}
test/basic/unpacked_localparam.sv
0 → 100644
View file @
1472ea0c
module
top
;
localparam
logic
[
7
:
0
]
init_val
[
4
]
=
{
8'd0
,
8'd8
,
8'd10
,
8'd200
};
initial
begin
integer
i
,
j
;
for
(
i
=
0
;
i
<
4
;
i
+=
1
)
begin
$
display
(
init_val
[
i
])
;
for
(
j
=
0
;
j
<
8
;
j
+=
1
)
begin
$
display
(
init_val
[
i
][
j
])
;
end
end
end
endmodule
test/basic/unpacked_localparam.v
0 → 100644
View file @
1472ea0c
module
top
;
localparam
[
31
:
0
]
init_val
=
{
8'd0
,
8'd8
,
8'd10
,
8'd200
};
initial
begin
:
foo
integer
i
,
j
;
for
(
i
=
0
;
i
<
4
;
i
+=
1
)
begin
$
display
(
init_val
[
8
*
i
+:
8
])
;
for
(
j
=
0
;
j
<
8
;
j
+=
1
)
begin
$
display
(
init_val
[
8
*
i
+
j
])
;
end
end
end
endmodule
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment