Forum Discussion
Altera_Forum
Honored Contributor
14 years agoCascading CPLDs on different PCBs
I'm designing a basic harness continuity checker based on shift registers implemented in Max V CPLDs. I'm aiming for a modular/extendable PCB design for the project as it has several benefits (cost, less complexity).
A uC communicates with my CPLDs using SPI. What I'm not sure about is how to best cascade these CPLDs in order to obtain a larger shift register. In a 144-pin TQFP, I only have 114 IO pins. Therefore, I can only implement a 114-bit Serial In Parallel Out or a Parallel In shift register. But by cascading these 114 IO devices I can obtain much larger shift registers. However, I'd like to place these additional CPLDs on a different PCB. This has the advantage that I can simply extend the device when I need. On smaller harnesses, a single 114 test-point PCB will suffice. On larger ones, I can cascade. At the moment, the CPLD is really just a shift-register. But in the future I'm hoping to implement a state-machine that can possibly implement more functions, like checksum to verify the contents sent by the uC etc. But that's for later and all I know is that I'd just use SPI for communication. As the CPLDs need SPI for communication, I am guessing that I need to pass these onto the cascading shift register i.e. each device will have a Serial Out (SO) pin. But it will also need to pass CLK, Chip Select and even a SI/MISO pin incase the uC needs to read back the shift register contents. I think buffering the signals would be good practice. But what would be the best way to actually connect the PCBs together? I suppose these really depends on the speed of operation. Fortunately, speed isn't an issue and therefore I'm operating at a very low frequency - just 62.5kHz. I'd like to be able to increase this, perhaps to 500kHz. I don't think I'll need any beyond that. At such frequencies, what's the best way to cascade PCBs and CPLDs? Please note, I'm aware that I can purchase a large 324-pin device. I'm afraid, I can't really use that as there is no way to inspect BGAs here locally. So I'm sticking with TQFP packages. I'm also aware that the topic, perhaps, mostly pertains to pcb-layout but I'm hoping I can get some CPLD/FPGA centric advice here regarding what signals I need to send as I'm not so sure about that. Would appreciate any responses.23 Replies
- Altera_Forum
Honored Contributor
This TI article is somewhat relevant to this discussion:
"Extending the SPI bus for long-distance communication" http://www.ti.com/lit/an/slyt441/slyt441.pdf - Altera_Forum
Honored Contributor
--- Quote Start --- But if feeding the clock to just one pin is ok, why does the CPLD have as much as 4 dedicated pins for the clock? Not that I'm complaining, just want to know. --- Quote End --- Many systems have more than one clock :) Cheers, Dave - Altera_Forum
Honored Contributor
--- Quote Start --- You don't. Each CPLD synchronizes the serial data to its own clock domain. The I/Os would update on the rising-edge of the shift clock, as detected in the synchronized domain (within a couple of clocks of each oscillator), or you can use the serial clock to update it. --- Quote End --- Ah, so each daughter-board as it's own oscillator. I think I'll go with an oscillator then. But if feeding the clock to just one pin is ok, why does the CPLD have as much as 4 dedicated pins for the clock? Not that I'm complaining, just want to know. - Altera_Forum
Honored Contributor
--- Quote Start --- 1) Do I need to connect the oscillator to all 4 pins? The development board's schematic shows the oscillator being only connected to one pin. --- Quote End --- To one clk pin is fine. --- Quote Start --- 2) What's the best way to send this clock source to the next PCB? LVDS I presume? I'm gonna go with a oscillator of 8 MHz or so. --- Quote End --- You don't. Each CPLD synchronizes the serial data to its own clock domain. The I/Os would update on the rising-edge of the shift clock, as detected in the synchronized domain (within a couple of clocks of each oscillator), or you can use the serial clock to update it. --- Quote Start --- 3) Is it better to go with an oscillator or a crystal? --- Quote End --- I always use oscillators, since they 'just work'. Cheers, Dave - Altera_Forum
Honored Contributor
Dave,
You mentioned that I should have an external oscillator on the board that feeds the global clock network of the CPLDs via the GCLK pins. My questions are: 1) Do I need to connect the oscillator to all 4 pins? The development board's schematic shows the oscillator being only connected to one pin. 2) What's the best way to send this clock source to the next PCB? LVDS I presume? I'm gonna go with a oscillator of 8 MHz or so. 3) Is it better to go with an oscillator or a crystal? - Altera_Forum
Honored Contributor
--- Quote Start --- I agree with your philosophy 100%. Which is why, after some discussion with my colleagues, is there any inherent advantage to this "Parallel-SPI" approach over doing it like JTAG? We can still program the CPLD on the main board with advanced things later on (like checksum, etc.) This approach would eliminate the addressing, wouldn't it? We can just use two CS to select between the CPLDs intended for driving and those intended for receiving. --- Quote End --- The key to the board design is to keep as many options open as makes sense. The 'all CPLDs as one big shift-register' option is conceptually the simplest, while the 'each CPLD is individually addressable' is a little more complex, but more flexible. The difference between the two designs is a single wire (or perhaps a couple). So you layout the boards to support both options. Then implement one of them. --- Quote Start --- When I want to drive the test-vector into the driving CPLDs, I select CS1. If I want to receive the output vector, I select CS2. Essentially, I treat a chain of CPLDs as a single shift register. No need to mess with addressing (I think?) --- Quote End --- Yep, that is probably correct. Simulate it and see if it all works. --- Quote Start --- Will this work? --- Quote End --- Your block diagram does not reflect (your) reality. You said you would have two CPLDs per board, so draw it that way. Now, where do the master controls for the second board come from? Are they buffered and re-driven from the microcontroller, or from the CPLD? You show CS1 and CS2. So now they will be seen in common by the second board. Now when you do your shift sequence between the two boards, will it all work? These are the types of questions you can answer by writing a couple of CPLD designs, tying them together into a 'board' design, and then cascading a couple of those 'boards' in a testbench. You then generate shift-register shifts, and check the I/O state after each shift. Once that all works, then you go back to your board design. As far as I can tell, you should not have any trouble getting it to work. The key is not to jump into the PCB design, and then realize you've forgotten something. Get the system working in the simulator, and use that to fine tune the design. Cheers, Dave - Altera_Forum
Honored Contributor
Thanks, Dave. Going through your documents now.
I agree with your philosophy 100%. Which is why, after some discussion with my colleagues, is there any inherent advantage to this "Parallel-SPI" approach over doing it like JTAG? We can still program the CPLD on the main board with advanced things later on (like checksum, etc.) This approach would eliminate the addressing, wouldn't it? We can just use two CS to select between the CPLDs intended for driving and those intended for receiving. Here's what I mean: When I want to drive the test-vector into the driving CPLDs, I select CS1. If I want to receive the output vector, I select CS2. Essentially, I treat a chain of CPLDs as a single shift register. No need to mess with addressing (I think?) http://i.imgur.com/XjQk1.png Will this work? - Altera_Forum
Honored Contributor
--- Quote Start --- I'M now thinking of the format of an entire frame. Each module will have 74 test points. Let's assume it's just 72 bits and we get a nice round figure of 9 bytes. So, we first send 2-bytes containing the address and then we send 9 bytes of data - obviously if the address doesn't match, the CPLD ignores anything sent afterwards. So essentially we have a 11 byte shift register. --- Quote End --- Yes. Look at the AD9956 document I gave you a link to. It can be similar to that. --- Quote Start --- However, how would the uC receive back the data from the CPLDs that specifically are meant for receiving the test-vectors? How about if I make the address 15-bit and make the LSB a Read/Write indicator? If this is 0, the CPLD will send the 9 bytes of data in its shift register. If it's 1, it will shift in new data that it receives just after this Read/Write bit. --- Quote End --- Now go and read the byteblaster interface ... it does something like this. --- Quote Start --- I know this is probably inefficient but I'm trying to start out small. As the devices will have a full SPI interface, I can easily upgrade the firmware as I get more experience with VHDL. I've been a C programmer for the past 10 years so VHDL still runs circles around my head. --- Quote End --- "Inefficient" is in the eye of the beholder. My philosophy is "Get it working first, then get it 'right'". Sometimes 'right' is skipped, since 'working' is often good enough :) Cheers, Dave - Altera_Forum
Honored Contributor
I didn't realize the LSB is hard-wired. Of course it is, otherwise we'd need two switches. Sometimes I miss obvious things - sorry about that.
I'M now thinking of the format of an entire frame. Each module will have 74 test points. Let's assume it's just 72 bits and we get a nice round figure of 9 bytes. So, we first send 2-bytes containing the address and then we send 9 bytes of data - obviously if the address doesn't match, the CPLD ignores anything sent afterwards. So essentially we have a 11 byte shift register. The CPLD, after receiving all 9 bytes of data can enable the outputs so that the test-vector appears at the output. This seems simple enough. The CPLD can transfer the data to another shift-register thats only meant for the output test-vector. However, how would the uC receive back the data from the CPLDs that specifically are meant for receiving the test-vectors? How about if I make the address 15-bit and make the LSB a Read/Write indicator? If this is 0, the CPLD will send the 9 bytes of data in its shift register. If it's 1, it will shift in new data that it receives just after this Read/Write bit. I know this is probably inefficient but I'm trying to start out small. As the devices will have a full SPI interface, I can easily upgrade the firmware as I get more experience with VHDL. I've been a C programmer for the past 10 years so VHDL still runs circles around my head. - Altera_Forum
Honored Contributor
Rather than using SPI to control the boards, you can also use an FTDI FT245 USB-to-FIFO component.
If your boards are all close together, then you would just have a USB cable to each board. Each device would show up as a COM port. You can use the serial number in the FTDI chip to uniquely identify boards, which can in turn be used to create unique COM numbers or udev names under Linux. You would still use a DIP switch in this case, as it allows the software to identify board 0, 1, 2, etc. No microcontroller would be needed in this scheme. I have an FTDI-to-Avalon-MM bridge that I've created ... I just haven't got around to documenting it yet ... you can use that code. Cheers, Dave