Special Pages

Tuesday, May 13, 2014

Techy Tuesday - Digital Design Primer - Part II

There have been some unfortunate delays since Part I due to things popping up around the house that just had to be done, and sucking up all the time I'd use to write this.  So let's just dive in, shall we?

I wrote a lot about combining signals with logic; the area called combinatorial logic.  How is this used?  When an electronic system is being developed, the subsystems and lower level assemblies pass a lot of information back and forth between themselves.  These things are undoubtedly hard for someone who has never built electronics to envision, but the individual signals might be commands to do something, or time signals that say it's time (or it isn't) for an event to happen.  If you're operating a handheld transceiver, for example, you will press a "Push to Talk" button and that signal will often need to do many things.  It may turn on an audio amplifier at the microphone, turn on voltages that power the transmitter, turn off the receiver (or just mute its audio), and other things.  It may be combined with other signals; for example, the radio may tune a wide spectrum but only be authorized to transmit in ham bands.  "Something, somewhere" in the radio says transmission is authorized, and the signals go through an AND gate.  That's the equivalent of saying "If PTT is pressed, AND I can use this frequency, then I transmit". 

In the days of lots of discrete logic, designers would map out the logic required to implement functions.  Some of it was done with graphical design techniques, Karnaugh or K Maps; some of it was done by hand (experience).  Compared to today's consumer products, these were big and bulky circuits.  Miniaturization of packages and more integration helps, but not as much as you might think; the more signals going in and out of the logic portion of the design, the more pins you need and connections limit the size far more than the logic. 

The world, though, is full of cheap consumer devices like your GPS or cycling computer or dive computer or heart rate monitor (pictured).  This monitor is sold with a transmitter you wear, together for just over $100.  How do they make them so cheaply that they can be manufactured, put in a package and shipped halfway around the world for that price?  No, it's not by going to China (at least, not exclusively).
 
They do it by turning everything in this package into a the smallest number of parts possible, replacing the many individual counters and other components with a custom ASIC - Application Specific Integrated Circuit.  Similarly, the display is a custom Liquid Crystal Display -LCD.  Together in an injection molded plastic case, they can be popped off the assembly line with the least effort and cost.  Designing for low cost is done in the design group, not by taking any approach and finding cheap labor to build it.

Design is all about trades, and the trade here is that developing ASICs is expensive.  The last time I was around a project that wanted to develop one, the first batch of parts was a quarter million dollars, and I'll bet it's not significantly cheaper today.  If your parts don't work, you pretty much have thrown that $250k out.

While you can't make an ASIC, you can get most of the way there with a Field Programmable Gate Array, an FPGA.  An FPGA allows the user to minimize the number of digital gates and parts in your design, which minimizes the size - and usually the power consumed, too.  It's programmed on power-up by a small programmable memory, and may be reprogrammed over and over.  Long the domain of the digital design wizards, they are coming onto the hobby market with the emphasis of learning how to design the FPGA.  This isn't done with any of those old techniques, like the Karnaugh  map; it's done by programming what you want the FPGA to do in a high level language that looks like Pascal.  Why Pascal?  It's sort of the default software training language these days; most enginerds get exposed to it in school.  It also bears a strong resemblance to a language called ADA that the DOD uses.   

Check out The Gadget Factory and Papilio - a board for experimenting with programming your own FPGA.  They have a page full of free downloads to help you learn the programming language, called VHDL, an acronym of acronyms if you listen to that Wikipedia page that says it stands for VHSIC Hardware Description Language (VHSIC was military acronym or program; it stands for Very High Speed Integrated Circuit) .  Adafruit features the Mojo FPGA Development Board also intended for learning FPGA programming.  I expect more of these systems to start showing up.  While top end FPGAs can be very expensive, there are many which can be used in small group designs.  

Make no mistake: this isn't beginners' stuff.  But the tools are out there, the open source community is out there and the potential rewards are great, even for small patriot groups. 


