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

Subversion Repositories apbi2c

[/] [apbi2c/] [trunk/] [rtl/] [i2c.v] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 redbear
//////////////////////////////////////////////////////////////////
2
////
3
////
4
////    TOP I2C BLOCK to I2C Core
5
////
6
////
7
////
8
//// This file is part of the APB to I2C project
9
////
10
//// http://www.opencores.org/cores/apbi2c/
11
////
12
////
13
////
14
//// Description
15
////
16
//// Implementation of APB IP core according to
17
////
18
//// apbi2c_spec IP core specification document.
19
////
20
////
21
////
22
//// To Do: Things are right here but always all block can suffer changes
23
////
24
////
25
////
26
////
27
////
28
//// Author(s): - Felipe Fernandes Da Costa, fefe2560@gmail.com
29
////              Ronal Dario Celaya
30
////
31
///////////////////////////////////////////////////////////////// 
32
////
33
////
34
//// Copyright (C) 2009 Authors and OPENCORES.ORG
35
////
36
////
37
////
38
//// This source file may be used and distributed without
39
////
40
//// restriction provided that this copyright statement is not
41
////
42
//// removed from the file and that any derivative work contains
43
//// the original copyright notice and the associated disclaimer.
44
////
45
////
46
//// This source file is free software; you can redistribute it
47
////
48
//// and/or modify it under the terms of the GNU Lesser General
49
////
50
//// Public License as published by the Free Software Foundation;
51
//// either version 2.1 of the License, or (at your option) any
52
////
53
//// later version.
54
////
55
////
56
////
57
//// This source is distributed in the hope that it will be
58
////
59
//// useful, but WITHOUT ANY WARRANTY; without even the implied
60
////
61
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
62
////
63
//// PURPOSE. See the GNU Lesser General Public License for more
64
//// details.
65
////
66
////
67
////
68
//// You should have received a copy of the GNU Lesser General
69
////
70
//// Public License along with this source; if not, download it
71
////
72
//// from http://www.opencores.org/lgpl.shtml
73
////
74
////
75
///////////////////////////////////////////////////////////////////
76
 
