Line 35... |
Line 35... |
---- ----
|
---- ----
|
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
|
|
-- CVS Log
|
-- CVS Log
|
--
|
--
|
-- $Id: i2c_master_bit_ctrl.vhd,v 1.6 2003-02-01 02:03:06 rherveille Exp $
|
-- $Id: i2c_master_bit_ctrl.vhd,v 1.7 2003-02-05 00:06:02 rherveille Exp $
|
--
|
--
|
-- $Date: 2003-02-01 02:03:06 $
|
-- $Date: 2003-02-05 00:06:02 $
|
-- $Revision: 1.6 $
|
-- $Revision: 1.7 $
|
-- $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.6 2003/02/01 02:03:06 rherveille
|
|
-- Fixed a few 'arbitration lost' bugs. VHDL version only.
|
|
--
|
-- Revision 1.5 2002/12/26 16:05:47 rherveille
|
-- Revision 1.5 2002/12/26 16:05:47 rherveille
|
-- Core is now a Multimaster I2C controller.
|
-- Core is now a Multimaster I2C controller.
|
--
|
--
|
-- Revision 1.4 2002/11/30 22:24:37 rherveille
|
-- Revision 1.4 2002/11/30 22:24:37 rherveille
|
-- Cleaned up code
|
-- Cleaned up code
|
Line 204... |
Line 207... |
signal sto_condition : std_logic; -- stop detected
|
signal sto_condition : std_logic; -- stop detected
|
signal cmd_stop, dcmd_stop : std_logic; -- STOP command
|
signal cmd_stop, dcmd_stop : std_logic; -- STOP command
|
signal ibusy : std_logic; -- internal busy signal
|
signal ibusy : std_logic; -- internal busy signal
|
begin
|
begin
|
-- synchronize SCL and SDA inputs
|
-- synchronize SCL and SDA inputs
|
synch_scl_sda: process(clk)
|
synch_scl_sda: process(clk, nReset)
|
begin
|
begin
|
if (clk'event and clk = '1') then
|
if (nReset = '0') then
|
|
sSCL <= '1';
|
|
sSDA <= '1';
|
|
|
|
dSCL <= '1';
|
|
dSDA <= '1';
|
|
elsif (clk'event and clk = '1') then
|
|
if (rst = '1') then
|
|
sSCL <= '1';
|
|
sSDA <= '1';
|
|
|
|
dSCL <= '1';
|
|
dSDA <= '1';
|
|
else
|
sSCL <= scl_i;
|
sSCL <= scl_i;
|
sSDA <= sda_i;
|
sSDA <= sda_i;
|
|
|
dSCL <= sSCL;
|
dSCL <= sSCL;
|
dSDA <= sSDA;
|
dSDA <= sSDA;
|
end if;
|
end if;
|
|
end if;
|
end process synch_SCL_SDA;
|
end process synch_SCL_SDA;
|
|
|
-- 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
|
detect_sta_sto: process(clk)
|
detect_sta_sto: process(clk, nReset)
|
begin
|
begin
|
if (clk'event and clk = '1') then
|
if (nReset = '0') then
|
|
sta_condition <= '0';
|
|
sto_condition <= '0';
|
|
elsif (clk'event and clk = '1') then
|
|
if (rst = '1') then
|
|
sta_condition <= '0';
|
|
sto_condition <= '0';
|
|
else
|
sta_condition <= (not sSDA and dSDA) and sSCL;
|
sta_condition <= (not sSDA and dSDA) and sSCL;
|
sto_condition <= (sSDA and not dSDA) and sSCL;
|
sto_condition <= (sSDA and not dSDA) and sSCL;
|
end if;
|
end if;
|
|
end if;
|
end process detect_sta_sto;
|
end process detect_sta_sto;
|
|
|
-- generate i2c-bus busy signal
|
-- generate i2c-bus busy signal
|
gen_busy: process(clk, nReset)
|
gen_busy: process(clk, nReset)
|
begin
|
begin
|
Line 242... |
Line 267... |
end process gen_busy;
|
end process gen_busy;
|
busy <= ibusy;
|
busy <= ibusy;
|
|
|
|
|
-- generate arbitration lost signal
|
-- generate arbitration lost signal
|
gen_al: process(clk)
|
gen_al: process(clk, nReset)
|
begin
|
begin
|
if (clk'event and clk = '1') then
|
if (nReset = '0') then
|
|
cmd_stop <= '0';
|
|
dcmd_stop <= '0';
|
|
ial <= '0';
|
|
elsif (clk'event and clk = '1') then
|
|
if (rst = '1') then
|
|
cmd_stop <= '0';
|
|
dcmd_stop <= '0';
|
|
ial <= '0';
|
|
else
|
if (cmd = I2C_CMD_STOP) then
|
if (cmd = I2C_CMD_STOP) then
|
cmd_stop <= '1';
|
cmd_stop <= '1';
|
else
|
else
|
cmd_stop <= '0';
|
cmd_stop <= '0';
|
end if;
|
end if;
|
dcmd_stop <= cmd_stop;
|
dcmd_stop <= cmd_stop;
|
|
|
al <= (sda_chk and not sSDA and isda_oen) or (sto_condition and not dcmd_stop);
|
ial <= (sda_chk and not sSDA and isda_oen) or (sto_condition and not dcmd_stop);
|
|
end if;
|
end if;
|
end if;
|
end process gen_al;
|
end process gen_al;
|
ial <= al;
|
al <= ial;
|
|
|
-- generate dout signal, store dout on rising edge of SCL
|
-- generate dout signal, store dout on rising edge of SCL
|
gen_dout: process(clk)
|
gen_dout: process(clk)
|
begin
|
begin
|
if (clk'event and clk = '1') then
|
if (clk'event and clk = '1') then
|