I'm trying to implement a bidirectional bus in my code. (VHDL, APEX20K1500E). But I'm having some trouble which brought me to ask the question :
How do I specify the direction signal while using a bidirectional bus ? I dont find myself setting any enable signals when using the bidirectional bus. I would appreciate it if someone could explain how this works.
A bidirectional signal usually signifies read/write access to a resource (a memory location or a control register). If this is your application, the direction signal controls the enable signal of the bus drivers. In other words, when you read the data travels in one direction and when you write it travels the other direction. You set the enable signal correspondingly. As an example assume there is a driver which is active high for output enable from the memory to the outside, and there is an active high read, low write signal (rd_wrb). In this case, you'd connect the rd_wrb signal to the oe pin of the memory and when rd_wrb is one, data is driven from the memory to the bus and when rd_wrb is zero, memory uses the data on the bus.
Hope this helps,
Muzaffer Kal
formatting link
ASIC/FPGA design/verification consulting specializing in DSP algorithm implementations
So how does this work for pins on an FPGA ? I have specified some of the FPGA pins as bidirectional pins. I'm using the bidirectional pins to read from a register in the code or to write from a different register in the code. I dont understand how to specify the direction signal for the pins. I can do this at the signal/register level within the logic. But how are the bidirectional IO pins controlled ?
I wont say I know the perfect way.. but typically you only have a bi-directional bus on the outside world. Inside the FPGA use an output bus and an input bus.
Xilinx have internal tristates but they can pig out on resources (I think) but other vendors don't so code portability will suffer if you use / rely on them.
tristate_bus : process (enable, dat_o) is begin if (enable = '0') then dat_bus 'Z'); else -- if enable = '1' dat_bus > >APEX20K1500E). But I'm having some trouble which brought me to ask the
always @(rd_wrb or address or data) if (!rd_wrb) registers[address] = data;
and this is how you read from the registers including direction control
wire [7:0] data = rd_wrb ? registers[address] : 8'hZ;
this last line shows you control the direction signal for the pins. You take the input rd_wrb and connect it to the active high OE port of the data pins. Hope this help.
Muzaffer Kal
formatting link
ASIC/FPGA design/verification consulting specializing in DSP algorithm implementations
Hi prashant, All that you should know when the paricular pin is to act as input & when as output.The use a control signal like "oe" which i have in my following code .
Here "sda" is my bidirectional pin. Intenally I copy it to signal "out_sda" & use.While driving the pin "sda" i copy "int_sda" to "sda".this control is determined by the signal "oe".
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.