Skip to content
Snippets Groups Projects
Commit 6698c9a9 authored by Simon Bjurek's avatar Simon Bjurek
Browse files

improved some of the styling

parent 96c159b8
No related branches found
No related tags found
1 merge request!461Finalize earliest deadline scheduler
Pipeline #154827 passed
......@@ -264,6 +264,8 @@ def direct_form_1_iir(
mult_properties: Optional[Union[Dict[str, int], Dict[str, Dict[str, int]]]] = None,
add_properties: Optional[Union[Dict[str, int], Dict[str, Dict[str, int]]]] = None,
) -> SFG:
if len(a) != len(b):
raise ValueError("size of coefficient lists a and b are not the same")
if name is None:
name = "Direct-form I IIR filter"
if mult_properties is None:
......@@ -271,10 +273,8 @@ def direct_form_1_iir(
if add_properties is None:
add_properties = {}
input_op = Input()
output = Output()
# construct the feed-forward part
input_op = Input()
muls = [ConstantMultiplication(b[0], input_op, **mult_properties)]
delays = []
prev_delay = input_op
......@@ -290,8 +290,8 @@ def direct_form_1_iir(
# construct the feedback part
tmp_add = Addition(op_a, None, **add_properties)
# muls = [ConstantMultiplication(a[0], tmp_add, **mult_properties)]
muls = []
output = Output()
output <<= tmp_add
delays = []
......@@ -318,6 +318,8 @@ def direct_form_2_iir(
mult_properties: Optional[Union[Dict[str, int], Dict[str, Dict[str, int]]]] = None,
add_properties: Optional[Union[Dict[str, int], Dict[str, Dict[str, int]]]] = None,
) -> SFG:
if len(a) != len(b):
raise ValueError("size of coefficient lists a and b are not the same")
if name is None:
name = "Direct-form I IIR filter"
if mult_properties is None:
......@@ -325,18 +327,12 @@ def direct_form_2_iir(
if add_properties is None:
add_properties = {}
input_op = Input()
# construct the repeated part of the SFG
left_adds = []
right_adds = []
left_muls = []
right_muls = []
delays = [Delay()]
if len(a) != len(b):
raise ValueError("size of coefficient lists a and b are not the same")
# all except the final
op_a_left = None
op_a_right = None
for i in range(len(a) - 1):
......@@ -361,7 +357,8 @@ def direct_form_2_iir(
op_a_left = left_muls[-1]
op_a_right = right_muls[-1]
# finalize
# finalize the SFG
input_op = Input()
if left_adds:
left_adds.append(Addition(input_op, left_adds[-1], **add_properties))
else:
......@@ -369,7 +366,6 @@ def direct_form_2_iir(
delays[-1] <<= left_adds[-1]
mul = ConstantMultiplication(b[0], left_adds[-1], **mult_properties)
add = Addition(mul, right_adds[-1], **add_properties)
output = Output()
output <<= add
return SFG([input_op], [output], name=Name(name))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment