From ff6dc1bef251c13dedda1fdc8adbafbeee176146 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 2 Jul 2018 09:01:30 +0100 Subject: [PATCH] add some more unit tests as an experiment --- src/test_bsv/tests/test_pinmux.py | 58 ++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/src/test_bsv/tests/test_pinmux.py b/src/test_bsv/tests/test_pinmux.py index e2ad15c..c9ab9a4 100644 --- a/src/test_bsv/tests/test_pinmux.py +++ b/src/test_bsv/tests/test_pinmux.py @@ -10,22 +10,62 @@ import random def pinmux_basic_test(dut): """Test for 5 + 10""" yield Timer(2) - A = 5 - B = 10 - - print dir(dut) dut.mux_lines_cell0_mux_in = 1 dut.mux_lines_cell1_mux_in = 2 dut.mux_lines_cell2_mux_in = 0 + yield Timer(2) + dut.EN_mux_lines_cell0_mux = 1 + dut.EN_mux_lines_cell1_mux = 1 + dut.EN_mux_lines_cell2_mux = 1 + yield Timer(2) + dut.peripheral_side_uart_tx_in = 1 + dut.peripheral_side_gpioa_a0_outen_in = 1 yield Timer(2) - if int(dut.X) != pinmux_model(A, B): + dut.peripheral_side_gpioa_a2_out_in = 0 + dut.peripheral_side_gpioa_a2_outen_in = 1 + + yield Timer(2) + + if dut.iocell_side_io2_cell_out != 0: raise TestFailure( - "Adder result is incorrect: %s != 15" % str(dut.X)) - else: # these last two lines are not strictly necessary - dut._log.info("Ok!") + "gpioa_a2=0/mux=0/out=1 %s iocell_io2 != 0" % \ + str(dut.iocell_side_io2_cell_out )) + + dut.peripheral_side_gpioa_a2_out_in = 1 + + yield Timer(2) + + if dut.iocell_side_io2_cell_out != 1: + raise TestFailure( + "gpioa_a2=0/mux=0/out=1 %s iocell_io2 != 1" % \ + str(dut.iocell_side_io2_cell_out )) + + # UART + yield Timer(2) + dut.peripheral_side_uart_tx_in = 1 + dut.peripheral_side_gpioa_a0_outen_in = 1 + + yield Timer(2) + + if dut.iocell_side_io0_cell_out != 1: + raise TestFailure( + "uart_tx=1/mux=0/out=1 %s iocell_io0 != 1" % \ + str(dut.iocell_side_io0_cell_out )) + + dut.peripheral_side_uart_tx_in = 0 + + yield Timer(2) + + if dut.iocell_side_io0_cell_out != 0: + raise TestFailure( + "uart_tx=0/mux=0/out=1 %s iocell_io0 != 0" % \ + str(dut.iocell_side_io0_cell_out )) + + dut._log.info("Ok!") + yield Timer(2) @cocotb.test() @@ -33,6 +73,8 @@ def pinmux_randomised_test(dut): """Test for adding 2 random numbers multiple times""" yield Timer(2) + return + for i in range(10): A = random.randint(0, 15) B = random.randint(0, 15) -- 2.30.2