.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/secondorderdirectformiir.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_secondorderdirectformiir.py: ===================================== Second-order IIR Filter with Schedule ===================================== .. GENERATED FROM PYTHON SOURCE LINES 7-33 .. code-block:: Python from b_asic.core_operations import Addition, ConstantMultiplication from b_asic.schedule import Schedule from b_asic.scheduler import ASAPScheduler from b_asic.sfg import SFG from b_asic.special_operations import Delay, Input, Output in1 = Input("IN1") c0 = ConstantMultiplication(5, in1, "C0") add1 = Addition(c0, None, "ADD1") # Not sure what operation "Q" is supposed to be in the example T1 = Delay(add1, 0, "T1") T2 = Delay(T1, 0, "T2") b2 = ConstantMultiplication(0.2, T2, "B2") b1 = ConstantMultiplication(0.3, T1, "B1") add2 = Addition(b1, b2, "ADD2") add1.input(1).connect(add2) a1 = ConstantMultiplication(0.4, T1, "A1") a2 = ConstantMultiplication(0.6, T2, "A2") add3 = Addition(a1, a2, "ADD3") a0 = ConstantMultiplication(0.7, add1, "A0") add4 = Addition(a0, add3, "ADD4") out1 = Output(add4, "OUT1") sfg = SFG(inputs=[in1], outputs=[out1], name="Second-order direct form IIR filter") .. GENERATED FROM PYTHON SOURCE LINES 34-35 The SFG looks like .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: Python sfg .. raw:: html
%3 in0 IN1 (in0) cmul0 C0 (cmul0) in0:e->cmul0 add0 ADD1 (add0) cmul0->add0 0 out0 OUT1 (out0) add2 ADD4 (add2) add2->out0:w add0.0 add0->add0.0 add1 ADD2 (add1) add1->add0 1 t0 T1 (t0) add0.0->t0 cmul1 A0 (cmul1) add0.0->cmul1 t0.0 t0->t0.0 cmul1->add2 0 add3 ADD3 (add3) add3->add2 1 cmul2 A1 (cmul2) cmul2->add3 0 cmul3 A2 (cmul3) cmul3->add3 1 t1.0 t1.0->cmul3 cmul4 B2 (cmul4) t1.0->cmul4 t1 T2 (t1) t1->t1.0 t0.0->cmul2 t0.0->t1 cmul5 B1 (cmul5) t0.0->cmul5 cmul4->add1 1 cmul5->add1 0


.. GENERATED FROM PYTHON SOURCE LINES 38-39 Set latencies and execution times .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: Python sfg.set_latency_of_type(ConstantMultiplication, 2) sfg.set_latency_of_type(Addition, 1) sfg.set_execution_time_of_type(ConstantMultiplication, 1) sfg.set_execution_time_of_type(Addition, 1) .. GENERATED FROM PYTHON SOURCE LINES 45-46 Create schedule .. GENERATED FROM PYTHON SOURCE LINES 46-49 .. code-block:: Python schedule = Schedule(sfg, scheduler=ASAPScheduler(), cyclic=True) schedule .. raw:: html
2026-06-03T14:26:25.167187 image/svg+xml Matplotlib v3.10.9, https://matplotlib.org/


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.148 seconds) .. _sphx_glr_download_examples_secondorderdirectformiir.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: secondorderdirectformiir.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: secondorderdirectformiir.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: secondorderdirectformiir.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_