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

Subversion Repositories i2c

[/] [i2c/] [trunk/] [rtl/] [verilog/] [i2c_master_top.v] - Diff between revs 16 and 27

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 27
Line 1... Line 1...
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
////                                                             ////
////                                                             ////
////  WISHBONE rev.B2 compliant I2C Master controller Top-level  ////
////  WISHBONE revB.2 compliant I2C Master controller Top-level  ////
////                                                             ////
////                                                             ////
////                                                             ////
////                                                             ////
////  Author: Richard Herveille                                  ////
////  Author: Richard Herveille                                  ////
////          richard@asics.ws                                   ////
////          richard@asics.ws                                   ////
////          www.asics.ws                                       ////
////          www.asics.ws                                       ////
Line 35... Line 35...
////                                                             ////
////                                                             ////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
 
 
//  CVS Log
//  CVS Log
//
//
//  $Id: i2c_master_top.v,v 1.5 2001-11-10 10:52:55 rherveille Exp $
//  $Id: i2c_master_top.v,v 1.6 2002-11-30 22:24:40 rherveille Exp $
//
//
//  $Date: 2001-11-10 10:52:55 $
//  $Date: 2002-11-30 22:24:40 $
//  $Revision: 1.5 $
//  $Revision: 1.6 $
//  $Author: rherveille $
//  $Author: rherveille $
//  $Locker:  $
//  $Locker:  $
//  $State: Exp $
//  $State: Exp $
//
//
// Change History:
// Change History:
//               $Log: not supported by cvs2svn $
//               $Log: not supported by cvs2svn $
 
//               Revision 1.5  2001/11/10 10:52:55  rherveille
 
//               Changed PRER reset value from 0x0000 to 0xffff, conform specs.
 
//
 
 
 
// synopsys translate_off
`include "timescale.v"
`include "timescale.v"
 
// synopsys translate_on
 
 
`include "i2c_master_defines.v"
`include "i2c_master_defines.v"
 
 
module i2c_master_top(
module i2c_master_top(
        wb_clk_i, wb_rst_i, arst_i, wb_adr_i, wb_dat_i, wb_dat_o,
        wb_clk_i, wb_rst_i, arst_i, wb_adr_i, wb_dat_i, wb_dat_o,
        wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_inta_o,
        wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_inta_o,
Line 68... Line 74...
        input        wb_rst_i;     // synchronous active high reset
        input        wb_rst_i;     // synchronous active high reset
        input        arst_i;       // asynchronous reset
        input        arst_i;       // asynchronous reset
        input  [2:0] wb_adr_i;     // lower address bits
        input  [2:0] wb_adr_i;     // lower address bits
        input  [7:0] wb_dat_i;     // databus input
        input  [7:0] wb_dat_i;     // databus input
        output [7:0] wb_dat_o;     // databus output
        output [7:0] wb_dat_o;     // databus output
        reg [7:0] wb_dat_o;
 
        input        wb_we_i;      // write enable input
        input        wb_we_i;      // write enable input
        input        wb_stb_i;     // stobe/core select signal
        input        wb_stb_i;     // stobe/core select signal
        input        wb_cyc_i;     // valid bus cycle input
        input        wb_cyc_i;     // valid bus cycle input
        output       wb_ack_o;     // bus cycle acknowledge output
        output       wb_ack_o;     // bus cycle acknowledge output
        output       wb_inta_o;    // interrupt request signal output
        output       wb_inta_o;    // interrupt request signal output
 
 
 
        reg [7:0] wb_dat_o;
 
        reg wb_ack_o;
        reg wb_inta_o;
        reg wb_inta_o;
 
 
        // I2C signals
        // I2C signals
        // i2c clock line
        // i2c clock line
        input  scl_pad_i;       // SCL-line input
        input  scl_pad_i;       // SCL-line input
        output scl_pad_o;       // SCL-line output (always 1'b0)
        output scl_pad_o;       // SCL-line output (always 1'b0)
        output scl_padoen_o;    // SCL-line output enable (active low)
        output scl_padoen_o;    // SCL-line output enable (active low)
 
 
        // i2c data line
        // i2c data line
        input  sda_pad_i;       // SDA-line input
        input  sda_pad_i;       // SDA-line input
        output sda_pad_o;       // SDA-line output (always 1'b0)
        output sda_pad_o;       // SDA-line output (always 1'b0)
        output sda_padoen_o;    // SDA-line output enable (active low)
        output sda_padoen_o;    // SDA-line output enable (active low)
 
 
Line 121... Line 130...
 
 
        // generate internal reset
        // generate internal reset
        wire rst_i = arst_i ^ ARST_LVL;
        wire rst_i = arst_i ^ ARST_LVL;
 
 
        // generate acknowledge output signal
        // generate acknowledge output signal
        assign wb_ack_o = wb_cyc_i && wb_stb_i; // because timing is always honored
        always @(posedge wb_clk_i)
 
          wb_ack_o <= #1 wb_cyc_i & wb_stb_i & ~wb_ack_o; // because timing is always honored
 
 
        // assign DAT_O
        // assign DAT_O
        always@(wb_adr_i or prer or ctr or txr or cr or rxr or sr)
        always @(posedge wb_clk_i)
        begin
        begin
                case (wb_adr_i) // synopsis full_case parallel_case
                case (wb_adr_i) // synopsis full_case parallel_case
                        3'b000: wb_dat_o = prer[ 7:0];
                        3'b000: wb_dat_o = prer[ 7:0];
                        3'b001: wb_dat_o = prer[15:8];
                        3'b001: wb_dat_o = prer[15:8];
                        3'b010: wb_dat_o = ctr;
                        3'b010: wb_dat_o = ctr;
Line 234... Line 244...
                                irq_flag <= #1 1'b0;
                                irq_flag <= #1 1'b0;
                        end
                        end
                else
                else
                        begin
                        begin
                                rxack    <= #1 irxack;
                                rxack    <= #1 irxack;
                                tip      <= #1 (rd || wr);
                tip      <= #1 (rd | wr);
                                irq_flag <= #1 (done || irq_flag) && !iack; // interrupt request flag is always generated
                irq_flag <= #1 (done | irq_flag) & ~iack; // interrupt request flag is always generated
                        end
                        end
 
 
                // generate interrupt request signals
                // generate interrupt request signals
                always@(posedge wb_clk_i or negedge rst_i)
                always@(posedge wb_clk_i or negedge rst_i)
                        if (!rst_i)
                        if (!rst_i)
Line 256... Line 266...
                assign sr[1]   = tip;
                assign sr[1]   = tip;
                assign sr[0]   = irq_flag;
                assign sr[0]   = irq_flag;
 
 
endmodule
endmodule
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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