]> rtime.felk.cvut.cz Git - fpga/uart.git/blob - tb/tb_baud_gen.vhd
First prototype of receiver shift register.
[fpga/uart.git] / tb / tb_baud_gen.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
5
6 entity tb_baud_gen is
7 end tb_baud_gen;
8
9
10 architecture testbench of tb_baud_gen is
11
12   component baud_gen is
13     port (
14       clk      : in  std_logic;
15       reset    : in  std_logic;
16       scale    : in  std_logic_vector (15 downto 0);
17       clk_baud : out std_logic
18     );
19   end component;
20   
21   signal clk   : std_logic;
22   signal reset : std_logic;
23   
24   constant period : time := 2 us;
25   constant offset : time := 2 us;
26   
27   signal scale    : std_logic_vector (15 downto 0);
28   signal clk_baud : std_logic;
29
30 --------------------------------------------------------------------------------
31   
32 begin
33   UUT : baud_gen port map (
34     clk      => clk,
35     reset    => reset,
36     scale    => scale,
37     clk_baud => clk_baud
38   );
39
40   process
41   begin
42     clk <= '0';
43     wait for offset;
44     
45     loop
46       clk <= '1';
47       wait for period/2;
48       clk <= '0';
49       wait for period/2;
50     end loop;
51   end process;
52
53
54   process
55   begin
56     reset <= '0';
57     wait for 1.2 * period;
58     reset <= '1';
59     wait for 3 * period;
60     reset <= '0';
61     wait;
62   end process;
63
64
65   process
66   begin
67     scale <= X"0000";
68   
69     wait until reset = '0' and clk = '1';
70     wait for 0.1 * period;
71     
72     wait;
73   end process;
74   
75 end testbench;
76