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

Subversion Repositories lpc

[/] [lpc/] [trunk/] [gpio/] [rtl/] [lpc_gpio_top.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 junbing
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  LPC(Low Pin Count) GPIO(General Purpose Input Output)      ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Junbing Liang                                      ////
7
////          Junbing.Liang@googlemail.com                       ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/                 ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2007 Junbing Liang                            ////
15
////                                                             ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
module  lpc_gpio_top;
39
 
40
 
41
reg    [3:0]   LAD;
42
reg            LFRAME;
43
reg            LRESET;
44
reg            LCLK;
45
 
46
wire   [7:0]   gpio_out;
47
 
48
wire    [3:0]   LAD_w;
49
 
50
 
51
//LCLK
52
initial
53
begin
54
       LCLK=1;
55
end
56
 
57
//LRESET
58
initial
59
begin
60
 
61
 
62
//write date to gpio    
63
       LRESET = 0;
64
#50   LRESET = 1;
65
#10    LFRAME = 0;
66
       LAD = 4'b0000;   //1-start
67
#10    LFRAME = 1;
68
       LAD = 4'b0010;   //2- CT-DIR, 0010- IO WRITE
69
#10    LFRAME = 1;
70
       LAD = 4'b0000;   //3- address A15-A12
71
#10    LFRAME = 1;
72
       LAD = 4'b0100;   //4- A11-A8
73
#10    LFRAME = 1;
74
       LAD = 4'b0010;   //5- A7-A4
75
#10    LFRAME = 1;
76
       LAD = 4'b0001;   //6- A3-A0
77
#10    LFRAME = 1;
78
       LAD = 4'b0101;   //7- D3-D0
79
#10    LFRAME = 1;
80
       LAD = 4'b1010;   //8- D7-D4
81
#10    LFRAME = 1;
82
       LAD = 4'b1111;   //9- TAR
83
#10    LFRAME = 1;
84
       LAD = 4'bzzzz;   //10- TAR       
85
#10    LFRAME = 1;
86
       LAD = 4'bzzzz;   //11- SYNC
87
#10    LFRAME = 1;
88
       LAD = 4'bzzzz;   //12- TAR
89
#10    LFRAME = 1;
90
       LAD = 4'bzzzz;   //13- TAR
91
#50   LFRAME = 1;
92
       LAD = 4'bzzzz;   //13- TAR
93
 
94
 
95
#20    LFRAME = 0;
96
       LAD = 4'b0000;   //start
97
#10    LFRAME = 1;
98
       LAD = 4'b0010;   //CT-DIR, 0010- IO WRITE
99
#10    LFRAME = 1;
100
       LAD = 4'b0000;   //address A15-A12
101
#10    LFRAME = 1;
102
       LAD = 4'b0100;   //A11-A8
103
#10    LFRAME = 1;
104
       LAD = 4'b0010;   //A7-A4
105
#10    LFRAME = 1;
106
       LAD = 4'b0101;   //A3-A0
107
#10    LFRAME = 1;
108
       LAD = 4'b1011;   //D3-D0
109
#10    LFRAME = 1;
110
       LAD = 4'b0010;   //D7-D4
111
#10    LFRAME = 1;
112
       LAD = 4'b1111;   //TAR
113
#10    LFRAME = 1;
114
       LAD = 4'bzzzz;   //TAR
115
#50    LFRAME = 1;
116
       LAD = 4'bzzzz;   //SYNC
117
 
118
 
119
//read data from LPC GPIO       
120
 
121
       LRESET = 0;
122
#50   LRESET = 1;
123
#10    LFRAME = 0;
124
       LAD = 4'b0000;   //1-start
125
#10    LFRAME = 1;
126
       LAD = 4'b0000;   //2- CT-DIR, 0000- IO READ
127
#10    LFRAME = 1;
128
       LAD = 4'b0000;   //3- address A15-A12
129
#10    LFRAME = 1;
130
       LAD = 4'b0100;   //4- A11-A8
131
#10    LFRAME = 1;
132
       LAD = 4'b0010;   //5- A7-A4
133
#10    LFRAME = 1;
134
       LAD = 4'b0001;   //6- A3-A0
135
#10    LFRAME = 1;
136
       LAD = 4'b1111;   //7- TAR
137
#10    LFRAME = 1;
138
       LAD = 4'bzzzz;   //8- TAR       
139
#10    LFRAME = 1;
140
       LAD = 4'bzzzz;   //9- SYNC
141
#10    LFRAME = 1;
142
       LAD = 4'bzzzz;   //10 D3-D0
143
#10    LFRAME = 1;
144
       LAD = 4'bzzzz;   //11 D7-D4       
145
#10    LFRAME = 1;
146
       LAD = 4'bzzzz;   //12- TAR
147
#100   LFRAME = 1;
148
       LAD = 4'bzzzz;   //13- TAR       
149
 
150
 
151
 
152
end
153
 
154
//LFRAME, LAD
155
initial
156
begin
157
    LFRAME = 0;
158
    LAD = 0;
159
end
160
 
161
//LCLK
162
always
163
begin
164
        #5 LCLK = !LCLK;
165
end
166
 
167
//hookup the gpip module
168
lpc_gpio gpio1(
169
   .LAD(LAD_w),
170
   .LFRAME(LFRAME),
171
   .LRESET(LRESET),
172
   .LCLK(LCLK),
173
   .gpio_addr_i(16'h0421),
174
   .gpio_i(8'ha5),
175
   .gpio_o(gpio_out)
176
   );
177
 
178
assign LAD_w = LAD;
179
 
180
 
181
 
182
 
183
endmodule

powered by: WebSVN 2.1.0

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