×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# How to implement a 2-way buffer based on a signal

## How to implement a 2-way buffer based on a signal

(OP)
I'm not sure if this would be possible to code in VHDL, but I would like to implement a two-way buffer using a CPLD (Complex Programmable Logic Device) where the input signal OE (OutputEnable) would determine the direction of the output.

So would it be possible to have two std_logic_vector's, say A and B, have their input and output determined based on a std_logic input signal OE?

So for example, if OE was high, then A would be the input, and B would be the output. Then if OE was low, then A would be the output, and B would be the input.

I can get this to work in ABEL HDL with INOUT signals but I can't seem to wrap my mind around how to approach this correctly in VHDL.

Thanks!
Replies continue below

### RE: How to implement a 2-way buffer based on a signal

wildchang,

This is perfectly possible in VHDL.

lets say the inout port is named A
A_int is an internal signal containing the output values for the port
A_OE is the output enable for the port A

you use the following syntax to asign the output:

A <= A_int when A_OE = '1' else 'Z';

This is for a standard logic;

For a vector this would be:

A <= A_int when A_OE = '1' else (others => 'Z');

You can at all times use A as an input, it's just for the output usage that you need to be sure no other device is driving the port.

The synthesizer will recognize the above code lines and instantiate tristate IO buffers. Most CPLDs I know have these.

Another way is checking the CPLD vendor documentation and instantiating the tristate IO buffer primitives directly from your VHDL. (Use generate for loops for vectors).

regards,

Jeandelfrigo

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!