Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • da/B-ASIC
  • lukja239/B-ASIC
  • robal695/B-ASIC
3 results
Show changes
Commits on Source (2)
......@@ -5,9 +5,10 @@ import string
import io
import sys
from b_asic import SFG, Signal, Input, Output, Constant, ConstantMultiplication, Addition, Multiplication, Delay, \
Butterfly, Subtraction, SquareRoot
from b_asic import SFG, Signal, Input, Output, Delay, FastSimulation
from b_asic.core_operations import Constant, Addition, Subtraction, Multiplication, \
Division, Min, Max, SquareRoot, ComplexConjugate, Absolute, ConstantMultiplication, \
Butterfly
from b_asic.save_load_structure import sfg_to_python, python_to_sfg
......@@ -283,6 +284,113 @@ class TestReplaceComponents:
assert False
class TestConstructSFG:
def test_1k_additions(self):
prev_op = Addition(Constant(1), Constant(1))
for _ in range(999):
prev_op = Addition(prev_op, Constant(2))
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 2000
def test_1k_subtractions(self):
prev_op = Subtraction(Constant(0), Constant(2))
for _ in range(999):
prev_op = Subtraction(prev_op, Constant(2))
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == -2000
def test_1k_butterfly(self):
prev_op_add = Addition(Constant(1), Constant(1))
prev_op_sub = Subtraction(Constant(-1), Constant(1))
for _ in range(499):
prev_op_add = Addition(prev_op_add, Constant(2))
for _ in range(499):
prev_op_sub = Subtraction(prev_op_sub, Constant(2))
butterfly = Butterfly(prev_op_add, prev_op_sub)
sfg = SFG(outputs=[Output(butterfly.output(0)), Output(butterfly.output(1))])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 0
assert sim.results["1"][0].real == 2000
def test_1k_multiplications(self):
prev_op = Multiplication(Constant(3), Constant(0.5))
for _ in range(999):
prev_op = Multiplication(prev_op, Constant(1.01))
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 31127.458868040336
def test_1k_divisions(self):
prev_op = Division(Constant(3), Constant(0.5))
for _ in range(999):
prev_op = Division(prev_op, Constant(1.01))
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 0.00028913378500165966
def test_1k_mins(self):
prev_op = Min(Constant(3.14159), Constant(43.14123843))
for _ in range(999):
prev_op = Min(prev_op, Constant(43.14123843))
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 3.14159
def test_1k_maxs(self):
prev_op = Max(Constant(3.14159), Constant(43.14123843))
for _ in range(999):
prev_op = Max(prev_op, Constant(3.14159))
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 43.14123843
def test_1k_square_roots(self):
prev_op = SquareRoot(Constant(1000000))
for _ in range(4):
prev_op = SquareRoot(prev_op)
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 1.539926526059492
def test_1k_complex_conjugates(self):
prev_op = ComplexConjugate(Constant(10+5j))
for _ in range(999):
prev_op = ComplexConjugate(prev_op)
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"] == [10+5j]
def test_1k_absolutes(self):
prev_op = Absolute(Constant(-3.14159))
for _ in range(999):
prev_op = Absolute(prev_op)
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 3.14159
def test_1k_constant_multiplications(self):
prev_op = ConstantMultiplication(1.02, Constant(3.14159))
for _ in range(999):
prev_op = ConstantMultiplication(1.02, prev_op)
sfg = SFG(outputs=[Output(prev_op)])
sim = FastSimulation(sfg)
sim.step()
assert sim.results["0"][0].real == 1251184247.0026844
class TestInsertComponent:
def test_insert_component_in_sfg(self, large_operation_tree_names):
......