Altera_Forum
Honored Contributor
10 years agoBidirectional bus - noob question
Sorry if this is a basic misunderstanding, but I'm just learning FPGAs (I did electronics at university, but that was 20+ years ago).
I've got the Cyclone II dev kit, and I'm trying to set it up so that a (slow) CPU connected to the GPIO ports can access the SRAM via the FPGA. So, I need a bidirectional bus 'inside' the FPGA. Having spent hours chasing varying compilation errors, I think I'm getting there - but the problem now seems to be down to the fact that the FPGA doesn't support internal tristate behaviour. I've now got a tristate buffer at the SRAM side and one at the GPIO side and 'split' the internal database bus into a read direction bus and a write direction bus (seemed simpler than trying to get a bidirectional bus internally). So, that's OK and makes sense. Now my problem is that I need several things to feed into the 'read' direction bus - eg the CPU can read the SRAM, or it can read control registers, and that's where I'm getting stuck. In old fashioned discrete logic, you'd have a tristate bus, tie the various outputs together, and only enable the outputs on the thing you want to read, but you can't do that on the FPGA because it doesn't support internal tristate lines. The only way I can think of doing it is to use lots of ORs and ANDs (or NORs and NANDs) to achieve the same, but that seems overcomplicated (and slower) - is that what I have to do, or am I missing something basic? (See the attached image for what I think I need to do, but 8 x (number of readable items) times, for an 8 bit bus)