10

I have been tasked with building a simple alarm device. It just needs to measure a few inputs and the outputs will respond accordingly (to put it very simply!). To me, it seemed that using a few discrete logic gates would get the job done, but a colleague (who was working on it with me) decided that we should use programmable logic instead. His case won, because firstly, he is more senior than me, and secondly, his main argument was that programmable devices are the future and we want to make future proof products.

My question is if you have a design which could be easily implemented by a few discrete logic gates, is it worth designing with discrete logic any more? IS there any advantage to using them over programmable? Or is it slowly going to be phased out completely by programmable logic? To be clear, I don't want answers of 'I believe this is the case' or 'personally I think this but...' I'd like to know if there are any actual advantages to designing with discrete over programmable and is it worth designing with them these days in consumer electronics products?

Curious
  • 482
  • 6
  • 19
  • 16
    This sounds like a question from the 90s... µC have won, its just so much easier to whack one in and be done than to think about how to connect half a dozen ICs together, let alone the space consumption. – PlasmaHH Apr 06 '18 at 08:01
  • 9
    Discrete gates have one big advantage. No toolchain. – jonk Apr 06 '18 at 08:03
  • No toolchain? What do you mean @jonk – Curious Apr 06 '18 at 08:27
  • @PlasmaHH so basically you're saying there is no advantage to designing discrete in the future? – Curious Apr 06 '18 at 08:28
  • 11
    What @jonk means is, when a microcontroller is used, you need software to create the program for the microcontroller, like an IDE (graphical or textual user interface) and compiler/linker/other tools combination dedicated for the microcontroller you use, called a tool chain. – Michel Keijzers Apr 06 '18 at 08:35
  • @Curious: to get a job done? nope. niche uses like glue logic maybe – PlasmaHH Apr 06 '18 at 08:36
  • @PlasmaHH so you reckon the future of discrete logic design is dead? – Curious Apr 06 '18 at 08:45
  • I suppose one of the best uses for them long term in that case then would be in schools and colleges when people are first learning how logic works! – Curious Apr 06 '18 at 08:54
  • @Curious: pretty much. look around in how much modern devices you find them. as said, there are niche uses and they can be glue logic, but thats about it – PlasmaHH Apr 06 '18 at 08:54
  • Hmm, my father built an alarm system some 20 years ago, I'm sure with the simplest components possible. Unfortunately I don't think I can find the schematics. – akostadinov Apr 06 '18 at 09:03
  • The person who downvoted this.... what was wrong with the question? – Curious Apr 09 '18 at 08:25

6 Answers6

14

I'm not a professional electronics engineer at all (actually just a beginner), but my few cents are that dedicated discrete logic ICs should only be used if timing is important or if it is a requirement not to use programmable logic.

With a microcontroller you can implement much more complicated logic and it is more flexible. Also it can be reprogrammed without having to change the hardware.

Also when very fast timings are needed that software cannot keep up with, dedicated logic ICs could be used. But for an alarm system this seems unneeded (it does not need a response time of nanoseconds).

Below is my interpretation of the advantages/disadvantages:

                          Discrete logic (ICs)      Programmable logic/
                                                    (Microcontrollers)
 Nanosecond speed                  x                         -
 Just a few 'operators' needed     x                         -
 No tool chain needed              x                         -
 Cost Efficiency *                 -                         x
 PCB / proto size                  -                         x
 Flexibility for changing          -                         x
 Production cost                   -                         x
 Possibility to extend features    -                         x

* Assuming more than a few (different) logic functions needed
psmears
  • 678
  • 4
  • 6
