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

Subversion Repositories mips32r1

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
`timescale 1ns / 1ps
2 3 ayersg
/*
3
 * File         : I2C_Clock.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   21-Jun-2012  GEA       Initial design.
10
 *
11
 * Standards/Formatting:
12
 *   Verilog 2001, 4 soft tab, wide column.
13
 *
14
 * Description:
15
 *   Generates a 100 kHz clock signal and an indicator which pulses
16
 *   in the middle of the high and low periods of the clock.
17
 */
18 2 ayersg
module I2C_Clock(
19 12 ayersg
    input  clock,           // 100 (66) MHz
20 2 ayersg
    input  reset,
21 12 ayersg
    inout  scl,             // A 100 (66) kHz clock
22 2 ayersg
    output scl_tick_90      // A pulse indicating the middle of the +/- scl levels
23
    );
24
 
25
    reg [7:0] count_4x;
26
 
27
 
28
    always @(posedge clock) begin
29 3 ayersg
        //count_4x <= (reset) ? 8'h00 : (scl) ? count_4x + 1 : count_4x;
30 2 ayersg
        count_4x <= (reset) ? 8'h00 : count_4x + 1; // XXX SIMULATION ONLY
31
    end
32
 
33
    // A single pulse once every 250 cycles
34
    wire tick_4x = (count_4x == 8'hFA);
35
 
36
    reg [1:0] state;
37
    always @(posedge clock) begin
38
        if (reset) begin
39
            state <= 2'b00;
40
        end
41
        else begin
42
            case (state)
43
                2'd0 : state <= (tick_4x) ? 2'd1 : 2'd0;
44
                2'd1 : state <= (tick_4x) ? 2'd2 : 2'd1;
45
                2'd2 : state <= (tick_4x) ? 2'd3 : 2'd2;
46
                2'd3 : state <= (tick_4x) ? 2'd0 : 2'd3;
47
            endcase
48
        end
49 3 ayersg
    end
50 2 ayersg
 
51
    assign scl = ((state == 2'd0) || (state == 2'd1));
52
    assign scl_tick_90 = tick_4x & ((state == 2'd0) || (state == 2'd2));
53
 
54
endmodule
55 3 ayersg
 

powered by: WebSVN 2.1.0

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