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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.