diff options
author | Brian Padalino <bpadalino@gmail.com> | 2021-09-23 01:44:59 -0400 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-09-24 07:29:46 +0200 |
commit | dfd094273e636fb275a7416a1c470d0b136e9362 (patch) | |
tree | c3381b2f291dd0edb6da5f2b77c049b265257241 /testsuite/gna | |
parent | a076bcb8121ea03b626447f5dace625415697600 (diff) | |
download | ghdl-dfd094273e636fb275a7416a1c470d0b136e9362.tar.gz ghdl-dfd094273e636fb275a7416a1c470d0b136e9362.tar.bz2 ghdl-dfd094273e636fb275a7416a1c470d0b136e9362.zip |
Add parsing of case? statement and simple test.
Also add the Matching flag to the Iir_Kind_Case_Statement.
Diffstat (limited to 'testsuite/gna')
-rw-r--r-- | testsuite/gna/issue717/matching_case.vhdl | 57 | ||||
-rwxr-xr-x | testsuite/gna/issue717/testsuite.sh | 11 |
2 files changed, 68 insertions, 0 deletions
diff --git a/testsuite/gna/issue717/matching_case.vhdl b/testsuite/gna/issue717/matching_case.vhdl new file mode 100644 index 000000000..80e059528 --- /dev/null +++ b/testsuite/gna/issue717/matching_case.vhdl @@ -0,0 +1,57 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity CounterWithReset is + generic (gWidth : natural := 16); + port( + iClk : in std_ulogic; + inRstAsync : in std_ulogic; + iCtrl : in std_ulogic_vector (2 downto 0); + oData : out unsigned(gWidth-1 downto 0) + ); +end entity CounterWithReset; + +architecture RTL of CounterWithReset is + signal CountStateM, CountStateNextM : unsigned(oData'RANGE); + signal CountState, CountStateNext : unsigned(oData'RANGE); + signal Ctrl : std_ulogic_vector(iCtrl'RANGE); + signal a, b : std_ulogic ; +begin + count : process (iClk, inRstAsync) is + begin + if inRstAsync = '0' then + CountState <= (others=>'0'); + Ctrl <= (others => '0'); + elsif rising_edge(iClk) then + CountState <= CountStateNext; + Ctrl <= iCtrl; + end if; + end process; + + counter : process(Ctrl, CountState) is + begin + CountStateNext <= CountState; + --our counter has 3 control bits + --the first(left) bit is enable + --the other two bits control the mode + case ?(ctrl) is + when "0--" => --enable bit is not set. we don't count + when "100" => CountStateNextM <= CountStateM + 1; --count up + when "101" => CountStateNextM <= CountStateM + 2; --count up 2 + when "110" => CountStateNextM <= CountStateM - 1; --count down + when "111" => CountStateNextM <= CountStateM - 2; --count down 2 + when others => CountStateNextM <= (others=>'X'); + end case?; + case ctrl is + when "0--" => --enable bit is not set. we don't count + when "100" => CountStateNext <= CountState + 1; --count up + when "101" => CountStateNext <= CountState + 2; --count up 2 + when "110" => CountStateNext <= CountState - 1; --count down + when "111" => CountStateNext <= CountState - 2; --count down 2 + when others => CountStateNext <= (others=>'X'); + end case; + end process; + + oData <= CountState; +end architecture RTL; diff --git a/testsuite/gna/issue717/testsuite.sh b/testsuite/gna/issue717/testsuite.sh new file mode 100755 index 000000000..c3bac1dd8 --- /dev/null +++ b/testsuite/gna/issue717/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 + +analyze matching_case.vhdl + +clean + +echo "Test successful" |