Confusing SFG error message on missed connection
ValueError: Unconnected input port in SFG
is going to be confusing error message for students during the lab session once the eventually miss a connection in a SFG.
MRE:
##
# SFG of Lab1: Task 2
#
from b_asic.core_operations import Addition, ConstantMultiplication
from b_asic.special_operations import Input, Output, Delay
from b_asic.signal_flow_graph import SFG
x = Input()
y = Output()
d1, d2 = (Delay(), Delay())
b1, b2, a0, a1, a2 = (
ConstantMultiplication( 179/512, d1), # b1
ConstantMultiplication(-171/512, d2), # b2
ConstantMultiplication( 57/256), # a0
ConstantMultiplication( 55/128, d1), # a1
ConstantMultiplication( 57/256, d2), # a2
)
add0 = Addition(b1, b2)
add1 = Addition(a1, a2)
add2 = Addition(x, add0)
add3 = Addition(a0, add1)
# a0.input(0).connect(add2) # <--- Forgotten input
d1.input(0).connect(add2)
d2.input(0).connect(d1)
y.input(0).connect(add3)
sfg = SFG([x], [y])
sfg
runcell(2, '/home/mikhe33/education/tste87/2024/lab1/lab1.py')
Traceback (most recent call last):
File ~/education/tste87/2024/basic-venv/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
exec(code, globals, locals)
File ~/education/tste87/2024/lab1/lab1.py:72
sfg = SFG([x], [y])
File ~/education/tste87/2024/B-ASIC/b_asic/signal_flow_graph.py:262 in __init__
self._add_operation_connected_tree_copy(
File ~/education/tste87/2024/B-ASIC/b_asic/signal_flow_graph.py:1276 in _add_operation_connected_tree_copy
raise ValueError("Unconnected input port in SFG")
ValueError: Unconnected input port in SFG
Edited by Mikael Henriksson