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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Hardware/] [XUPV5-LX110T_SoC/] [MIPS32-Pipelined-Hw/] [src/] [I2C/] [I2C_Controller.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2
/*
3
 * File         : I2C_Controller.v
4
 * Project      : University of Utah, XUM Project MIPS32 core
5
 * Creator(s)   : Grant Ayers (ayers@cs.utah.edu)
6
 *
7
 * Modification History:
8
 *   Rev   Date         Initials  Description of Change
9
 *   1.0   25-Jun-2012  GEA       Initial design.
10
 *
11
 * Standards/Formatting:
12
 *   Verilog 2001, 4 soft tab, wide column.
13
 *
14
 * Description:
15
 *   A top-level I2C controller which bridges the I2C physical layer with
16
 *   the data memory bus. This controller accepts the following commands:
17
 *
18
 *      Clear   : [Bit 8]  Empties the I2C FIFO of all data.
19
 *      EnQ     : [Bit 9]  Enqueues a byte of data to the FIFO for transmission.
20
 *      Tx      : [Bit 10] Transmits all bytes within the FIFO.
21
 *      Rx      : [Bit 11] Transmits the first byte in the FIFO (bus address),
22
 *                         then receives a requested number of bytes into the FIFO.
23
 *      RxN     : [Bit 12] Sets the number of bytes to receive on an 'Rx' command.
24
 *
25
 *   To read data from the FIFO, the data memory bus issues a Read command. The received
26
 *   data is arranged as follows:
27
 *
28
 *      Bit 10  : 'Nack' which indicates if the last Tx/Rx command did not receive
29
 *                an acknowledgment from the slave device.
30
 *      Bit  9  : Indicates if the FIFO is currently full.
31
 *      Bit  8  : Indicates if the FIFO is currently empty.
32
 *      Bit 7-0 : The first byte in the FIFO.
33
 */
34
module I2C_Controller(
35
    input  clock,
36
    input  reset,
37
    input  Read,
38
    input  Write,
39
    input  [12:0] DataIn,
40
    output [10:0] DataOut,
41
    output Ack,
42
 
43
    inout  i2c_scl,
44
    inout  i2c_sda
45
    );
46
 
47
    // I2C Physical layer signals
48
    wire I2C_Read, I2C_Write;
49
    wire I2C_ReadCountSet;
50
    wire I2C_EnQ, I2C_DeQ, I2C_Clear;
51
    wire [7:0] I2C_DataIn, I2C_DataOut;
52
    wire I2C_Ack, I2C_Nack;
53
    wire I2C_FifoEmpty, I2C_FifoFull;
54
 
55
 
56
    wire Cmd_Clear = DataIn[8];
57
    wire Cmd_EnQ   = DataIn[9];
58
    wire Cmd_Tx    = DataIn[10];
59
    wire Cmd_Rx    = DataIn[11];
60
    wire Cmd_RxN   = DataIn[12];
61
 
62
 
63
    assign I2C_Read         = Write & Cmd_Rx;
64
    assign I2C_Write        = Write & Cmd_Tx;
65
    assign I2C_ReadCountSet = Write & Cmd_RxN;
66
    assign I2C_EnQ          = Write & Cmd_EnQ;
67
    assign I2C_DeQ          = Read;
68
    assign I2C_Clear        = Write & Cmd_Clear;
69
    assign I2C_DataIn       = DataIn[7:0];
70
    assign DataOut[7:0]     = I2C_DataOut;
71
    assign DataOut[8]       = I2C_FifoEmpty;
72
    assign DataOut[9]       = I2C_FifoFull;
73
    assign DataOut[10]      = I2C_Nack;
74
    assign Ack              = I2C_Ack;
75
 
76
 
77
    // I2C Physical layer
78
    I2C_Phy PHY (
79
        .clock         (clock),
80
        .reset         (reset),
81
        .Read          (I2C_Read),
82
        .Write         (I2C_Write),
83
        .ReadCountSet  (I2C_ReadCountSet),
84
        .EnQ           (I2C_EnQ),
85
        .DeQ           (I2C_DeQ),
86
        .Clear         (I2C_Clear),
87
        .DataIn        (I2C_DataIn),
88
        .DataOut       (I2C_DataOut),
89
        .Ack           (I2C_Ack),
90
        .Nack          (I2C_Nack),
91
        .Fifo_Empty    (I2C_FifoEmpty),
92
        .Fifo_Full     (I2C_FifoFull),
93
        .i2c_scl       (i2c_scl),
94
        .i2c_sda       (i2c_sda)
95
    );
96
 
97
endmodule
98 3 ayersg
 

powered by: WebSVN 2.1.0

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