Michel Keijzers
  • 13,867
  • 18
  • 69
  • 139
  • 1
    So speed is the main advantage in your opinion? +1 for the answer, I especially like your table! – Curious Apr 06 '18 at 08:29
  • 1
    Yes, hardware is faster than software, so if you REALLY need the speed, you need hardware ICs, otherwise I would go for 'software' (microcontroller) solutions. Btw, nowadays for more complicated speed sensitive solutions FPGAs are used. – Michel Keijzers Apr 06 '18 at 08:32
  • What are the advantages of FPGAs over discrete then? If they are speedy? – Curious Apr 06 '18 at 08:44
  • @Curious I don't have any experience with FPGAs, but hardware is faster than FGPAs (but FPGAs are faster than microcontrollers, in general). FPGAs are dedicated for specifically pre-programmed but programmable logic), like in video/audio processors. For an alarm system, you don't need a FPGA. – Michel Keijzers Apr 06 '18 at 08:47
  • 1
    I wasn't planning on using an FPGA, the head engineer has already decided the hardware now! I was just asking the question out of curiosity to see where any advantage lies. By the way, I will be accepting your answer in time if no other answers come up. Just want to give others a chance to answer before accepting prematurely! – Curious Apr 06 '18 at 08:53
  • 5
    I think your head engineer made the right decisions. An alarm system is typically something that will be extended (getting more inputs from mutliple sources and act on it), even making combinations of them, and later add functionality like sending an automatic SMS, signalling a beeper/alarm signal, maybe some logging of sensors etc. – Michel Keijzers Apr 06 '18 at 08:55
  • 1
    @Curious You can picture an FPGA as a huge array of programmable discrete logic. Because it's all on one piece of silicon, it can run much faster than individual chips. The big piece of info that answers have skimmed over is that discrete/FPGA execute in parallel and can be designed to burn area and power for one purpose only, whereas processors are sequential and general purpose. – awjlogan Apr 06 '18 at 10:12
  • 1
    @Curious just note that it is not "speed", but "nanosecond speed". A uC reacts in microseconds (at most some hundreds of microseconds). Since your alarm will need to react in milliseconds, there is plenty of time for both. – frarugi87 Apr 06 '18 at 10:21
  • 1
    Moreover please consider that "Flexibility for changing" does not mean only change because I don't like it; if you have a "bouncy" button as input, you will need some HW filtering (low pass filter, flip-flop, ...) in your case, or just a SW debounce with the uC. Change schematic+change layout+make new samples VS. copy-paste the code for the debounce from a website+fix bugs... – frarugi87 Apr 06 '18 at 10:27
  • No mention of power consumption? – supercat Apr 06 '18 at 22:55
  • 2
    @MichelKeijzers modern FPGAs are significantly faster than anything that you could accomplish with traditional discrete logic ICs. – Tustique Apr 07 '18 at 00:39
  • @user38168 I didn't know that .. I would assume electronics is always faster, however, maybe the small distances inside an FPGA makes it faster than 'oldschool' ICs. – Michel Keijzers Apr 07 '18 at 18:59
  • @MichelKeijzers The main factor is the much lower capacitance at the gates within a single IC. Distance is of less importance at lower \$f\$ but of increasing importance as \$f\$ increases. The synthesis tool can rearrange inside in the FPGA to minimise distances (i.e. increase the timing slack) to an extent. – awjlogan Apr 09 '18 at 09:48
  • 1
    @MichelKeijzers that's correct. We're now at the point where the speed of light is our primary limiting factor, and decreasing the distances is one way to improve speed. – Tustique Apr 10 '18 at 03:09
  • @user38168 Thanks and sounds logical too (hence the less nm-overlays for semiconductor industry to minimize distances, among other advantages). – Michel Keijzers Apr 10 '18 at 08:37
14

Discrete logic design won't be fully phased out. There will always be applications where using a discrete logic IC is preferable. As has been pointed out, speed is a big advantage, although in a lot of applications, the speed difference is just not that important.

When it comes to the design phase, if you design a circuit that only needs to perform 2 or 3 simple logic functions at different points in the circuit, it will be better to use discrete gates, just to save design time on having to also write the program too.

For systems that need to do more complex logic functions, it would be silly to spend all the time working out a truth table, then figuring out which logic gates go where etc when you could just write a small program. Usually, the more inputs mean the more gates required and the longer it takes to design in discrete.

The place where discrete logic really has the advantage though is in learning. When you are first learning about logic design and how gates work etc, that is where getting hands on with actual logic gates and designing different functions with discrete parts is great. Always a good idea to get an understanding of fundamentals. So, because of that, discrete logic is always going to have a place in this world. As for consumer electronics? The future is definitely programmable.

MCG
  • 11,809
  • 4
  • 34
  • 70
  • Simple answer, good points and answers all the questions asked! Thanks! – Curious Apr 06 '18 at 11:57
  • As programmer with an electronics background I would like to state that if you do not work out your truth table, you will spend as much time debugging your program as you will need time to set up your truth table. Your truth table will be nice documentation for your program. – chthon Apr 06 '18 at 14:28
  • Yeah, I do agree, truth tables are always useful to have, I'll edit the answer to make it a bit more relevant to this scenario – MCG Apr 06 '18 at 14:30
  • 1
    The last design I implemented using discrete logic had a timing requirement of "as low as possible" using 5V logic and a comparatively simple program requirement. I could spend a ton of money on a nice shiny FPGAs or just do it the "old school" way. Military spec chips undergo the full voltage swing in picoseconds, will survive the nuclear apocalypse along with the cockroaches, and also happen to cost almost nothing. There will always be a place for discrete logic. – Landak Apr 07 '18 at 14:37
10

If you're going to create a commercial product, you really shouldn't choose a design because "it's programmable" or because a more senior colleague proposed it. Instead you should estimate risks and costs associated with each design, and pick the one with the lowest cost and acceptable risk level. For a start:

  • price of individual components adds to the cost
  • required PCB size and complexity adds to the cost
  • required design effort and tools adds to the cost
  • required testing and certification adds to the cost

  • lack of flexibility (e.g. changes in discrete logic requiring a new PCB) is a risk
  • lack of experience with a particular technology in your team is a risk
  • inability to meet project requirements (e.g. target power consumption) is a risk

If sourcing discrete logic ICs for your particular project is cheaper, your team has experience with such design and you consider the lack of flexibility is not critical, there is no reason not to use discrete logic.

