From 6d6ee6778edcbca12bc322839c061fe788bb86ba Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 3 May 2020 19:31:37 +0200 Subject: testsuite/synth: add a regression test for previous commits. --- testsuite/synth/int01/prio02.vhdl | 25 +++++++++++++++++++++++++ testsuite/synth/int01/tb_prio02.vhdl | 30 ++++++++++++++++++++++++++++++ testsuite/synth/int01/testsuite.sh | 9 ++++----- 3 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 testsuite/synth/int01/prio02.vhdl create mode 100644 testsuite/synth/int01/tb_prio02.vhdl (limited to 'testsuite') diff --git a/testsuite/synth/int01/prio02.vhdl b/testsuite/synth/int01/prio02.vhdl new file mode 100644 index 000000000..d6b164d19 --- /dev/null +++ b/testsuite/synth/int01/prio02.vhdl @@ -0,0 +1,25 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity prio02 is + port (dat : std_logic_vector(15 downto 0); + prio : out natural); +end; + +architecture behav of prio02 is + function prioritize(b : std_logic_vector(15 downto 0)) return natural + is + variable level : integer range 0 to 15; + begin + level := 0; + for i in 15 downto 0 loop + level := i; + if b(i) = '1' then exit; end if; + end loop; + return level; + end; +begin + prio <= prioritize (dat); +end; + diff --git a/testsuite/synth/int01/tb_prio02.vhdl b/testsuite/synth/int01/tb_prio02.vhdl new file mode 100644 index 000000000..cc1fa40b6 --- /dev/null +++ b/testsuite/synth/int01/tb_prio02.vhdl @@ -0,0 +1,30 @@ +entity tb_prio02 is +end tb_prio02; + +library ieee; +use ieee.std_logic_1164.all; + +architecture behav of tb_prio02 is + signal d : std_logic_vector(15 downto 0); + signal p : natural; +begin + dut: entity work.prio02 + port map (d, p); + + process + begin + d <= x"0004"; + wait for 1 ns; + assert p = 2 severity failure; + + d <= x"8000"; + wait for 1 ns; + assert p = 15 severity failure; + + d <= x"0024"; + wait for 1 ns; + assert p = 5 severity failure; + + wait; + end process; +end behav; diff --git a/testsuite/synth/int01/testsuite.sh b/testsuite/synth/int01/testsuite.sh index a590cde72..ac3fc413e 100755 --- a/testsuite/synth/int01/testsuite.sh +++ b/testsuite/synth/int01/testsuite.sh @@ -2,10 +2,9 @@ . ../../testenv.sh -for t in int_operators; do - synth $t.vhdl -e $t > syn_$t.vhdl - analyze syn_$t.vhdl - clean -done +synth_analyze int_operators +clean + +synth_tb prio02 echo "Test successful" -- cgit v1.2.3