From 7d53d11f95cc3bcac0d11f747860d2c523af2ecf Mon Sep 17 00:00:00 2001
From: Kevin <Kevin>
Date: Fri, 24 Apr 2020 14:03:14 +0200
Subject: [PATCH] added test case for replacing multiply-and-add with MAC

---
 test/test_sfg.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/test/test_sfg.py b/test/test_sfg.py
index 222bfe23..b1e4f18c 100644
--- a/test/test_sfg.py
+++ b/test/test_sfg.py
@@ -1,6 +1,6 @@
 import pytest
 
-from b_asic import SFG, Signal, Input, Output, Constant, Addition, Multiplication
+from b_asic import SFG, Signal, Input, Output, Constant, Addition, Multiplication, MAD
 
 
 class TestInit:
@@ -254,3 +254,22 @@ class TestReplaceComponents:
             assert True
         else:
             assert False
+
+class TestReplaceOperations:
+    def test_replace_mul_add_with_MAD(self):
+        in1 = Input()
+        in2 = Input()
+        in3 = Input()
+        mul1 = in1 * in2
+        add1 = mul1 + in3
+        out1 = Output(add1)
+
+        sfg = SFG(inputs=[in1, in2, in3], outputs=[out1])
+        assert len(sfg.operations) == 6
+
+        mad1 = MAD()
+
+        sfg.replace_operations([in1, in2, in3], [out1], mad1)
+        assert len(sfg.operations) == 5
+        assert {add1, mul1} not in sfg.operations
+        
\ No newline at end of file
-- 
GitLab