source: firmware/FTU/test_firmware/FTU_test6_new/FTU_test6_new_tb.vhd

Last change on this file was 10057, checked in by weitzel, 14 years ago
v3 of FTU docu and new version of FTU_test6 added
File size: 4.9 KB
Line 
1--------------------------------------------------------------------------------
2-- Company: ETH Zurich, Institute for Particle Physics
3-- Engineer: Q. Weitzel, P. Vogler
4--
5-- Create Date: 19.11.2010
6-- Design Name:
7-- Module Name: FTU_test6_new_tb.vhd
8-- Project Name:
9-- Target Device:
10-- Tool versions:
11-- Description: Testbench for FTU RS485 test
12--
13-- VHDL Test Bench Created by ISE for module: FTU_test6_new
14--
15-- Dependencies:
16--
17-- Revision:
18-- Revision 0.01 - File Created
19-- Additional Comments:
20--
21-- Notes:
22-- This testbench has been automatically generated using types std_logic and
23-- std_logic_vector for the ports of the unit under test. Xilinx recommends
24-- that these types always be used for the top-level I/O of a design in order
25-- to guarantee that the testbench will bind correctly to the post-implementation
26-- simulation model.
27--------------------------------------------------------------------------------
28library IEEE;
29use IEEE.STD_LOGIC_1164.ALL;
30use IEEE.STD_LOGIC_UNSIGNED.ALL;
31use IEEE.NUMERIC_STD.ALL;
32
33library UNISIM;
34use UNISIM.VComponents.all;
35
36entity FTU_test6_new_tb is
37end FTU_test6_new_tb;
38
39architecture behavior of FTU_test6_new_tb is
40
41 -- Component Declaration for the Unit Under Test (UUT)
42
43 component FTU_test6_new
44 port(
45 ext_clk : IN STD_LOGIC;
46 rx : IN STD_LOGIC;
47 tx : OUT STD_LOGIC;
48 rx_en : OUT STD_LOGIC;
49 tx_en : OUT STD_LOGIC;
50 enables_A : OUT STD_LOGIC_VECTOR(8 downto 0);
51 enables_B : OUT STD_LOGIC_VECTOR(8 downto 0);
52 enables_C : OUT STD_LOGIC_VECTOR(8 downto 0);
53 enables_D : OUT STD_LOGIC_VECTOR(8 downto 0)
54 );
55 end component;
56
57 --Inputs
58 signal clk : STD_LOGIC := '0';
59 signal rx : STD_LOGIC := '1';
60
61 --Outputs
62 signal enables_A : STD_LOGIC_VECTOR(8 downto 0);
63 signal enables_B : STD_LOGIC_VECTOR(8 downto 0);
64 signal enables_C : STD_LOGIC_VECTOR(8 downto 0);
65 signal enables_D : STD_LOGIC_VECTOR(8 downto 0);
66 signal tx : STD_LOGIC;
67 signal rx_en : STD_LOGIC;
68 signal tx_en : STD_LOGIC;
69
70 -- Clock period definitions
71 constant clk_period : TIME := 20 ns;
72 constant baud_rate_period : TIME := 4 us;
73
74begin
75
76 -- Instantiate the Unit Under Test (UUT)
77 uut: FTU_test6_new
78 port map(
79 ext_clk => clk,
80 rx => rx,
81 tx => tx,
82 rx_en => rx_en,
83 tx_en => tx_en,
84 enables_A => enables_A,
85 enables_B => enables_B,
86 enables_C => enables_C,
87 enables_D => enables_D
88 );
89
90 -- Stimulus process for clock
91 clk_proc: process
92 begin
93 clk <= '0';
94 wait for clk_period/2;
95 clk <= '1';
96 wait for clk_period/2;
97 end process clk_proc;
98
99 -- Stimulus process for RS485
100 rs485_proc: process
101
102 procedure assign_rs485 (data: std_logic_vector(7 downto 0)) is
103 begin
104 rx <= '0'; --start bit
105 wait for baud_rate_period;
106 rx <= data(0); --bit 0
107 wait for baud_rate_period;
108 rx <= data(1); --bit 1
109 wait for baud_rate_period;
110 rx <= data(2); --bit 2
111 wait for baud_rate_period;
112 rx <= data(3); --bit 3
113 wait for baud_rate_period;
114 rx <= data(4); --bit 4
115 wait for baud_rate_period;
116 rx <= data(5); --bit 5
117 wait for baud_rate_period;
118 rx <= data(6); --bit 6
119 wait for baud_rate_period;
120 rx <= data(7); --bit 7
121 wait for baud_rate_period;
122 rx <= '1'; --stop bit
123 wait for baud_rate_period;
124 rx <= '1'; --stop bit
125 wait for baud_rate_period;
126 end assign_rs485;
127
128 begin
129 wait for 1us;
130 ---------------------------------------------------------------------------
131 -- send a '1' character
132 ---------------------------------------------------------------------------
133 assign_rs485("00110001");
134 wait for 1us;
135 ---------------------------------------------------------------------------
136 -- send a '2' character
137 ---------------------------------------------------------------------------
138 assign_rs485("00110010");
139 wait for 1us;
140 ---------------------------------------------------------------------------
141 -- send a '3' character
142 ---------------------------------------------------------------------------
143 assign_rs485("00110011");
144 wait for 1us;
145 ---------------------------------------------------------------------------
146 -- send a '4' character
147 ---------------------------------------------------------------------------
148 assign_rs485("00110100");
149 wait for 1us;
150 ---------------------------------------------------------------------------
151 -- send a '0' character
152 ---------------------------------------------------------------------------
153 assign_rs485("00110000");
154 wait for 1us;
155 ---------------------------------------------------------------------------
156 -- don't forget final wait!
157 ---------------------------------------------------------------------------
158 wait;
159
160 end process rs485_proc;
161
162end;
Note: See TracBrowser for help on using the repository browser.