Dmitry Grigoryev
  • 25,576
  • 5
  • 45
  • 106
  • Very true. So you think there is a future for discrete logic then? – Curious Apr 06 '18 at 11:57
  • 4
    @Curious I still see individual BJTs and MOSFETs being used to implement basic logic functions here and there. Discrete logic is a useful abstraction for some simple tasks, so I'm convinced it will not disappear completely. – Dmitry Grigoryev Apr 06 '18 at 12:07
7

One aspect the other answers are forgetting is safety. Discrete logic circuits are way more reliable than much more complex microcontroller designs. I helped building a hydrogen prototype car, all the safety-circuits were designed using discrete logic. Safety and reliability is an aspect you'd might want to consider designing an alarmsystem.

  • 3
    This is not generally true. One could build a horrendously unsafe discrete system and an incredibly safe and robust system on a processor. Your team didn't have the skills to use a processor, but this does not make it inherently unsafe. You can have massive duplication in a processor, which would be impractical in a discrete system. – awjlogan Apr 06 '18 at 11:26
  • 1
    @awjlogan You can do both of those things, but your discrete logic emergency stop is *never* going to fail to activate because an unexpected condition sent another part of it into an infinite loop. Safety-critical systems *must be as simple as possible*. – user253751 Apr 06 '18 at 11:27
  • 1
    @immibis That's bad design and spec, not inherent to a processor. There is always a possibility of failure in a system, discrete, FPGA, or whatever. Agreed that fail safes should be as simple as possible, that doesn't mean they need to be discrete. – awjlogan Apr 06 '18 at 11:30
  • 5
    @immibis Discrete logic becomes less reliable than MCUs past a certain design size due to soldering defects alone. And if discrete logic includes triggers, you end up having exactly the same problem with forbidden system states as you do in software. – Dmitry Grigoryev Apr 06 '18 at 11:51
  • Not sure if I agree with this 100% A lot of 'safety' issues can be down to the design rather than the components used, although it can be the other way round too! It's definitely not a black and white issue. It doesn't exactly answer the question, but it's not bad enough for a downvote! – Curious Apr 06 '18 at 12:00
  • 1
    @Curious Just to be totally correct, it is *always* the design. For safety, you must design knowing the failure rate and source of your components in the critical section. – awjlogan Apr 06 '18 at 12:14
  • 4
    Discrete parts might act more predictable IN case of a fault... – rackandboneman Apr 06 '18 at 12:28
  • 1
    That is, super low level safety circuits; indeed for somewhat more complex circuitry you want to go with a technique other than discrete logic, hehe. As for @awjlogan, it's not a question of skillset, and I find that irrelevant to this subject. – LukeHappyValley Apr 06 '18 at 13:15
  • @LukeHappyValley Skills are absolutely relevant, and it wasn't meant as a criticism (apologies if it came across that way). Safety is *hard*, so if your team is much stronger in hardware you should probably go down that route, and vice versa. – awjlogan Apr 06 '18 at 13:24
  • @LukeHappyValley But yes, at things like e.g. short circuit protection, that should be discrete but there are still plenty of traps in something as "simple" as that... – awjlogan Apr 06 '18 at 13:28
4

I have to admit, whenever I have to do some complex combinatorial logic plus some timers, I don't bother with discrete logic at all but always code a minimal assembler program for an ATtiny (use a PIC if you like those better).

The combinatorial logic is at maximum 20 lines of assembler (several lookup tables). Each software timer adds another 10 lines. Hardware timers even less. You even gain advantage of having an A/D converter, Comparator, PWM generation on board, should you need those.

The only disadvantage is you had to flash this part. Sometimes that's a show-stopper, but it's seldom the case. The big advantage is you need much less space on the board, routing is much simpler, and you can easily change the logic functions if required.


The remaining use-case for separate logic ICs is when things have to work quicker than 1µs.

Janka
  • 13,636
  • 1
  • 19
  • 33
  • A little off topic, but the ATTiny x17/x16 parts have two built in 3-input LUTs. Very handy indeed! – awjlogan Apr 06 '18 at 12:18
4

In the end product - probably not many advantages to discrete logic if we are talking a consumer device. Exceptions would be something that needs to be very rugged against adverse conditions, or very easy to completely characterize (the actual complexity and potential for hidden bugs is much higher with something firmware based), or that you want to be able to build again from very similar parts for decades to come (74xx footprints change very very slowly even if the technology letters change :) ).

Something that you can actually do better with discretes is self-timing, asynchronous logic (completion of one thing immediately triggers another thing). The legitimacy of such designs is a holy war topic. Do not worry, the synchronous people will want to beat you but you just have to take their clock away, they will be nonsensically waiting forever for it.

When it comes to design methodology, I'd say it depends on the preferred style of the designer - a CPLD device that you could literally rewire live ("let's touch that wire to pins until something clicks in"), in a ratsnest view, and under power from a host PC (with simulated sparks when you touch a wire to a pin, preferrably, just for ambience) would certainly be well liked by people preferring discrete logic :)

rackandboneman
  • 3,085
  • 9
  • 13