EmbDev.net

Forum: FPGA, VHDL & Verilog Test bench I2C (vhdl)


von Javier P. (lascameador)


Rate this post
useful
not useful
hi guys!
I've developed two i2c components.
1
u1: SlaveI2CA generic map (SLAVE_ADDR) port map(scl,sda1,clk,rst,starting1,sda2);
2
u2: SlaveI2CB generic map (SLAVE_ADDR) port map(scl,sda3,clk,rst,starting2,sda4);

I want to connect sda2 and sda3 with a pullup resistor (in simulation) 
but i don't know how to do this.
When I write 'Z' or '0' the slave works,while it has already been 
programmed ,but i don't know how to develope this function in 
simulation.

any advices??
thanks ;)

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Javier PA wrote:
> but i don't know how to develope this function in simulation.
Try it with Google translator:
http://www.lothar-miller.de/s9y/archives/91-Schalter-und-Bruecke.html

I would take the switch model and connect it with a pullup (='H') this 
way:
1
 SDA_A --- Switch --- 'H' --- Switch --- SDA_B
2
3
 SCL_A --- Switch --- 'H' --- Switch --- SCL_B

Of course the switch model could be simplified to a Zero-Ohm this way:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
4
entity zeroohm is
5
    Port ( A : inout  STD_LOGIC;
6
           B : inout  STD_LOGIC);
7
end swbidi;
8
9
architecture Behavioral of zeroohm is
10
begin
11
  process
12
    variable thentime : time;
13
  begin
14
    wait on A, B until thentime /= now;
15
    
16
    -- Break
17
    thentime := now;
18
    A <= 'Z';
19
    B <= 'Z';
20
    wait for 0 ns;
21
    
22
    -- Make
23
    A <= B;
24
    B <= A;
25
  end process;
26
27
end Behavioral;

: Edited by Moderator
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.