From b043d5c890ec66474e19824d863996d4461bab98 Mon Sep 17 00:00:00 2001
From: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Date: Mon, 15 May 2023 13:25:25 +0200
Subject: [PATCH] Make branch_node=True default

---
 b_asic/signal_flow_graph.py                   |  8 ++++----
 examples/folding_example_with_architecture.py |  3 ++-
 examples/schedulingexample.py                 |  2 +-
 examples/secondorderdirectformiir.py          |  4 ++++
 test/test_sfg.py                              | 15 +++++++++++----
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py
index e9e47845..7bcb273e 100644
--- a/b_asic/signal_flow_graph.py
+++ b/b_asic/signal_flow_graph.py
@@ -1393,7 +1393,7 @@ class SFG(AbstractOperation):
         self,
         show_id: bool = False,
         engine: Optional[str] = None,
-        branch_node: bool = False,
+        branch_node: bool = True,
         port_numbering: bool = True,
         splines: str = "spline",
     ) -> Digraph:
@@ -1409,7 +1409,7 @@ class SFG(AbstractOperation):
         engine : string, optional
             Graphviz layout engine to be used, see https://graphviz.org/documentation/.
             Most common are "dot" and "neato". Default is None leading to dot.
-        branch_node : bool, default: False
+        branch_node : bool, default: True
             Add a branch node in case the fan-out of a signal is two or more.
         port_numbering : bool, default: True
             Show the port number in case the number of ports (input or output) is two or
@@ -1503,7 +1503,7 @@ class SFG(AbstractOperation):
         fmt: Optional[str] = None,
         show_id: bool = False,
         engine: Optional[str] = None,
-        branch_node: bool = False,
+        branch_node: bool = True,
         port_numbering: bool = True,
         splines: str = "spline",
     ) -> None:
@@ -1522,7 +1522,7 @@ class SFG(AbstractOperation):
         engine : string, optional
             Graphviz layout engine to be used, see https://graphviz.org/documentation/.
             Most common are "dot" and "neato". Default is None leading to dot.
-        branch_node : bool, default: False
+        branch_node : bool, default: True
             Add a branch node in case the fan-out of a signal is two or more.
         port_numbering : bool, default: True
             Show the port number in case the number of ports (input or output) is two or
diff --git a/examples/folding_example_with_architecture.py b/examples/folding_example_with_architecture.py
index 8eea8e4d..5d531dd8 100644
--- a/examples/folding_example_with_architecture.py
+++ b/examples/folding_example_with_architecture.py
@@ -120,11 +120,12 @@ arch = Architecture({p1, p2, p_in, p_out}, memories, direct_interconnects=direct
 #        cmul [label="{{<in0> in0}|cmul|{<out0> out0}}"]
 #        memory1:out0 -> adder:in1 [label=2]
 #        cmul:out0 -> adder:in0 [label=2]
-#        memory0:out0 -> cmul:in0 [label=4]
+#        memory0:out0 -> cmul:in0 [label=3]
 #        adder:out0 -> output:in0 [label=1]
 #        input:out0 -> adder:in0 [label=1]
 #        adder:out0 -> memory0:in0 [label=1]
 #        adder:out0 -> adder:in1 [label=2]
 #        memory0:out0 -> adder:in0 [label=1]
+#        adder:out0 -> cmul:in0 [label=1]
 #        cmul:out0 -> memory1:in0 [label=2]
 #    }
diff --git a/examples/schedulingexample.py b/examples/schedulingexample.py
index 44e3f946..e0e82b56 100644
--- a/examples/schedulingexample.py
+++ b/examples/schedulingexample.py
@@ -29,5 +29,5 @@ node4 << node3
 
 sfg = SFG([node1], [out], name="Scheduling example")
 # %%
-# THe SFG looks like
+# The SFG looks like
 sfg
diff --git a/examples/secondorderdirectformiir.py b/examples/secondorderdirectformiir.py
index e78a48f3..b4eee825 100644
--- a/examples/secondorderdirectformiir.py
+++ b/examples/secondorderdirectformiir.py
@@ -29,6 +29,10 @@ out1 = Output(add4, "OUT1")
 
 sfg = SFG(inputs=[in1], outputs=[out1], name="Second-order direct form IIR filter")
 
+# %%
+# The SFG looks like
+sfg
+
 # %%
 # Set latencies and execution times
 sfg.set_latency_of_type(ConstantMultiplication.type_name(), 2)
diff --git a/test/test_sfg.py b/test/test_sfg.py
index 5cc0d416..f6a42e7a 100644
--- a/test/test_sfg.py
+++ b/test/test_sfg.py
@@ -1250,7 +1250,10 @@ class TestSFGGraph:
             ' [shape=ellipse]\n\tcmul1 -> add1 [headlabel=1]\n\tcmul1'
             ' [shape=ellipse]\n\tadd1 -> t1\n\tt1 [shape=square]\n\tt1 -> cmul1\n}'
         )
-        assert sfg_simple_filter.sfg_digraph().source in (res, res + "\n")
+        assert sfg_simple_filter.sfg_digraph(branch_node=False).source in (
+            res,
+            res + "\n",
+        )
 
     def test_sfg_show_id(self, sfg_simple_filter):
         res = (
@@ -1261,7 +1264,9 @@ class TestSFGGraph:
             ' [shape=square]\n\tt1 -> cmul1 [label=s5]\n}'
         )
 
-        assert sfg_simple_filter.sfg_digraph(show_id=True).source in (
+        assert sfg_simple_filter.sfg_digraph(
+            show_id=True, branch_node=False
+        ).source in (
             res,
             res + "\n",
         )
@@ -1276,7 +1281,7 @@ class TestSFGGraph:
             ' cmul1\n}'
         )
 
-        assert sfg_simple_filter.sfg_digraph(branch_node=True).source in (
+        assert sfg_simple_filter.sfg_digraph().source in (
             res,
             res + "\n",
         )
@@ -1289,7 +1294,9 @@ class TestSFGGraph:
             ' -> cmul1\n}'
         )
 
-        assert sfg_simple_filter.sfg_digraph(port_numbering=False).source in (
+        assert sfg_simple_filter.sfg_digraph(
+            port_numbering=False, branch_node=False
+        ).source in (
             res,
             res + "\n",
         )
-- 
GitLab