def test_bench_no_trigger(node: PythonNode): """This node sends 2 consecutive messages, the first is a data signal, the second is a trigger to move out of a specific state of the migen FSM. """ node.send(TestBenchFork(15, 0)) node.send(TestBenchFork(0, 1))
def opt_increment(node: PythonNode): n = 0 while n < 3: node.send(TwoInts(n, None)) n = node.receive("n") node.send(TwoInts(None, n))
def interactive_func(node: PythonNode): while(True): num = node.receive()["num"] print(f"received num = {num}") opt = node.receive()["opt"] if opt: print(f"received opt={opt}") val = node.receive()["val"] node.send(num + val + 1)
def add_until_10(node: PythonNode): """Sends num on the left port until it is greater than 10, then sends it on the right port. """ num = 1 while num < 10: node.send(TwoInts(num, None)) num = node.receive()["num"] node.send(TwoInts(None, num))
def test_bench_yes_trigger(node: PythonNode): """This node sends 3 consecutive messages, the first is a data signal, the second is the same data signal, and the third is a trigger to move out of a specific state of the migen FSM. """ node.send(TestBenchFork(15, 0)) # make inp.data available for an extra cycle of migen clock node.send(TestBenchFork(15, 0)) node.send(TestBenchFork(0, 1))
def add_print_t(a: int, b: int, node: PythonNode = None) -> Void: print(node.receive('a') + node.receive('b')) raise DeltaRuntimeExit
def add_set_x_t(self, a: int, b: int, node: PythonNode = None) -> Void: self.x = node.receive('a') + node.receive('b') raise DeltaRuntimeExit
def add_assert(a: int, b: int, node: PythonNode = None) -> Void: self.assertEqual(node.receive('a') + node.receive('b'), 9) raise DeltaRuntimeExit
def forward(node: PythonNode): for _ in range(10): num = node.receive("num") node.send(num) raise DeltaRuntimeExit
def interactive_func(node: PythonNode): node.send(3) num = node.receive()["num"] num = int(num, base=10) node.send(num + 1)
def interactive_func(node: PythonNode): for _ in range(10): num = node.receive()["num"] print(f"received num: {num}") node.send(num + 1)
def send_5(node: PythonNode): node.send(5)