aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/fsm02/tb_recv.vhdl
blob: d6f0bb048a9a19fb2277bd514207b43b1bfcb491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
library ieee;
use ieee.std_logic_1164.all;

entity tb_recv is
end tb_recv;

architecture behav of tb_recv is
    signal clk : std_logic;
    signal rst : std_logic := '1';
    signal tx : std_logic;
    signal data : std_logic_vector (7 downto 0);
    signal valid : std_logic;
    signal err : std_logic;
begin
    dut: entity work.recv
      port map (clk => clk,
        rst => rst,
        rx => tx,
        byte => data,
        b_err => err,
        b_en => valid);
    
    process
        procedure pulse is
        begin
            clk <= '0';
            wait for 1 ns;
            clk <= '1';
            wait for 1 ns;
        end pulse;
        variable txdata : std_logic_vector (7 downto 0);
    begin
        rst <= '1';
        tx <= '1';
        pulse;
        rst <= '0';
        
        --  Transmit 1 byte.
        tx <= '0';
        pulse;
        assert err = '0' and valid = '0' severity error;
        txdata := x"6e";
        for i in txdata'reverse_range loop
            tx <= txdata(i);
            pulse;
            assert err = '0' and valid = '0' severity error;
        end loop;
        tx <= '1';  -- parity
        pulse;
        tx <= '1';  --  stop
        pulse;
        assert valid = '1' severity error;
        assert err = '0' severity error;
        assert data = txdata;
        wait;
    end process;
end behav;