77
`timescale 1ns/1ps //timescale 
78
 
79
module i2c(
80
        //APB PORTS
81
        input PCLK,
82
        input PRESETn,
83
        input [31:0] PADDR,
84
        input [31:0] PWDATA,
85
        input PWRITE,
86
        input PSELx,
87
        input PENABLE,
88
        output PREADY,
89
        output PSLVERR,
90
        output INT_RX,
91
        output INT_TX,
92
        output [31:0] PRDATA,
93
        //I2C OUTPUT
94 20 redbear
        output SDA_ENABLE,
95
        output SCL_ENABLE,
96 2 redbear
        inout SDA,
97
        inout SCL
98
 
99
          );
100
 
101
        wire RESET_N;
102
 
103
        //THIS IS USED TO RESET FIFO
104
        assign RESET_N = (PRESETn == 0)?1'b1:1'b0;
105
 
106
        //WIRES USED TO CONECT BLOCK WITH EACH OTHER
107
        wire TX_RD_EN;
108
        wire TX_F_EMPTY;
109
        wire TX_F_FULL;
110
        wire [31:0] TX_DATA_IN;
111
        wire [31:0] TX_DATA_OUT;
112
        wire TX_WRITE_ENA;
113
 
114
        wire RX_RD_EN;
115
        wire RX_F_EMPTY;
116
        wire RX_F_FULL;
117
        wire [31:0] RX_DATA_IN;
118
        wire [31:0] RX_DATA_OUT;
119
        wire RX_WRITE_ENA;
120
 
121
 
122
        wire [13:0] REGISTER_CONFIG;
123 20 redbear
        wire [13:0] TIMEOUT_CONFIG;
124 2 redbear
 
125
 
126
        wire error;
127 20 redbear
 
128
 
129 2 redbear
        wire tx_empty;
130
        wire rx_empty;
131
 
132 18 redbear
        //wire w_pwrite;
133 14 redbear
        wire w_full;
134 18 redbear
        //wire w_full_tx;
135 14 redbear
 
136 18 redbear
        //assign w_pwrite = (PWRITE == 1'b0)?1'b1:1'b0;
137 14 redbear
 
138
 
139
 
140 2 redbear
        //CONECTIONS WITH FIFO TX
141
        fifo DUT_FIFO_TX (
142
                                .clock(PCLK),
143
                                .reset(RESET_N),
144
                                .wr_en(TX_WRITE_ENA),
145
                                .rd_en(TX_RD_EN),
146
                                .data_in(TX_DATA_IN),
147 14 redbear
                                .f_full(w_full),
148 2 redbear
                                .f_empty(TX_F_EMPTY),
149
                                .data_out(TX_DATA_OUT)
150
                         );
151
 
152 14 redbear
 
153 18 redbear
        //and(w_full_tx,w_pwrite,w_full);
154 14 redbear
 
155 18 redbear
        assign TX_F_FULL = w_full;
156 14 redbear
 
157 2 redbear
        //CONECTIONS WITH FIFO RX
158
        fifo DUT_FIFO_RX (
159
                                .clock(PCLK),
160
                                .reset(RESET_N),
161
                                .wr_en(RX_WRITE_ENA),
162
                                .rd_en(RX_RD_EN),
163
                                .data_in(RX_DATA_IN),
164
                                .f_full(RX_F_FULL),
165
                                .f_empty(RX_F_EMPTY),
166
                                .data_out(RX_DATA_OUT)
167
                         );
168
 
169
        //CONECTIONS WITH APB AND ALL BLOCKS WHERE IS TWO FIFOS AND I2C CORE
170
        apb DUT_APB (
171
 
172
                        .PCLK(PCLK),
173
                        .PRESETn(PRESETn),
174
                        .PADDR(PADDR),
175
                        .PRDATA(PRDATA),
176
                        .PWDATA(PWDATA),
177
                        .PWRITE(PWRITE),
178
                        .PSELx(PSELx),
179
                        .PENABLE(PENABLE),
180
                        .PREADY(PREADY),
181
                        .PSLVERR(PSLVERR),
182
                        .READ_DATA_ON_RX(RX_DATA_OUT),
183
                        .INTERNAL_I2C_REGISTER_CONFIG(REGISTER_CONFIG),
184 20 redbear
                        .INTERNAL_I2C_REGISTER_TIMEOUT(TIMEOUT_CONFIG),
185 2 redbear
                        .INT_RX(INT_RX),
186
                        .WR_ENA(TX_WRITE_ENA),
187
                        .WRITE_DATA_ON_TX(TX_DATA_IN),
188
                        .RD_ENA(RX_RD_EN),
189
                        .INT_TX(INT_TX),
190
                        .TX_EMPTY(tx_empty),
191
                        .RX_EMPTY(rx_empty),
192
                        .ERROR(error)
193
 
194
                     );
195
 
196
        //I2C CORE BLOCK WITH ALL ANOTHER BLOCKS
197 20 redbear
        module_i2c DUT_I2C_INTERNAL_RX_TX (
198 2 redbear
                                        .PCLK(PCLK),
199
                                        .PRESETn(PRESETn),
200
                                        .fifo_rx_wr_en(RX_WRITE_ENA),
201
                                        .fifo_rx_f_empty(RX_F_EMPTY),
202
                                        .fifo_rx_data_in(RX_DATA_IN),
203
                                        .fifo_rx_f_full(RX_F_FULL),
204 20 redbear
                                        .fifo_tx_f_full(TX_F_FULL),
205
                                        .fifo_tx_f_empty(TX_F_EMPTY),
206
                                        .fifo_tx_rd_en(TX_RD_EN),
207
                                        .fifo_tx_data_out(TX_DATA_OUT),
208 2 redbear
                                        .DATA_CONFIG_REG(REGISTER_CONFIG),
209 20 redbear
                                        .TIMEOUT_TX(TIMEOUT_CONFIG),
210 2 redbear
                                        .RX_EMPTY(rx_empty),
211 20 redbear
                                        .TX_EMPTY(tx_empty),
212 2 redbear
                                        .ERROR(error),
213 20 redbear
                                        .ENABLE_SDA(SDA_ENABLE),
214
                                        .ENABLE_SCL(SCL_ENABLE),
215 2 redbear
                                        .SDA(SDA),
216
                                        .SCL(SCL)
217
                                    );
218 20 redbear
 
219 2 redbear
endmodule

powered by: WebSVN 2.1.0

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