Writing Testbench for Bidirectional/Inout Port

OP (Company: None) #4930810
Rate this post
useful
not useful
Hello! I have to write a testbench for I2C. I have an inout SDA port, 
which I drive to either zero or high impedance state in the module.I 
want to make sure that on the 9th clock cycle, when the SDA port is 
driven to a high impedance state for the slave to issue an acknowledge, 
the test bench drives the port low, indicating successful 
acknowledgement by the slave. Currently, I know when I want to drive the 
port low, this cycle is marked by an IO signal in simulation which goes 
high on the 9th clock cycle.

The function should be something like this :

//reg IO; //IO is controlled in the testbench, not exported from module.
 if (IO)  SDA = 1'b0;
 else     SDA = SDA;
///

The following approach did not work.

 assign SDA = IO? 1'b0 : SDA;
Guest #4930823
Rate this post
useful
not useful
The problem may be that you never set SDA = 1'bZ when IO===0. So your 
SDA signal is always driven by the test bench. ( I am not sure if 1'bZ 
is the correct notation for high impedance in Verilog, you have to look 
up)

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now