OpenCores
URL https://opencores.org/ocsvn/usb_dongle_fpga/usb_dongle_fpga/trunk

Subversion Repositories usb_dongle_fpga

[/] [usb_dongle_fpga/] [trunk/] [beh/] [lpc_byte_test.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 nuubik
------------------------------------------------------------------
2
-- Universal dongle board source code
3
-- 
4
-- Copyright (C) 2006 Artec Design <jyrit@artecdesign.ee>
5
-- 
6
-- This source code is free hardware; you can redistribute it and/or
7
-- modify it under the terms of the GNU Lesser General Public
8
-- License as published by the Free Software Foundation; either
9
-- version 2.1 of the License, or (at your option) any later version.
10
-- 
11
-- This source code is distributed in the hope that it will be useful,
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
-- Lesser General Public License for more details.
15
-- 
16
-- You should have received a copy of the GNU Lesser General Public
17
-- License along with this library; if not, write to the Free Software
18
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
-- 
20
-- 
21
-- The complete text of the GNU Lesser General Public License can be found in 
22
-- the file 'lesser.txt'.
23
--------------------------------------------------------------------------------
24
-- Company: 
25
-- Engineer:
26
--
27
-- Create Date:   17:35:11 10/09/2006
28
-- Design Name:   lpc_iow
29
-- Module Name:   C:/projects/USB_dongle/beh/lpc_byte_test.vhd
30
-- Project Name:  simulation
31
-- Target Device:  
32
-- Tool versions:  
33
-- Description:   
34
-- 
35
-- VHDL Test Bench Created by ISE for module: lpc_iow
36
--
37
-- Dependencies:
38
-- 
39
-- Revision:
40
-- Revision 0.01 - File Created
41
-- Additional Comments:
42
--
43
-- Notes: 
44
-- This testbench has been automatically generated using types std_logic and
45
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends 
46
-- that these types always be used for the top-level I/O of a design in order 
47
-- to guarantee that the testbench will bind correctly to the post-implementation 
48
-- simulation model.
49
--------------------------------------------------------------------------------
50
LIBRARY ieee;
51
USE ieee.std_logic_1164.ALL;
52
USE ieee.std_logic_unsigned.all;
53
USE ieee.numeric_std.ALL;
54
 
55
ENTITY lpc_byte_test_vhd IS
56
END lpc_byte_test_vhd;
57
 
58
ARCHITECTURE behavior OF lpc_byte_test_vhd IS
59
 
60
        -- Component Declaration for the Unit Under Test (UUT)
61
        COMPONENT lpc_iow
62
        PORT(
63
                lreset_n : IN std_logic;
64
                lclk : IN std_logic;
65
                lad_i : IN std_logic_vector(3 downto 0);
66
                lframe_n : IN std_logic;
67
                lpc_data_i : IN std_logic_vector(7 downto 0);
68
                lpc_ack : IN std_logic;
69
                lad_o : OUT std_logic_vector(3 downto 0);
70
                lad_oe : OUT std_logic;
71
                lpc_addr : OUT std_logic_vector(23 downto 0);
72
                lpc_wr : OUT std_logic;
73
                lpc_data_o : OUT std_logic_vector(7 downto 0);
74
                lpc_val : OUT std_logic
75
                );
76
        END COMPONENT;
77
 
78
        --Inputs
79
        SIGNAL lreset_n :  std_logic := '0';
80
        SIGNAL lclk :  std_logic := '0';
81
        SIGNAL lframe_n :  std_logic := '1';
82
        SIGNAL lpc_ack :  std_logic := '0';
83
        SIGNAL lad_i :  std_logic_vector(3 downto 0) := (others=>'0');
84
        SIGNAL lpc_data_i :  std_logic_vector(7 downto 0) := (others=>'0');
85
 
86
        --Outputs
87
        SIGNAL lad_o :  std_logic_vector(3 downto 0);
88
        SIGNAL lad_oe :  std_logic;
89
        SIGNAL lpc_addr :  std_logic_vector(23 downto 0);
90
        SIGNAL lpc_wr :  std_logic;
91
        SIGNAL lpc_data_o :  std_logic_vector(7 downto 0);
92
        SIGNAL lpc_val :  std_logic;
93
 
94
BEGIN
95
 
96
        -- Instantiate the Unit Under Test (UUT)
97
        uut: lpc_iow PORT MAP(
98
                lreset_n => lreset_n,
99
                lclk => lclk,
100
                lad_i => lad_i,
101
                lad_o => lad_o,
102
                lad_oe => lad_oe,
103
                lframe_n => lframe_n,
104
                lpc_addr => lpc_addr,
105
                lpc_wr => lpc_wr,
106
                lpc_data_i => lpc_data_i,
107
                lpc_data_o => lpc_data_o,
108
                lpc_val => lpc_val,
109
                lpc_ack => lpc_ack
110
        );
111
 
112
 
113
 clocker : process is
114
  begin
115
    wait for 15 ns;
116
    lclk <=not (lclk);
117
  end process clocker;
118
 
119
 
120
 VCI_ACK : process is
121
  begin
122
    wait until lpc_val='1';
123
         wait for 100 ns;
124
         lpc_ack <='1';
125
         wait until lpc_val='0';
126
         lpc_ack <='0';
127
  end process VCI_ACK;
128
 
129
 
130
        tb : PROCESS
131
        BEGIN
132
 
133
                -- Wait 100 ns for global reset to finish
134
                wait for 500 ns;
135
                        lreset_n <='1';
136
                -- Place stimulus here
137
                wait until lclk='0'; --cycle 1
138
                wait until lclk='1';
139
                lad_i <="0000";
140
                lframe_n <='0';
141
                wait until lclk='0'; --cycle 2
142
                wait until lclk='1';
143
                lad_i <="0010";      --LPC IO write
144
                lframe_n <='1';
145
                wait until lclk='0'; --cycle 3
146
                wait until lclk='1';
147
                lad_i <=x"0";                    --address nibble 1
148
                wait until lclk='0'; --cycle 4
149
                wait until lclk='1';
150
                lad_i <=x"0";                    --address nibble 2
151
                wait until lclk='0'; --cycle 5
152
                wait until lclk='1';
153
                lad_i <=x"8";                   --address nibble 3              
154
                wait until lclk='0'; --cycle 6
155
                wait until lclk='1';
156
                lad_i <=x"0";                    --address nibble 4
157
                wait until lclk='0'; --cycle 7
158
                wait until lclk='1';
159
                lad_i <=x"A";                   --data nibble 1                         
160
                wait until lclk='0'; --cycle 8
161
                wait until lclk='1';
162
                lad_i <=x"5";                   --data nibble 2
163
                wait until lclk='0'; --cycle 9
164
                wait until lclk='1';
165
                lad_i <=x"F";                   --TAR   1
166
                wait until lclk='0'; --cycle 10
167
                wait until lclk='1';
168
                if lad_o=x"F" and lad_oe='1' then  --TAR 2
169
                else
170
                        report "LPC error found on TAR cycle no 0xF on lad_o";
171
                        lframe_n <='0';
172
                end if;
173
                wait until lclk='0'; --cycle 11
174
                wait until lclk='1';
175
                if (lad_o=x"0") and lad_oe='1' then --SYNC
176
                else
177
                        report "LPC error found on SYNC cycle no 0x0 on lad_o";
178
                        lframe_n <='0';
179
                end if;
180
                wait until lclk='0'; --cycle 12
181
                wait until lclk='1';
182
                if (lad_o=x"F") and lad_oe='1' then --TARL 1
183
                else
184
                        report "LPC error found on TAR_L cycle no 0xF on lad_o";
185
                        lframe_n <='0';
186
                end if;
187
                wait until lclk='0'; --cycle 13
188
                wait until lclk='1';
189
                lad_i <=x"F";                   --TARL 2        
190
                lframe_n <='1';
191
                wait; -- will wait forever
192
        END PROCESS;
193
 
194
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.