1 -----------------------------------------------------------------------
2 -- Copyright (c) 2009 Malte S. Stretz <http://msquadrat.de>
4 -- Testing the parity generator.
5 -----------------------------------------------------------------------
6 -- This entity is part of the following library:
7 -- pragma library fhw_rs232_t
10 use fhw_rs232.rs232_globals_p.all;
13 use ieee.std_logic_1164.all;
14 use ieee.numeric_std.all;
17 use stefanvhdl.txt_util.all;
19 -----------------------------------------------------------------------
21 entity rs232_globals_parity_t is
22 end rs232_globals_parity_t;
24 architecture test of rs232_globals_parity_t is
25 -- The first parameter is the `word` to calculate the parities (both
26 -- even and odd) of, the second is the `expect`ed value for even parity.
28 word : in std_logic_vector;
29 expect : in std_logic) is
30 variable e_p_v, e_e_v : std_logic;
31 variable o_p_v, o_e_v : std_logic;
33 e_e_v := expect; o_e_v := not expect;
34 o_p_v := get_parity(word, '0'); assert o_p_v = o_e_v report "wrong O parity for " & str(word) & ": " & str(o_p_v) & " != " & str(o_e_v);
35 e_p_v := get_parity(word, '1'); assert e_p_v = e_e_v report "wrong E parity for " & str(word) & ": " & str(e_p_v) & " != " & str(e_e_v);
38 -- We'll test the parity for 1, 2, 3 and 4 bit words. That includes
39 -- the shortest possible word lengths with even and odd number of
40 -- digits and the next two lengths. Everything else doesn't make a