From dc2f813dda3b0fa10642a9a93c496fdda49f670e Mon Sep 17 00:00:00 2001 From: Hugo Winbladh <hugwi268@student.liu.se> Date: Thu, 15 Jun 2023 15:18:11 +0200 Subject: [PATCH] Fix examples after GraphID numbering change --- examples/firstorderiirfilter.py | 104 +++++++++--------- examples/fivepointwinograddft.py | 86 +++++++-------- examples/folding_example_with_architecture.py | 16 +-- .../secondorderdirectformiir_architecture.py | 22 ++-- examples/threepointwinograddft.py | 62 +++++------ examples/twotapfirsfg.py | 44 ++++---- 6 files changed, 167 insertions(+), 167 deletions(-) diff --git a/examples/firstorderiirfilter.py b/examples/firstorderiirfilter.py index 4dea6dcf..3a2ed744 100644 --- a/examples/firstorderiirfilter.py +++ b/examples/firstorderiirfilter.py @@ -78,59 +78,59 @@ firstorderiir.print_precedence_graph() # # .. graphviz:: # -# digraph { -# rankdir=LR -# subgraph cluster_0 { -# label=N0 -# "in1.0" [label=in1 height=0.1 shape=rectangle width=0.1] -# "t1.0" [label=t1 height=0.1 shape=rectangle width=0.1] -# } -# subgraph cluster_1 { -# label=N1 -# "cmul2.0" [label=cmul2 height=0.1 shape=rectangle width=0.1] -# "cmul1.0" [label=cmul1 height=0.1 shape=rectangle width=0.1] -# } -# subgraph cluster_2 { -# label=N2 -# "add1.0" [label=add1 height=0.1 shape=rectangle width=0.1] -# } -# subgraph cluster_3 { -# label=N3 -# "add2.0" [label=add2 height=0.1 shape=rectangle width=0.1] -# } -# "in1.0" -> add1 -# add1 [label=add1 shape=ellipse] -# in1 -> "in1.0" -# in1 [label=in1 shape=cds] -# "t1.0" -> cmul2 -# cmul2 [label=cmul2 shape=ellipse] -# "t1.0" -> cmul1 -# cmul1 [label=cmul1 shape=ellipse] -# t1Out -> "t1.0" -# t1Out [label=t1 shape=square] -# "cmul2.0" -> add2 -# add2 [label=add2 shape=ellipse] -# cmul2 -> "cmul2.0" -# cmul2 [label=cmul2 shape=ellipse] -# "cmul1.0" -> add1 -# add1 [label=add1 shape=ellipse] -# cmul1 -> "cmul1.0" -# cmul1 [label=cmul1 shape=ellipse] -# "add1.0" -> t1In -# t1In [label=t1 shape=square] -# "add1.0" -> add2 -# add2 [label=add2 shape=ellipse] -# add1 -> "add1.0" -# add1 [label=add1 shape=ellipse] -# "add2.0" -> out1 -# out1 [label=out1 shape=cds] -# add2 -> "add2.0" -# add2 [label=add2 shape=ellipse] -# } -# +# digraph { +# rankdir=LR +# subgraph cluster_0 { +# label=N0 +# "in0.0" [label=in0 height=0.1 shape=rectangle width=0.1] +# "t0.0" [label=t0 height=0.1 shape=rectangle width=0.1] +# } +# subgraph cluster_1 { +# label=N1 +# "cmul1.0" [label=cmul1 height=0.1 shape=rectangle width=0.1] +# "cmul0.0" [label=cmul0 height=0.1 shape=rectangle width=0.1] +# } +# subgraph cluster_2 { +# label=N2 +# "add0.0" [label=add0 height=0.1 shape=rectangle width=0.1] +# } +# subgraph cluster_3 { +# label=N3 +# "add1.0" [label=add1 height=0.1 shape=rectangle width=0.1] +# } +# "in0.0" -> add0 +# add0 [label=add0 shape=ellipse] +# in0 -> "in0.0" +# in0 [label=in0 shape=cds] +# "t0.0" -> cmul1 +# cmul1 [label=cmul1 shape=ellipse] +# "t0.0" -> cmul0 +# cmul0 [label=cmul0 shape=ellipse] +# t0Out -> "t0.0" +# t0Out [label=t0 shape=square] +# "cmul1.0" -> add1 +# add1 [label=add1 shape=ellipse] +# cmul1 -> "cmul1.0" +# cmul1 [label=cmul1 shape=ellipse] +# "cmul0.0" -> add0 +# add0 [label=add0 shape=ellipse] +# cmul0 -> "cmul0.0" +# cmul0 [label=cmul0 shape=ellipse] +# "add0.0" -> t0In +# t0In [label=t0 shape=square] +# "add0.0" -> add1 +# add1 [label=add1 shape=ellipse] +# add0 -> "add0.0" +# add0 [label=add0 shape=ellipse] +# "add1.0" -> out0 +# out0 [label=out0 shape=cds] +# add1 -> "add1.0" +# add1 [label=add1 shape=ellipse] +# } +# # As seen, each operation has an id, in addition to the optional name. # This can be used to access the operation. For example, -firstorderiir.find_by_id('cmul1') +firstorderiir.find_by_id('cmul0') # %% # Note that this operation differs from ``a1`` defined above as the operations are @@ -170,7 +170,7 @@ sim.results import matplotlib.pyplot as plt # noqa: E402 plt.plot(sim.results['0'], label="Output") -plt.plot(sim.results['add1'], label="After first addition") +plt.plot(sim.results['add0'], label="After first addition") plt.legend() plt.show() diff --git a/examples/fivepointwinograddft.py b/examples/fivepointwinograddft.py index dea0cd55..0787445e 100644 --- a/examples/fivepointwinograddft.py +++ b/examples/fivepointwinograddft.py @@ -80,54 +80,54 @@ schedule.show() # Reschedule to only use one AddSub and one multiplier schedule.set_schedule_time(10) -schedule.move_operation('out5', 12) -schedule.move_operation('out4', 11) -schedule.move_operation('out3', 10) -schedule.move_operation('out2', 9) -schedule.move_operation('out1', 12) -schedule.move_operation('bfly4', 10) -schedule.move_operation('bfly3', 9) -schedule.move_operation('bfly2', 7) -schedule.move_operation('addsub5', 5) -schedule.move_operation('addsub3', 5) +schedule.move_operation('out4', 12) +schedule.move_operation('out3', 11) +schedule.move_operation('out2', 10) +schedule.move_operation('out1', 9) +schedule.move_operation('out0', 12) +schedule.move_operation('bfly3', 10) +schedule.move_operation('bfly2', 9) +schedule.move_operation('bfly1', 7) +schedule.move_operation('addsub4', 5) schedule.move_operation('addsub2', 5) -schedule.move_operation('cmul5', 4) -schedule.move_operation('cmul3', 4) -schedule.move_operation('cmul1', 5) -schedule.move_operation('addsub1', 6) -schedule.move_operation('cmul2', 6) -schedule.move_operation('addsub4', 4) -schedule.move_operation('bfly1', 4) -schedule.move_operation('cmul4', 6) -schedule.move_operation('bfly6', 4) +schedule.move_operation('addsub1', 5) +schedule.move_operation('cmul4', 4) +schedule.move_operation('cmul2', 4) +schedule.move_operation('cmul0', 5) +schedule.move_operation('addsub0', 6) +schedule.move_operation('cmul1', 6) +schedule.move_operation('addsub3', 4) +schedule.move_operation('bfly0', 4) +schedule.move_operation('cmul3', 6) schedule.move_operation('bfly5', 4) -schedule.move_operation('in2', 1) -schedule.move_operation('in3', 2) -schedule.move_operation('in4', 3) -schedule.move_operation('in5', 4) -schedule.move_operation('bfly6', -1) -schedule.move_operation('bfly4', 1) -schedule.move_operation('cmul3', 1) -schedule.move_operation('cmul5', 1) -schedule.move_operation('bfly1', 1) +schedule.move_operation('bfly4', 4) +schedule.move_operation('in1', 1) +schedule.move_operation('in2', 2) +schedule.move_operation('in3', 3) +schedule.move_operation('in4', 4) +schedule.move_operation('bfly5', -1) +schedule.move_operation('bfly3', 1) +schedule.move_operation('cmul2', 1) +schedule.move_operation('cmul4', 1) +schedule.move_operation('bfly0', 1) +schedule.move_operation('addsub0', -1) +schedule.move_operation('cmul1', -3) +schedule.move_operation('cmul3', -2) +schedule.move_operation('cmul4', -1) +schedule.move_operation('addsub4', 1) +schedule.move_operation('addsub1', 2) +schedule.move_operation('cmul0', 1) +schedule.move_operation('bfly0', -1) +schedule.move_operation('addsub0', -1) +schedule.move_operation('bfly2', -1) +schedule.move_operation('cmul2', -1) +schedule.move_operation('cmul4', 1) +schedule.move_operation('addsub2', -1) +schedule.move_operation('addsub4', -1) schedule.move_operation('addsub1', -1) -schedule.move_operation('cmul2', -3) -schedule.move_operation('cmul4', -2) -schedule.move_operation('cmul5', -1) -schedule.move_operation('addsub5', 1) -schedule.move_operation('addsub2', 2) -schedule.move_operation('cmul1', 1) schedule.move_operation('bfly1', -1) -schedule.move_operation('addsub1', -1) +schedule.move_operation('bfly2', -2) schedule.move_operation('bfly3', -1) -schedule.move_operation('cmul3', -1) -schedule.move_operation('cmul5', 1) -schedule.move_operation('addsub3', -1) -schedule.move_operation('addsub5', -1) -schedule.move_operation('addsub2', -1) -schedule.move_operation('bfly2', -1) -schedule.move_operation('bfly3', -2) -schedule.move_operation('bfly4', -1) schedule.show() # %% diff --git a/examples/folding_example_with_architecture.py b/examples/folding_example_with_architecture.py index 289b9d1c..9baf92e0 100644 --- a/examples/folding_example_with_architecture.py +++ b/examples/folding_example_with_architecture.py @@ -53,17 +53,17 @@ schedule.show(title='Original schedule') # %% # Reschedule to only require one adder and one multiplier -schedule.move_operation('out1', 2) -schedule.move_operation('add3', 2) -schedule.move_operation('cmul3', -3) -schedule.move_operation('add4', 3) +schedule.move_operation('out0', 2) +schedule.move_operation('add2', 2) schedule.move_operation('cmul2', -3) +schedule.move_operation('add3', 3) +schedule.move_operation('cmul1', -3) schedule.set_schedule_time(4) -schedule.move_operation('cmul2', 1) -schedule.move_operation('cmul1', 1) -schedule.move_operation('in1', 3) -schedule.move_operation('cmul3', -1) schedule.move_operation('cmul1', 1) +schedule.move_operation('cmul0', 1) +schedule.move_operation('in0', 3) +schedule.move_operation('cmul2', -1) +schedule.move_operation('cmul0', 1) schedule.show(title='Improved schedule') # %% diff --git a/examples/secondorderdirectformiir_architecture.py b/examples/secondorderdirectformiir_architecture.py index 72d23961..a60c760d 100644 --- a/examples/secondorderdirectformiir_architecture.py +++ b/examples/secondorderdirectformiir_architecture.py @@ -47,11 +47,11 @@ schedule.show(title='Original schedule') # %% # Reschedule to only require one adder and one multiplier. -schedule.move_operation('add4', 2) -schedule.move_operation('cmul5', -4) -schedule.move_operation('cmul4', -5) -schedule.move_operation('cmul6', -2) -schedule.move_operation('cmul3', 1) +schedule.move_operation('add3', 2) +schedule.move_operation('cmul4', -4) +schedule.move_operation('cmul3', -5) +schedule.move_operation('cmul5', -2) +schedule.move_operation('cmul2', 1) schedule.show(title='Improved schedule') # %% @@ -100,11 +100,11 @@ arch = Architecture( arch # %% -# To reduce the amount of interconnect, the ``cuml3.0`` variable can be moved from +# To reduce the amount of interconnect, the ``cuml2.0`` variable can be moved from # ``memory0`` to ``memory2``. In this way, ``memory0`` only gets variables from the # adder and an input multiplexer can be avoided. The memories must be assigned again as # the contents have changed. -arch.move_process('cmul3.0', 'memory0', 'memory2') +arch.move_process('cmul2.0', 'memory0', 'memory2') memories[0].assign() memories[2].assign() @@ -117,9 +117,9 @@ memories[2].show_content("New assigned memory2") arch # %% -# It is of course also possible to move ``add4.0`` to ``memory2`` to save one memory +# It is of course also possible to move ``add3.0`` to ``memory2`` to save one memory # cell. It is possible to pass ``assign=True`` to perform assignment after moving. -arch.move_process('add4.0', 'memory0', 'memory2', assign=True) +arch.move_process('add3.0', 'memory0', 'memory2', assign=True) memories[0].show_content("New assigned memory0") memories[2].show_content("New assigned memory2") @@ -129,9 +129,9 @@ memories[2].show_content("New assigned memory2") arch # %% -# Finally, by noting that ``cmul1.0`` is the only variable from ``memory1`` going to +# Finally, by noting that ``cmul0.0`` is the only variable from ``memory1`` going to # ``in0`` of ``adder``, another multiplexer can be reduced by: -arch.move_process('cmul1.0', 'memory1', 'memory2', assign=True) +arch.move_process('cmul0.0', 'memory1', 'memory2', assign=True) memories[1].show_content("New assigned memory1") memories[2].show_content("New assigned memory2") diff --git a/examples/threepointwinograddft.py b/examples/threepointwinograddft.py index ff5cfa5a..38338b08 100644 --- a/examples/threepointwinograddft.py +++ b/examples/threepointwinograddft.py @@ -59,40 +59,40 @@ schedule.show() # Reschedule to only use one AddSub and one multiplier schedule.set_schedule_time(10) -schedule.move_operation('out2', 3) -schedule.move_operation('out3', 4) -schedule.move_operation('addsub5', 2) -schedule.move_operation('addsub4', 3) -schedule.move_operation('addsub3', 2) -schedule.move_operation('cmul2', 2) -schedule.move_operation('cmul1', 2) -schedule.move_operation('out1', 5) -schedule.move_operation('addsub1', 3) -schedule.move_operation('addsub6', 2) +schedule.move_operation('out1', 3) +schedule.move_operation('out2', 4) +schedule.move_operation('addsub4', 2) +schedule.move_operation('addsub3', 3) schedule.move_operation('addsub2', 2) -schedule.move_operation('in2', 1) -schedule.move_operation('in3', 2) -schedule.move_operation('cmul2', 1) -schedule.move_operation('out3', 6) +schedule.move_operation('cmul1', 2) +schedule.move_operation('cmul0', 2) +schedule.move_operation('out0', 5) +schedule.move_operation('addsub0', 3) +schedule.move_operation('addsub5', 2) +schedule.move_operation('addsub1', 2) +schedule.move_operation('in1', 1) +schedule.move_operation('in2', 2) +schedule.move_operation('cmul1', 1) schedule.move_operation('out2', 6) schedule.move_operation('out1', 6) -schedule.move_operation('addsub6', 1) -schedule.move_operation('addsub4', 3) -schedule.move_operation('addsub5', 4) -schedule.move_operation('addsub4', 1) -schedule.move_operation('addsub5', 4) -schedule.move_operation('cmul2', 3) -schedule.move_operation('addsub4', 2) -schedule.move_operation('cmul2', 3) -schedule.move_operation('addsub3', 5) +schedule.move_operation('out0', 6) +schedule.move_operation('addsub5', 1) +schedule.move_operation('addsub3', 3) +schedule.move_operation('addsub4', 4) +schedule.move_operation('addsub3', 1) +schedule.move_operation('addsub4', 4) +schedule.move_operation('cmul1', 3) +schedule.move_operation('addsub3', 2) +schedule.move_operation('cmul1', 3) +schedule.move_operation('addsub2', 5) schedule.set_schedule_time(6) -schedule.move_operation('addsub1', 1) -schedule.move_operation('addsub4', -1) -schedule.move_operation('cmul2', -2) -schedule.move_operation('addsub4', -1) -schedule.move_operation('addsub1', -1) +schedule.move_operation('addsub0', 1) +schedule.move_operation('addsub3', -1) +schedule.move_operation('cmul1', -2) schedule.move_operation('addsub3', -1) -schedule.move_operation('addsub5', -4) +schedule.move_operation('addsub0', -1) +schedule.move_operation('addsub2', -1) +schedule.move_operation('addsub4', -4) schedule.show() # Extract memory variables and operation executions @@ -139,8 +139,8 @@ arch # %% # Move memory variables -arch.move_process('addsub2.0', memories[2], memories[1]) -arch.move_process('addsub4.0', memories[1], memories[2], assign=True) +arch.move_process('addsub1.0', memories[2], memories[1]) +arch.move_process('addsub3.0', memories[1], memories[2], assign=True) memories[1].assign() memories[1].show_content(title="Assigned memory1") diff --git a/examples/twotapfirsfg.py b/examples/twotapfirsfg.py index 87a90e1c..3d8b6b7e 100644 --- a/examples/twotapfirsfg.py +++ b/examples/twotapfirsfg.py @@ -14,40 +14,40 @@ from b_asic import ( ) # Inputs: -in1 = Input(name="in_1") +in0 = Input(name="in_0") # Outputs: -out1 = Output(name="out1") +out0 = Output(name="out0") # Operations: -t1 = Delay(initial_value=0, name="t1") -cmul1 = ConstantMultiplication( - value=0.5, name="cmul1", latency_offsets={'in0': None, 'out0': None} +t0 = Delay(initial_value=0, name="t0") +cmul0 = ConstantMultiplication( + value=0.5, name="cmul0", latency_offsets={'in0': None, 'out0': None} ) -add1 = Addition( - name="add1", latency_offsets={'in0': None, 'in1': None, 'out0': None} +add0 = Addition( + name="add0", latency_offsets={'in0': None, 'in1': None, 'out0': None} ) -cmul2 = ConstantMultiplication( - value=0.5, name="cmul2", latency_offsets={'in0': None, 'out0': None} +cmul1 = ConstantMultiplication( + value=0.5, name="cmul1", latency_offsets={'in0': None, 'out0': None} ) # Signals: -Signal(source=t1.output(0), destination=cmul1.input(0)) -Signal(source=in1.output(0), destination=t1.input(0)) -Signal(source=in1.output(0), destination=cmul2.input(0)) -Signal(source=cmul1.output(0), destination=add1.input(0)) -Signal(source=add1.output(0), destination=out1.input(0)) -Signal(source=cmul2.output(0), destination=add1.input(1)) -twotapfir = SFG(inputs=[in1], outputs=[out1], name='twotapfir') +Signal(source=t0.output(0), destination=cmul0.input(0)) +Signal(source=in0.output(0), destination=t0.input(0)) +Signal(source=in0.output(0), destination=cmul1.input(0)) +Signal(source=cmul0.output(0), destination=add0.input(0)) +Signal(source=add0.output(0), destination=out0.input(0)) +Signal(source=cmul1.output(0), destination=add0.input(1)) +twotapfir = SFG(inputs=[in0], outputs=[out0], name='twotapfir') # SFG Properties: prop = {'name': twotapfir} positions = { - 't1': (-209, 19), - 'cmul1': (-95, 76), - 'add1': (0, 95), - 'cmul2': (-209, 114), - 'out1': (76, 95), - 'in1': (-323, 19), + 't0': (-209, 19), + 'cmul0': (-95, 76), + 'add0': (0, 95), + 'cmul1': (-209, 114), + 'out0': (76, 95), + 'in0': (-323, 19), } -- GitLab