# Microcontroller, FPGA or CPLD?

1. Aug 8, 2007

### Jdo300

Hello All,

I'm still working on the ultimate programmable precision pulse control circuit for my experiments. Most of the stuff I have made so far has used discrete components and analog parts to do the job but I'm ready to start looking into some of the more advanced approaches.

As the title shows, I'm looking at microcontrollers, FPGAs and CPLDs. I don't know much about them beyond the general differences but I'm not sure which one would be best to learn to program first. So I thought I would ask you all here to get some opinions on this. Which type do you all think would be easiest to get into?

To give you an idea of my background, I have taken an intro class to Assembly programming, and computer architecture as well as other languages such as C++, VB, and Java.

God Bless,
Jason O

2. Aug 8, 2007

### edmondng

fpga more complex, more power, fast, cost more too. Easy to modify as well. Some companies have graphical layout to help in programming (haven't done FPGA but check xilinx out, development kit cost a lot )

cpld i believe has faster processing, easy to modify too. Cost maybe about the same or little more than microcontroller depending on I/O's. Uses VHDL language (eg: atmel that has really cheap development kit starting maybe $50) microcontroller is less complex (once you have the base code made), cheap and less power (if you went with UART). If you go to like USB microcontroller it cost a bit but then has more capability. Can be program in C, C++, Assembly) I guess it depends on your application. If you want something portable, cost less and doesn't need the processing complexity (like doing audio/video streaming, data transfer etc) an 8051 controller will work well just to toggle bits, DAC, A/D, I2C, SPI to control other device. 3. Aug 8, 2007 ### berkeman ### Staff: Mentor Here is a brief intro to programmable logic (CPLDs and FPGAs): http://www.handasarabia.org/mambo/index.php?option=com_docman&task=doc_download&gid=12&lang=Ar You can download a copy of the Altera CPLD design software "Quartus II" from Altera's website: https://www.altera.com/support/software/download/sof-download_center.html You need to register first with Altera, I think, but I believe that the download is free. You can download a copy of Xilinx's excellent FPGA design software suite "ISE WebPack" from Xilinx's website: http://www.xilinx.com/products/design_resources/design_tool/index.htm And for your first uC programming experiments, I'd recommend getting or building a simple PIC evaluation board, and programming it in C or assembly. Learning all of these tools is very important for EEs. Depending on what kind of work you do, you will probably use each of them on pretty much a daily basis in one way or another. BTW, Verilog is used in the Silicon Valley for writing CPLD and FPGA code, but I believe VHDL is mostly used elsewhere. Last edited: Aug 8, 2007 4. Aug 8, 2007 ### chroot Staff Emeritus If you're already familiar with C programming, you'll find the microcontrollers to have the easiest learning curve. They will not be capable of any truly "precise" pulse generation, though. The best precision you'll be able to get is some multiple of their clock period. FPGAs and CPLDs are much, much more flexible. You can program both using schematics, but you might find it more useful to learn a hardware description language like Verilog. (Stay away from VHDL, it's a horrible language and virtually no one in industry uses it.) The learning curve can be pretty steep. FPGAs and CPLDs will both involve significantly higher start-up costs than microcontrollers. The benefit? They're so flexible that you can probably get virtually any timing you want out of them, particularly if you use FPGAs which have built-in digital PLLs. They're not going to have fabulous jitter performance, but you'll be able to get performance and flexibility close to that of an ASIC for many applications. - Warren 5. Aug 8, 2007 ### berkeman ### Staff: Mentor Hey chroot, Do you have any good learning resources you could recommend for Verilog? I've only used it a little, and I learned that from the digital hotshots that I work with. When I asked them for a good book recommendation, they just laughed and said that there aren't any. There are books, but none that are good to learn from. Do you have any suggestions, especially ones that include discussions of the RTL subset of Verilog? Thanks. Last edited: Aug 8, 2007 6. Aug 8, 2007 ### chroot Staff Emeritus The classic book is Palnitkar: http://www.amazon.com/Verilog-HDL-2...6729728?ie=UTF8&s=books&qid=1186618996&sr=8-1 It serves as a thorough reference, and has a reasonably good pedagogical approach. The reason why your coworkers laugh is because Verilog, like C and many other "programming" languages, has some gotchas. Understanding the syntax is not enough to be able to write code that will synthesize to small, fast logic. There are often four or five ways to code any specific task, and there can be differences in speed or size of the resulting logic of almost orders of magnitude. I recommend reading papers by Sutherland to get more of the "design sense" of how to properly use Verilog. http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_top.html - Warren 7. Aug 8, 2007 ### berkeman ### Staff: Mentor Great stuff, chroot. Thanks for the links. 8. Aug 12, 2007 ### Jdo300 Hey Guys, Thanks for all the great links and recomendations :-). It looks like the FPGA approach is where I might head. I don't have a startup kit but I will at least familiarize myself with some of the programming stuff so that I can use it when I finally do get a development kit. Thank you all! - Jason O 9. Aug 12, 2007 ### Jdo300 10. Aug 13, 2007 ### Jdo300 Hello Again, Just a quick question. Does anyone know of any good FPGA development kits for a newbie like me? I heard of someone using a Spartan kit but does anyone here have any recommendations? Thanks, Jason O 11. Aug 13, 2007 ### chroot Staff Emeritus Hey Jdo300, asic-world.com is a good site. It's more a reference than a tutorial though. You will learn the syntax and basic composition of the language there, but you won't learn the minutia of how to make your resulting design fast and small. To my knowledge, there really is no comprehensive book on writing tight Verilog. - Warren 12. Aug 14, 2007 ### Odin42 Ultra precise can mean a lot of different things, first thing you need to specify is how precise. How long are the pulses you are trying to make? What type of precision do you need? Also it is nice to know what type of budget, how much time you have to do your project? 13. Aug 15, 2007 ### Jdo300 Hi Odin42, When I say high precision, I'm looking at the frequency resolution that I need. The primary range I'm working in is from 1 Hz to 1 MHz although it would be nice if I could go up to the 20 MHz range (I know that's asking a lot). The pulse width I'd like to have would be somewhere from 10 ns and up. In a perfect world, I would be nice to have a frequency resolution of at least 0.1 Hz. for most of the range. The FPGA has to have a fast enough clock to give me the ability to do phase shifting between the output pulses with 15 degree resolution between channels. (there would be three channels of pulse output). Thanks, Jason O Last edited: Aug 15, 2007 14. Aug 15, 2007 ### chroot Staff Emeritus You want to generate a square wave, over a range of frequencies from 1 Hz to 20 MHz, with a frequency resolution of something like 0.1 Hz? You're not going to be able to do this with anything but an FPGA. I would look into numerically controlled oscillators (NCOs), which are simple designs which can "play back" a pattern stored in memory at any speed you like. They also give you excellent phase resolution, and are trivially easy to change phases. The only problem I see is that you're going to have quite a bit of jitter if use an NCO to generate a square wave. The normal procedure to use an NCO is to follow it with some kind of analog smoothing filter, but that won't be an option for a square wave. Honestly, why on earth are you attempting to create something like this with digital components anyway? Now that we understand your needs better, I would really suggest that you just use an analog frequency synthesizer chip (ADI makes some). If you need to control it digitally, use a microcontroller or some digitally-controlled potentiometers. - Warren 15. Aug 15, 2007 ### Jdo300 Hi Warren, Thanks for the tips. I've never even heard of an analog frequency synthesizer. What kind of frequency range can these things have? I would love to learn more about these. especially if they can by synchronized together and phase shifted with respect to each other. That is honestly all I need to do. The only reason I'm having so much trouble is to find a setup that will work well up into the higher frequencies. If you know of any chips that may be suitable for my purposes, I would be very happy too look into it. Thanks, Jason O Last edited: Aug 15, 2007 16. Aug 15, 2007 ### chroot Staff Emeritus 17. Aug 16, 2007 ### Jdo300 Thanks for the reference. I"m going to definitely look into this one. BTW, do you know of any of these chips that come in a through hole package? 18. Aug 16, 2007 ### chroot Staff Emeritus Sorry, I don't really keep track of packages of the products I help design, much less those sold by other companies! Besides, I'd say only 10% of the parts sold today come in packages that are easy to solder. I don't really know what to tell you to do with a tiny SMT package. - Warren 19. Aug 17, 2007 ### Jdo300 It's ok Warren Thanks for you help with this. @Everyone, I'm still going to see about learning to program an FPGA and I was wondering if anyone here knows of any physically small development boards for under$100. It doesn't need to be fancy; I just need the bare minimum, which would be the FPGA, programming port, memory to hold the program, and some IO pins. In a perfict world, I would like to get a development board that is around 3" x 3" to fit inside of the coil that I'll be experimenting with. Im playing around with high speed rotating magnetic fields so the board would need to sit in the middle of the field where the 'dead zone' is to avoid relativistic effects from running wires to the coil from the outside (yeah I know it sounds weird). Any suggestions?

Thanks,
Jason O

20. Aug 17, 2007

### Jdo300

Ok, have been doing some more reading to figure out how to actually make the FPGA generate the frequencies I need. Apparently, I have to implement some different fractional division techniques to even get decently frequency resolution out of it.

Now that I think about it, I'm beginning to sway back to the Analog frequency synthesis idea again. The other good thing is that I actually have two 68HC12 microcontrollers that I got from school (for free) that I could use to program the frequency chips. But I'm wondering if anyone here may know of any good resources out there to aid me in doing this. I have pretty much no experience in this area. I am now looking at some tutorials to see how to program the microcontroller, which as someone pointed out earlier, will be much less painful since I already have some experience programming in C and assembly. My only question at this point is figuring out how to sync up the three AFS chips.

Thanks,
Jason O