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

Subversion Repositories i2c

[/] [i2c/] [tags/] [asyst_3/] [rtl/] [verilog/] [i2c_master_bit_ctrl.v] - Diff between revs 30 and 35

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

Rev 30 Rev 35
Line 35... Line 35...
////                                                             ////
////                                                             ////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
 
 
//  CVS Log
//  CVS Log
//
//
//  $Id: i2c_master_bit_ctrl.v,v 1.7 2002-12-26 16:05:12 rherveille Exp $
//  $Id: i2c_master_bit_ctrl.v,v 1.8 2003-02-05 00:06:10 rherveille Exp $
//
//
//  $Date: 2002-12-26 16:05:12 $
//  $Date: 2003-02-05 00:06:10 $
//  $Revision: 1.7 $
//  $Revision: 1.8 $
//  $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.7  2002/12/26 16:05:12  rherveille
 
//               Small code simplifications
 
//
//               Revision 1.6  2002/12/26 15:02:32  rherveille
//               Revision 1.6  2002/12/26 15:02:32  rherveille
//               Core is now a Multimaster I2C controller
//               Core is now a Multimaster I2C controller
//
//
//               Revision 1.5  2002/11/30 22:24:40  rherveille
//               Revision 1.5  2002/11/30 22:24:40  rherveille
//               Cleaned up code
//               Cleaned up code
Line 208... Line 211...
        reg sta_condition;
        reg sta_condition;
        reg sto_condition;
        reg sto_condition;
 
 
        // synchronize SCL and SDA inputs
        // synchronize SCL and SDA inputs
        // reduce metastability risc
        // reduce metastability risc
        always @(posedge clk)
        always @(posedge clk or negedge nReset)
 
          if (~nReset)
 
            begin
 
                sSCL <= #1 1'b1;
 
                sSDA <= #1 1'b1;
 
 
 
                dSCL <= #1 1'b1;
 
                dSDA <= #1 1'b1;
 
            end
 
          else if (rst)
 
            begin
 
                sSCL <= #1 1'b1;
 
                sSDA <= #1 1'b1;
 
 
 
                dSCL <= #1 1'b1;
 
                dSDA <= #1 1'b1;
 
            end
 
          else
          begin
          begin
              sSCL <= #1 scl_i;
              sSCL <= #1 scl_i;
              sSDA <= #1 sda_i;
              sSDA <= #1 sda_i;
 
 
              dSCL <= #1 sSCL;
              dSCL <= #1 sSCL;
              dSDA <= #1 sSDA;
              dSDA <= #1 sSDA;
          end
          end
 
 
        // detect start condition => detect falling edge on SDA while SCL is high
        // detect start condition => detect falling edge on SDA while SCL is high
        // detect stop condition => detect rising edge on SDA while SCL is high
        // detect stop condition => detect rising edge on SDA while SCL is high
        always @(posedge clk)
        always @(posedge clk or negedge nReset)
 
          if (~nReset)
 
            begin
 
                sta_condition <= #1 1'b0;
 
                sto_condition <= #1 1'b0;
 
            end
 
          else if (rst)
 
            begin
 
                sta_condition <= #1 1'b0;
 
                sto_condition <= #1 1'b0;
 
            end
 
          else
          begin
          begin
              sta_condition <= #1 ~sSDA &  dSDA & sSCL;
              sta_condition <= #1 ~sSDA &  dSDA & sSCL;
              sto_condition <= #1  sSDA & ~dSDA & sSCL;
              sto_condition <= #1  sSDA & ~dSDA & sSCL;
          end
          end
 
 
Line 239... Line 270...
        // generate arbitration lost signal
        // generate arbitration lost signal
        // aribitration lost when:
        // aribitration lost when:
        // 1) master drives SDA high, but the i2c bus is low
        // 1) master drives SDA high, but the i2c bus is low
        // 2) stop detected while not requested
        // 2) stop detected while not requested
        reg cmd_stop, dcmd_stop;
        reg cmd_stop, dcmd_stop;
        always @(posedge clk)
        always @(posedge clk or negedge nReset)
 
          if (~nReset)
 
            begin
 
                cmd_stop  <= #1 1'b0;
 
                dcmd_stop <= #1 1'b0;
 
                al        <= #1 1'b0;
 
            end
 
          else if (rst)
 
            begin
 
                cmd_stop  <= #1 1'b0;
 
                dcmd_stop <= #1 1'b0;
 
                al        <= #1 1'b0;
 
            end
 
          else
        begin
        begin
          cmd_stop  <= #1 cmd == `I2C_CMD_STOP;
          cmd_stop  <= #1 cmd == `I2C_CMD_STOP;
          dcmd_stop <= #1 cmd_stop;
          dcmd_stop <= #1 cmd_stop;
 
 
          al <= #1 (sda_chk & ~sSDA & sda_oen) | (sto_condition & ~dcmd_stop);
          al <= #1 (sda_chk & ~sSDA & sda_oen) | (sto_condition & ~dcmd_stop);
        end
        end
 
 
 
 
        // generate dout signal (store SDA on rising edge of SCL)
        // generate dout signal (store SDA on rising edge of SCL)
        always @(posedge clk)
        always @(posedge clk)
          if(sSCL & ~dSCL)
          if(sSCL & ~dSCL)
            dout <= #1 sSDA;
            dout <= #1 sSDA;
 
 

powered by: WebSVN 2.1.0

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