Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kestrel Collaboration
Kestrel LiteX
migen
Commits
d0676e2d
Commit
d0676e2d
authored
11 years ago
by
Sebastien Bourdeauducq
Browse files
Options
Download
Email Patches
Plain Diff
migen/fhdl/autofragment: factorize
parent
d0d2df3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
migen/fhdl/autofragment.py
migen/fhdl/autofragment.py
+13
-16
No files found.
migen/fhdl/autofragment.py
View file @
d0676e2d
import
collections
from
migen.fhdl.structure
import
*
from
migen.fhdl.structure
import
*
from
migen.fhdl.specials
import
Special
from
migen.fhdl.specials
import
Special
from
migen.fhdl.tools
import
flat_iteration
def
flat_list
(
e
):
if
isinstance
(
e
,
collections
.
Iterable
):
return
flat_iteration
(
e
)
else
:
return
[
e
]
class
_FModuleProxy
:
class
_FModuleProxy
:
def
__init__
(
self
,
fm
):
def
__init__
(
self
,
fm
):
...
@@ -7,10 +16,7 @@ class _FModuleProxy:
...
@@ -7,10 +16,7 @@ class _FModuleProxy:
class
_FModuleComb
(
_FModuleProxy
):
class
_FModuleComb
(
_FModuleProxy
):
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
if
isinstance
(
other
,
(
list
,
tuple
)):
self
.
_fm
.
_fragment
.
comb
+=
flat_list
(
other
)
self
.
_fm
.
_fragment
.
comb
+=
other
else
:
self
.
_fm
.
_fragment
.
comb
.
append
(
other
)
return
self
return
self
def
_cd_append
(
d
,
key
,
statements
):
def
_cd_append
(
d
,
key
,
statements
):
...
@@ -19,10 +25,7 @@ def _cd_append(d, key, statements):
...
@@ -19,10 +25,7 @@ def _cd_append(d, key, statements):
except
KeyError
:
except
KeyError
:
l
=
[]
l
=
[]
d
[
key
]
=
l
d
[
key
]
=
l
if
isinstance
(
statements
,
(
list
,
tuple
)):
l
+=
flat_list
(
statements
)
l
+=
statements
else
:
l
.
append
(
statements
)
class
_FModuleSyncCD
:
class
_FModuleSyncCD
:
def
__init__
(
self
,
fm
,
cd
):
def
__init__
(
self
,
fm
,
cd
):
...
@@ -47,18 +50,12 @@ class _FModuleSync(_FModuleProxy):
...
@@ -47,18 +50,12 @@ class _FModuleSync(_FModuleProxy):
class
_FModuleSpecials
(
_FModuleProxy
):
class
_FModuleSpecials
(
_FModuleProxy
):
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
if
isinstance
(
other
,
(
set
,
list
,
tuple
)):
self
.
_fm
.
_fragment
.
specials
|=
set
(
flat_list
(
other
))
self
.
_fm
.
_fragment
.
specials
|=
set
(
other
)
else
:
self
.
_fm
.
_fragment
.
specials
.
add
(
other
)
return
self
return
self
class
_FModuleSubmodules
(
_FModuleProxy
):
class
_FModuleSubmodules
(
_FModuleProxy
):
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
if
isinstance
(
other
,
(
list
,
tuple
)):
self
.
_fm
.
_submodules
+=
flat_list
(
other
)
self
.
_fm
.
_submodules
+=
other
else
:
self
.
_fm
.
_submodules
.
append
(
other
)
return
self
return
self
class
FModule
:
class
FModule
:
...
...
This diff is collapsed.
Click to expand it.
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