6 comments:

  1. The first programming language I paid for to run on my brand new Intel 80286 PC was Borland Pascal. As I recall it was some time before a C language product was available. It makes me wonder if the FPGA guys started similarly and decided to never incur the switching costs.

    Personally I never cared for the upside tree structure for the procedures (main at the bottom of the source file). Thus far I have managed to successfully avoid ADA.

    Cool about the Adafruit product. I sure hope those guys are getting filthy rich. Love their products, tutorials, and so much more.

    73, Jim

    ReplyDelete
  2. VHDL is indeed very much like Pascal, but for the C language types, take a look at Verilog. VHDL and Verilog are the Ford and Chevy (or 9mm and .45) of the FPGA world. Both are widely used and supported, and both have people who swear by them. At my company we use primarily VHDL, but some Verilog. IMO, the structure required by VHDL helps make sure you write code that can be turned into hardware. Verilog makes it very easy to write code that can't be synthesized.

    FYI, FPGAs are not just for prototypes and stepping-stones on the way to ASICs anymore. Many lower volume products are designed using FPGAs, as there's often no ROI on the costs of making an ASIC unless you are making hundreds of thousands of your end product. FPGAs such as the Spartan 6 from Xilinx or the Cyclone 5 from Altera are amazingly powerful and fairly cheap. Chips like the MachXO2 from Lattice are a hobbyists dream - single power supply, integrated programming memory, super cheap ($10), and they still have high-speed I/O capabilities, PLLs, etc. making them capable of amazing things. The design tools are free for all three chips above as well.

    ReplyDelete
  3. Anon 1243 Thanks for the feedback and bringing up something I meant to. FPGAs are not a stepping stone to ASICs, they ship in millions of commercial products every year. Price is coming down as capabilities are going up.

    There has been some discussion around here about designing a voice scrambler that would take audio out of a microphone, run the open source ham codec on it, and produce encrypted voice that could be used in a handheld radio. I think that's an FPGA with today's capabilities and a few support chips.

    I've never seen Verilog, but since I'm one of the age group that was trained on Pascal (yeah, Jim, Turbo Pascal 3(?) was one of the first things I bought for my first PC - an XT!), and continue to use it even recently (in the form of Delphi - Pascal for Windows), I always thought I'd play with VHDL.

    ReplyDelete
  4. SiGB - You were much braver (or had a greater craving) than me in getting the XT. I waited for the AT series. The decision probably had as much to do with a boatload of Commodore gear than an ability to see the relatively short lifespan of the XT. As I recall there were a fair number of XT adapters than were orphaned; something I know about from Commodore-land.

    Anon 1243 - Oh oh. A $10 FPGA sounds wonderfully attractive. Alas I'm chock full on shiny objects at the moment so I'll wait. Of course nothing says I can't read up on it. Free toolset, yum.

    73, Jim

    ReplyDelete
  5. Here's a couple DigiKey links to the MachXO2 I mentioned above. You will see it listed as a CPLD instead of an FPGA, but if you read about the part, it's really a small FPGA. The on-board flash programming memory allows it to be used as a CPLD.

    This is the middle of the road size in the HC variant which has the on-board voltage regulators to allow single supply operation. I'm linking to a TQFP package instead of one of the BGA packages because these are not too hard to solder yourself with a decent soldering iron. It's possible to solder BGAs using a hot air pencil (nice hobbyist options can be had for less than $200 from Madell), but tricky.
    http://www.digikey.com/product-detail/en/LCMXO2-2000HC-4TG100C/220-1395-ND/2785428

    This is the largest part, also in the HC version and a TQFP. Cost skyrockets all the way up to $14.45, though....

    http://www.digikey.com/product-detail/en/LCMXO2-7000HC-4TG144C/220-1508-ND/2785707

    ReplyDelete
  6. Some FPGA stuff has shown up at Hack A Day of late.

    http://hackaday.com/?s=FPGA

    Anon 1243 - Thanks for the DigiKey info and related datasheets.

    Jim

    ReplyDelete