2020-08-15 15:50:36 +02:00
|
|
|
import "/nmigen_dg/*"
|
|
|
|
|
|
|
|
# result = pipeline 5
|
|
|
|
# bind (+) 1
|
|
|
|
# bind (-) 5
|
|
|
|
pipeline = data *: funcs -> data where
|
|
|
|
for func in funcs =>
|
|
|
|
data = func data
|
|
|
|
|
|
|
|
# cast to signed, extending the signal by one bit
|
2020-08-19 16:34:16 +02:00
|
|
|
to_signed = signal ->
|
|
|
|
Cat signal 0 |>.as_signed!
|
|
|
|
|
|
|
|
# only works before any elaboration, assuming ports are defined in __init__
|
|
|
|
deduce_ports = elaboratable -> ports where
|
|
|
|
ports = []
|
|
|
|
for name in dir elaboratable =>
|
|
|
|
if not$ name.startswith "_" =>
|
|
|
|
value = getattr elaboratable name
|
|
|
|
value :: Signal => ports.append value
|