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
a6cd3626
Commit
a6cd3626
authored
Feb 28, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small pre-refactor PackedArray fixes
parent
e1d6da00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
src/Convert/PackedArray.hs
+18
-8
No files found.
src/Convert/PackedArray.hs
View file @
a6cd3626
...
@@ -6,9 +6,12 @@
...
@@ -6,9 +6,12 @@
- This removes one dimension per identifier at a time. This works fine because
- This removes one dimension per identifier at a time. This works fine because
- the conversions are repeatedly applied.
- the conversions are repeatedly applied.
-
-
- TODO FIXME XXX: The Parser/AST don't yet support indexing into an identifier
- twice, or indexing into an identifier, and then selecting a range.
-
- TODO: This assumes that the first range index is the upper bound. We could
- TODO: This assumes that the first range index is the upper bound. We could
- probably get ar
r
ound this with some cleverness in the generate block. I don't
- probably get around this with some cleverness in the generate block. I don't
- think it's urgent to have support for "backwards" ra
gn
es.
- think it's urgent to have support for "backwards" ra
ng
es.
-}
-}
module
Convert.PackedArray
(
convert
)
where
module
Convert.PackedArray
(
convert
)
where
...
@@ -40,7 +43,7 @@ convertDescription description =
...
@@ -40,7 +43,7 @@ convertDescription description =
collectDecl
::
ModuleItem
->
State
(
DimMap
,
DirMap
)
()
collectDecl
::
ModuleItem
->
State
(
DimMap
,
DirMap
)
()
collectDecl
(
MIDecl
(
Variable
dir
t
ident
_
_
))
=
do
collectDecl
(
MIDecl
(
Variable
dir
t
ident
_
_
))
=
do
let
(
tf
,
rs
)
=
typeDims
t
let
(
tf
,
rs
)
=
typeDims
t
if
length
rs
>
1
if
not
(
typeIsImplicit
t
)
&&
length
rs
>
1
then
modify
$
\
(
m
,
r
)
->
(
Map
.
insert
ident
(
tf
$
tail
rs
,
head
rs
)
m
,
r
)
then
modify
$
\
(
m
,
r
)
->
(
Map
.
insert
ident
(
tf
$
tail
rs
,
head
rs
)
m
,
r
)
else
return
()
else
return
()
if
dir
/=
Local
if
dir
/=
Local
...
@@ -93,9 +96,6 @@ flattenModuleItem (dimMap, dirMap) (orig @ (MIDecl (Variable dir t ident a me)))
...
@@ -93,9 +96,6 @@ flattenModuleItem (dimMap, dirMap) (orig @ (MIDecl (Variable dir t ident a me)))
flipGen
=
Map
.
lookup
ident
dirMap
==
Just
Input
flipGen
=
Map
.
lookup
ident
dirMap
==
Just
Input
genItems
=
unflattener
flipGen
ident
(
dimMap
Map
.!
ident
)
genItems
=
unflattener
flipGen
ident
(
dimMap
Map
.!
ident
)
newDecl
=
MIDecl
$
Variable
dir
t'
ident
a
me
newDecl
=
MIDecl
$
Variable
dir
t'
ident
a
me
typeIsImplicit
::
Type
->
Bool
typeIsImplicit
(
Implicit
_
)
=
True
typeIsImplicit
_
=
False
flattenModuleItem
_
other
=
other
flattenModuleItem
_
other
=
other
-- produces a generate block for creating a local unflattened copy of the given
-- produces a generate block for creating a local unflattened copy of the given
...
@@ -132,6 +132,10 @@ unflattener shouldFlip arr (t, (majorHi, majorLo)) =
...
@@ -132,6 +132,10 @@ unflattener shouldFlip arr (t, (majorHi, majorLo)) =
(
BinOp
Sub
size
(
Number
"1"
)))
(
BinOp
Sub
size
(
Number
"1"
)))
,
Ident
startBit
)
,
Ident
startBit
)
typeIsImplicit
::
Type
->
Bool
typeIsImplicit
(
Implicit
_
)
=
True
typeIsImplicit
_
=
False
-- basic expression simplfication utility to help us generate nicer code in the
-- basic expression simplfication utility to help us generate nicer code in the
-- common case of ranges like `[FOO-1:0]`
-- common case of ranges like `[FOO-1:0]`
simplify
::
Expr
->
Expr
simplify
::
Expr
->
Expr
...
@@ -190,6 +194,12 @@ rewriteModuleItem dimMap =
...
@@ -190,6 +194,12 @@ rewriteModuleItem dimMap =
e'
=
BinOp
Mul
size
e
e'
=
BinOp
Mul
size
e
rewriteExpr
other
=
other
rewriteExpr
other
=
other
rewriteLHS
::
LHS
->
LHS
rewriteLHS
(
LHS
x
)
=
LHS
(
rewriteIdent
x
)
rewriteLHS
(
LHSBit
x
e
)
=
LHSBit
(
rewriteIdent
x
)
e
rewriteLHS
(
LHSRange
x
r
)
=
LHSRange
(
rewriteIdent
x
)
r
rewriteLHS
(
LHSConcat
ls
)
=
LHSConcat
$
map
rewriteLHS
ls
rewriteStmt
::
Stmt
->
Stmt
rewriteStmt
::
Stmt
->
Stmt
rewriteStmt
(
AsgnBlk
lhs
expr
)
=
convertAssignment
AsgnBlk
lhs
expr
rewriteStmt
(
AsgnBlk
lhs
expr
)
=
convertAssignment
AsgnBlk
lhs
expr
rewriteStmt
(
Asgn
lhs
expr
)
=
convertAssignment
Asgn
lhs
expr
rewriteStmt
(
Asgn
lhs
expr
)
=
convertAssignment
Asgn
lhs
expr
...
@@ -197,7 +207,7 @@ rewriteModuleItem dimMap =
...
@@ -197,7 +207,7 @@ rewriteModuleItem dimMap =
convertAssignment
::
(
LHS
->
Expr
->
Stmt
)
->
LHS
->
Expr
->
Stmt
convertAssignment
::
(
LHS
->
Expr
->
Stmt
)
->
LHS
->
Expr
->
Stmt
convertAssignment
constructor
(
lhs
@
(
LHS
ident
))
(
expr
@
(
Repeat
_
exprs
))
=
convertAssignment
constructor
(
lhs
@
(
LHS
ident
))
(
expr
@
(
Repeat
_
exprs
))
=
case
Map
.
lookup
ident
dimMap
of
case
Map
.
lookup
ident
dimMap
of
Nothing
->
constructor
lhs
expr
Nothing
->
constructor
(
rewriteLHS
lhs
)
expr
Just
(
_
,
(
a
,
b
))
->
Just
(
_
,
(
a
,
b
))
->
For
inir
chkr
incr
assign
For
inir
chkr
incr
assign
where
where
...
@@ -209,4 +219,4 @@ rewriteModuleItem dimMap =
...
@@ -209,4 +219,4 @@ rewriteModuleItem dimMap =
chkr
=
BinOp
Le
(
Ident
index
)
a
chkr
=
BinOp
Le
(
Ident
index
)
a
incr
=
(
index
,
BinOp
Add
(
Ident
index
)
(
Number
"1"
))
incr
=
(
index
,
BinOp
Add
(
Ident
index
)
(
Number
"1"
))
convertAssignment
constructor
lhs
expr
=
convertAssignment
constructor
lhs
expr
=
constructor
lhs
expr
constructor
(
rewriteLHS
lhs
)
expr
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