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

Subversion Repositories apbi2c

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

Go to most recent revision | 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
        inout SDA,
95
        inout SCL
96
 
97
          );
98
 
99
        wire RESET_N;
100
 
101
        //THIS IS USED TO RESET FIFO
102
        assign RESET_N = (PRESETn == 0)?1'b1:1'b0;
103
 
104
        //WIRES USED TO CONECT BLOCK WITH EACH OTHER
105
        wire TX_RD_EN;
106
        wire TX_F_EMPTY;
107
        wire TX_F_FULL;
108
        wire [31:0] TX_DATA_IN;
109
        wire [31:0] TX_DATA_OUT;
110
        wire TX_WRITE_ENA;
111
 
112
        wire RX_RD_EN;
113
        wire RX_F_EMPTY;
114
        wire RX_F_FULL;
115
        wire [31:0] RX_DATA_IN;
116
        wire [31:0] RX_DATA_OUT;
117
        wire RX_WRITE_ENA;
118
 
119
 
120
        wire [13:0] REGISTER_CONFIG;
121
 
122
 
123
        wire error;
124
        wire tx_empty;
125
        wire rx_empty;
126
 
127 18 redbear
        //wire w_pwrite;
128 14 redbear
        wire w_full;
129 18 redbear
        //wire w_full_tx;
130 14 redbear
 
131 18 redbear
        //assign w_pwrite = (PWRITE == 1'b0)?1'b1:1'b0;
132 14 redbear
 
133
 
134
 
135 2 redbear
        //CONECTIONS WITH FIFO TX
136
        fifo DUT_FIFO_TX (
137
                                .clock(PCLK),
138
                                .reset(RESET_N),
139
                                .wr_en(TX_WRITE_ENA),
140
                                .rd_en(TX_RD_EN),
141
                                .data_in(TX_DATA_IN),
142 14 redbear
                                .f_full(w_full),
143 2 redbear
                                .f_empty(TX_F_EMPTY),
144
                                .data_out(TX_DATA_OUT)
145
                         );
146
 
147 14 redbear
 
148 18 redbear
        //and(w_full_tx,w_pwrite,w_full);
149 14 redbear
 
150 18 redbear
        assign TX_F_FULL = w_full;
151 14 redbear
 
152 2 redbear
        //CONECTIONS WITH FIFO RX
153
        fifo DUT_FIFO_RX (
154
                                .clock(PCLK),
155
                                .reset(RESET_N),
156
                                .wr_en(RX_WRITE_ENA),
157
                                .rd_en(RX_RD_EN),
158
                                .data_in(RX_DATA_IN),
159
                                .f_full(RX_F_FULL),
160
                                .f_empty(RX_F_EMPTY),
161
                                .data_out(RX_DATA_OUT)
162
                         );
163
 
164
        //CONECTIONS WITH APB AND ALL BLOCKS WHERE IS TWO FIFOS AND I2C CORE
165
        apb DUT_APB (
166
 
167
                        .PCLK(PCLK),
168
                        .PRESETn(PRESETn),
169
                        .PADDR(PADDR),
170
                        .PRDATA(PRDATA),
171
                        .PWDATA(PWDATA),
172
                        .PWRITE(PWRITE),
173
                        .PSELx(PSELx),
174
                        .PENABLE(PENABLE),
175
                        .PREADY(PREADY),
176
                        .PSLVERR(PSLVERR),
177
                        .READ_DATA_ON_RX(RX_DATA_OUT),
178
                        .INTERNAL_I2C_REGISTER_CONFIG(REGISTER_CONFIG),
179
                        .INT_RX(INT_RX),
180
                        .WR_ENA(TX_WRITE_ENA),
181
                        .WRITE_DATA_ON_TX(TX_DATA_IN),
182
                        .RD_ENA(RX_RD_EN),
183
                        .INT_TX(INT_TX),
184
                        .TX_EMPTY(tx_empty),
185
                        .RX_EMPTY(rx_empty),
186
                        .ERROR(error)
187
 
188
                     );
189
 
190
        //I2C CORE BLOCK WITH ALL ANOTHER BLOCKS
191
        module_i2c DUT_I2C_INTERNAL (
192
                                        .PCLK(PCLK),
193
                                        .PRESETn(PRESETn),
194
                                        .fifo_tx_rd_en(TX_RD_EN),
195
                                        .fifo_tx_f_full(TX_F_FULL),
196
                                        .fifo_tx_f_empty(TX_F_EMPTY),
197
                                        .fifo_tx_data_out(TX_DATA_OUT),
198
                                        .fifo_rx_wr_en(RX_WRITE_ENA),
199
                                        .fifo_rx_f_empty(RX_F_EMPTY),
200
                                        .fifo_rx_data_in(RX_DATA_IN),
201
                                        .fifo_rx_f_full(RX_F_FULL),
202
                                        .DATA_CONFIG_REG(REGISTER_CONFIG),
203
                                        .TX_EMPTY(tx_empty),
204
                                        .RX_EMPTY(rx_empty),
205
                                        .ERROR(error),
206
                                        .SDA(SDA),
207
                                        .SCL(SCL)
208
                                    );
209
endmodule

powered by: WebSVN 2.1.0

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