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 20

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 20 nuubik
      lena_mem_r : in  std_logic;  --enable lpc regular memory read cycles also (default is only LPC firmware read)
66
           lena_reads : in  std_logic;  --enable read capabilities      
67 2 nuubik
                lad_i : IN std_logic_vector(3 downto 0);
68
                lframe_n : IN std_logic;
69
                lpc_data_i : IN std_logic_vector(7 downto 0);
70
                lpc_ack : IN std_logic;
71
                lad_o : OUT std_logic_vector(3 downto 0);
72
                lad_oe : OUT std_logic;
73
                lpc_addr : OUT std_logic_vector(23 downto 0);
74
                lpc_wr : OUT std_logic;
75
                lpc_data_o : OUT std_logic_vector(7 downto 0);
76
                lpc_val : OUT std_logic
77
                );
78
        END COMPONENT;
79
 
80
        --Inputs
81
        SIGNAL lreset_n :  std_logic := '0';
82
        SIGNAL lclk :  std_logic := '0';
83 20 nuubik
 
84
   SIGNAL   lena_mem_r : std_logic:='1';  --enable lpc regular memory read cycles also (default is only LPC firmware read)
85
        SIGNAL   lena_reads : std_logic:='1';  --enable read capabilities      
86
 
87 2 nuubik
        SIGNAL lframe_n :  std_logic := '1';
88
        SIGNAL lpc_ack :  std_logic := '0';
89
        SIGNAL lad_i :  std_logic_vector(3 downto 0) := (others=>'0');
90
        SIGNAL lpc_data_i :  std_logic_vector(7 downto 0) := (others=>'0');
91
 
92
        --Outputs
93
        SIGNAL lad_o :  std_logic_vector(3 downto 0);
94
        SIGNAL lad_oe :  std_logic;
95
        SIGNAL lpc_addr :  std_logic_vector(23 downto 0);
96
        SIGNAL lpc_wr :  std_logic;
97
        SIGNAL lpc_data_o :  std_logic_vector(7 downto 0);
98
        SIGNAL lpc_val :  std_logic;
99
 
100
BEGIN
101
 
102
        -- Instantiate the Unit Under Test (UUT)
103
        uut: lpc_iow PORT MAP(
104
                lreset_n => lreset_n,
105
                lclk => lclk,
106 20 nuubik
      lena_mem_r=> lena_mem_r,
107
      lena_reads => lena_reads,
108 2 nuubik
                lad_i => lad_i,
109
                lad_o => lad_o,
110
                lad_oe => lad_oe,
111
                lframe_n => lframe_n,
112
                lpc_addr => lpc_addr,
113
                lpc_wr => lpc_wr,
114
                lpc_data_i => lpc_data_i,
115
                lpc_data_o => lpc_data_o,
116
                lpc_val => lpc_val,
117
                lpc_ack => lpc_ack
118
        );
119
 
120
 
121
 clocker : process is
122
  begin
123
    wait for 15 ns;
124
    lclk <=not (lclk);
125
  end process clocker;
126
 
127
 
128
 VCI_ACK : process is
129
  begin
130
    wait until lpc_val='1';
131
         wait for 100 ns;
132
         lpc_ack <='1';
133
         wait until lpc_val='0';
134
         lpc_ack <='0';
135
  end process VCI_ACK;
136
 
137
 
138
        tb : PROCESS
139
        BEGIN
140
 
141
                -- Wait 100 ns for global reset to finish
142
                wait for 500 ns;
143
                        lreset_n <='1';
144
                -- Place stimulus here
145
                wait until lclk='0'; --cycle 1
146
                wait until lclk='1';
147
                lad_i <="0000";
148
                lframe_n <='0';
149
                wait until lclk='0'; --cycle 2
150
                wait until lclk='1';
151
                lad_i <="0010";      --LPC IO write
152
                lframe_n <='1';
153
                wait until lclk='0'; --cycle 3
154
                wait until lclk='1';
155
                lad_i <=x"0";                    --address nibble 1
156
                wait until lclk='0'; --cycle 4
157
                wait until lclk='1';
158
                lad_i <=x"0";                    --address nibble 2
159
                wait until lclk='0'; --cycle 5
160
                wait until lclk='1';
161
                lad_i <=x"8";                   --address nibble 3              
162
                wait until lclk='0'; --cycle 6
163
                wait until lclk='1';
164
                lad_i <=x"0";                    --address nibble 4
165
                wait until lclk='0'; --cycle 7
166
                wait until lclk='1';
167
                lad_i <=x"A";                   --data nibble 1                         
168
                wait until lclk='0'; --cycle 8
169
                wait until lclk='1';
170
                lad_i <=x"5";                   --data nibble 2
171
                wait until lclk='0'; --cycle 9
172
                wait until lclk='1';
173
                lad_i <=x"F";                   --TAR   1
174
                wait until lclk='0'; --cycle 10
175
                wait until lclk='1';
176 20 nuubik
                if lad_oe='0' then  --TAR 2
177 2 nuubik
                else
178
                        report "LPC error found on TAR cycle no 0xF on lad_o";
179
                        lframe_n <='0';
180
                end if;
181
                wait until lclk='0'; --cycle 11
182 20 nuubik
                wait until lclk='1';
183
      wait until lad_o=x"6";
184
      while(lad_o=x"6") loop
185
         wait until lclk='0'; --cycle 11
186
         wait until lclk='1';
187
      end loop;
188 2 nuubik
                if (lad_o=x"0") and lad_oe='1' then --SYNC
189
                else
190
                        report "LPC error found on SYNC cycle no 0x0 on lad_o";
191
                        lframe_n <='0';
192
                end if;
193
                wait until lclk='0'; --cycle 12
194
                wait until lclk='1';
195
                if (lad_o=x"F") and lad_oe='1' then --TARL 1
196
                else
197
                        report "LPC error found on TAR_L cycle no 0xF on lad_o";
198
                        lframe_n <='0';
199
                end if;
200
                wait until lclk='0'; --cycle 13
201
                wait until lclk='1';
202
                lad_i <=x"F";                   --TARL 2        
203
                lframe_n <='1';
204
                wait; -- will wait forever
205
        END PROCESS;
206
 
207
END;

powered by: WebSVN 2.1.0

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