Add common.deduce_ports, improve to_signed
This commit is contained in:
parent
8d2c12225b
commit
b865a8d19a
@ -8,6 +8,13 @@ pipeline = data *: funcs -> data where
|
||||
data = func data
|
||||
|
||||
# cast to signed, extending the signal by one bit
|
||||
to_signed = signal -> out where
|
||||
out = Signal$ signed (signal.width + 1)
|
||||
Comb$ out ::= signal
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user