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
588f1a25
Commit
588f1a25
authored
12 years ago
by
Sebastien Bourdeauducq
Browse files
Options
Download
Email Patches
Plain Diff
flow: plumbing
parent
8f1bf508
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
4 deletions
+68
-4
examples/dataflow.py
examples/dataflow.py
+19
-3
migen/flow/actor.py
migen/flow/actor.py
+3
-0
migen/flow/ala.py
migen/flow/ala.py
+1
-1
migen/flow/plumbing.py
migen/flow/plumbing.py
+45
-0
No files found.
examples/dataflow.py
View file @
588f1a25
from
migen.fhdl
import
verilog
from
migen.flow.ala
import
*
from
migen.flow.plumbing
import
*
act
=
Divider
(
32
)
frag
=
act
.
get_control_fragment
()
+
act
.
get_process_fragment
()
print
(
verilog
.
convert
(
frag
))
act
=
Adder
(
32
)
comb
=
Combinator
(
act
.
operands
,
[
"a"
],
[
"b"
])
outbuf
=
Buffer
(
act
.
result
.
template
())
frag
=
get_actor_fragments
(
act
,
comb
,
outbuf
)
stb_a
=
comb
.
sinks
[
0
].
stb
ack_a
=
comb
.
sinks
[
0
].
ack
stb_b
=
comb
.
sinks
[
1
].
stb
ack_b
=
comb
.
sinks
[
1
].
ack
stb_a
.
name
=
"stb_a_i"
ack_a
.
name
=
"ack_a_o"
stb_b
.
name
=
"stb_b_i"
ack_b
.
name
=
"stb_b_o"
a
=
comb
.
ins
[
0
].
a
b
=
comb
.
ins
[
1
].
b
a
.
name
=
"a"
b
.
name
=
"b"
print
(
verilog
.
convert
(
frag
,
ios
=
{
stb_a
,
ack_a
,
stb_b
,
ack_b
,
a
,
b
}))
This diff is collapsed.
Click to expand it.
migen/flow/actor.py
View file @
588f1a25
...
...
@@ -104,3 +104,6 @@ class Actor:
def
get_process_fragment
(
self
):
raise
NotImplementedError
(
"Actor classes must overload get_process_fragment"
)
def
get_actor_fragments
(
*
actors
):
return
sum
([
a
.
get_control_fragment
()
+
a
.
get_process_fragment
()
for
a
in
actors
],
Fragment
())
This diff is collapsed.
Click to expand it.
migen/flow/ala.py
View file @
588f1a25
...
...
@@ -6,7 +6,7 @@ from migen.corelogic import divider
class
Adder
(
Actor
):
def
__init__
(
self
,
width
):
self
.
operands
=
Record
([(
'a'
,
BV
(
width
)),
(
'b'
,
BV
(
width
))])
self
.
result
=
Record
([
'sum'
,
BV
(
width
+
1
)])
self
.
result
=
Record
([
(
'sum'
,
BV
(
width
+
1
)
)
])
Actor
.
__init__
(
self
,
SchedulingModel
(
SchedulingModel
.
COMBINATORIAL
),
self
.
operands
,
self
.
result
)
...
...
This diff is collapsed.
Click to expand it.
migen/flow/plumbing.py
0 → 100644
View file @
588f1a25
from
migen.fhdl.structure
import
*
from
migen.flow.actor
import
*
from
migen.corelogic.record
import
*
from
migen.corelogic.misc
import
optree
class
Buffer
(
Actor
):
def
__init__
(
self
,
template
):
self
.
d
=
Record
(
template
)
self
.
q
=
Record
(
template
)
Actor
.
__init__
(
self
,
SchedulingModel
(
SchedulingModel
.
PIPELINE
,
1
),
self
.
d
,
self
.
q
)
def
get_process_fragment
(
self
):
sigs_d
=
self
.
d
.
flatten
()
sigs_q
=
self
.
q
.
flatten
()
sync
=
[
Cat
(
*
sigs_q
).
eq
(
Cat
(
*
sigs_d
))]
return
Fragment
(
sync
=
sync
)
class
Combinator
(
Actor
):
def
__init__
(
self
,
destination
,
*
subrecords
):
self
.
ins
=
[
destination
.
subrecord
(
*
subr
)
for
subr
in
subrecords
]
Actor
.
__init__
(
self
,
SchedulingModel
(
SchedulingModel
.
COMBINATORIAL
),
self
.
ins
,
destination
)
def
get_process_fragment
(
self
):
return
Fragment
()
# nothing to do
def
get_control_fragment
(
self
):
comb
=
[
self
.
sources
[
0
].
stb
.
eq
(
optree
(
'&'
,
[
sink
.
stb
for
sink
in
self
.
sinks
]))]
comb
+=
[
sink
.
ack
.
eq
(
self
.
sources
[
0
].
ack
&
self
.
sources
[
0
].
stb
)
for
sink
in
self
.
sinks
]
return
Fragment
(
comb
)
class
Splitter
(
Actor
):
def
__init__
(
self
,
source
,
*
subrecords
):
self
.
outs
=
[
source
.
subrecord
(
*
subr
)
for
subr
in
subrecords
]
Actor
.
__init__
(
self
,
SchedulingModel
(
SchedulingModel
.
COMBINATORIAL
),
source
,
self
.
outs
)
def
get_process_fragment
(
self
):
return
Fragment
()
# nothing to do
# TODO def get_control_fragment(self):
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