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
a3bf8778
Commit
a3bf8778
authored
12 years ago
by
Sebastien Bourdeauducq
Browse files
Options
Download
Email Patches
Plain Diff
ALA: use records for tokens
parent
1905eb37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
migen/flow/ala.py
migen/flow/ala.py
+13
-11
No files found.
migen/flow/ala.py
View file @
a3bf8778
from
migen.fhdl.structure
import
*
from
migen.flow.actor
import
*
from
migen.corelogic.record
import
*
from
migen.corelogic
import
divider
class
Sum
(
Actor
):
class
Adder
(
Actor
):
def
__init__
(
self
,
width
):
self
.
a
=
Signal
(
BV
(
width
))
self
.
b
=
Signal
(
BV
(
width
))
self
.
r
=
Signal
(
BV
(
width
+
1
))
self
.
operands
=
Record
([(
'a'
,
BV
(
width
)),
(
'b'
,
BV
(
width
))])
self
.
result
=
Record
([
'sum'
,
BV
(
width
+
1
)])
Actor
.
__init__
(
self
,
SchedulingModel
(
SchedulingModel
.
COMBINATORIAL
),
[
Sink
(
self
,
[
self
.
a
,
self
.
b
]
)],
[
Source
(
self
,
self
.
r
)])
[
Sink
(
self
,
self
.
operands
)],
[
Source
(
self
,
self
.
r
esult
)])
def
get_process_fragment
(
self
):
return
Fragment
([
self
.
r
.
eq
(
self
.
a
+
self
.
b
)])
return
Fragment
([
self
.
r
esult
.
sum
.
eq
(
self
.
operands
.
a
+
self
.
operands
.
b
)])
class
Divider
(
Actor
):
def
__init__
(
self
,
width
):
self
.
div
=
divider
.
Inst
(
width
)
self
.
operands
=
Record
([(
'dividend'
,
self
.
div
.
dividend_i
),
(
'divisor'
,
self
.
div
.
divisor_i
)])
self
.
result
=
Record
([(
'quotient'
,
self
.
div
.
quotient_o
),
(
'remainder'
,
self
.
div
.
remainder_o
)])
Actor
.
__init__
(
self
,
SchedulingModel
(
SchedulingModel
.
SEQUENTIAL
,
width
),
[
Sink
(
self
,
[
self
.
div
.
dividend_i
]),
Sink
(
self
,
[
self
.
div
.
divisor_i
])],
[
Source
(
self
,
[
self
.
div
.
quotient_o
]),
Source
(
self
,
[
self
.
div
.
remainder_o
])])
[
Sink
(
self
,
[
self
.
operands
])],
[
Source
(
self
,
[
self
.
result
])])
def
get_process_fragment
(
self
):
return
self
.
div
.
get_fragment
()
+
Fragment
([
self
.
div
.
start_i
.
eq
(
self
.
trigger
)])
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