D
deep
I am new to vhdl development . I am trying to model a I2C bus master and
slave, making components of each.the signal SDA and SCL are being fed in
both components i.e. master and slave.I am facing two problems:
1] when I call components in the design , there is a problem of multi
sourcing on "SDA" signal, when I write SDA in both components.I have
declared it as an inout port .
2] when I donot write in both cases i.e. write to"SDA" only in one of
components, but keep SDA as "inout" in both the components, it does not
changes the value of SDA.
I am synthesising in Xilinx and simulating in Modelsim .
Could anyone help me ...the code is described below...
Deep
entity I2C is
port ( rst : in std_logic;
clk: in std_logic;
sda : inout std_logic;
scl : inout std_logic;
data_in : in std_logic_vector( 7 downto 0) ;
data_out : out std_logic_vector( 7 downto 0)
);
end I2C;
architecture I2C_a of I2C is
type wrrd is ( wr, rd);
signal mode1: wrrd;
signal mode: std_logic;
signal data : std_logic_vector(7 downto 0);
component i2c_master is
port (rst : in std_logic;
clk: in std_logic;
sdam : inout std_logic;
sclm : out std_logic;
mode : inout std_logic;
data : in std_logic_vector( 7 downto 0)
);
end component;
component i2c_slave is
port (rst : in std_logic;
clk: in std_logic;
sdas : inout std_logic;
scls : in std_logic;
mode : in std_logic;
data : out std_logic_vector( 7 downto 0)
);
end component;
begin
port map(rst => rst,clk => clk,sdam=> sda,sclm=> scl,mode=>
mode,data=> data_in);
port map (rst=> rst, clk=> clk,sdas=>sda, scls=>scl, mode=> mode,
data=> data_out);
end I2C_a;
slave, making components of each.the signal SDA and SCL are being fed in
both components i.e. master and slave.I am facing two problems:
1] when I call components in the design , there is a problem of multi
sourcing on "SDA" signal, when I write SDA in both components.I have
declared it as an inout port .
2] when I donot write in both cases i.e. write to"SDA" only in one of
components, but keep SDA as "inout" in both the components, it does not
changes the value of SDA.
I am synthesising in Xilinx and simulating in Modelsim .
Could anyone help me ...the code is described below...
Deep
entity I2C is
port ( rst : in std_logic;
clk: in std_logic;
sda : inout std_logic;
scl : inout std_logic;
data_in : in std_logic_vector( 7 downto 0) ;
data_out : out std_logic_vector( 7 downto 0)
);
end I2C;
architecture I2C_a of I2C is
type wrrd is ( wr, rd);
signal mode1: wrrd;
signal mode: std_logic;
signal data : std_logic_vector(7 downto 0);
component i2c_master is
port (rst : in std_logic;
clk: in std_logic;
sdam : inout std_logic;
sclm : out std_logic;
mode : inout std_logic;
data : in std_logic_vector( 7 downto 0)
);
end component;
component i2c_slave is
port (rst : in std_logic;
clk: in std_logic;
sdas : inout std_logic;
scls : in std_logic;
mode : in std_logic;
data : out std_logic_vector( 7 downto 0)
);
end component;
begin
port map(rst => rst,clk => clk,sdam=> sda,sclm=> scl,mode=>
mode,data=> data_in);
port map (rst=> rst, clk=> clk,sdas=>sda, scls=>scl, mode=> mode,
data=> data_out);
end I2C_a;