Thursday 12 November 2015

digital logic - Counting the number of 0's


I am new at digital design and I have a problem. I need to get the number of zeros. There must be 4 inputs and I must use only half-adders. I tried everything I know but I could not solve this. Do you have an idea?



Answer



Phase 1, invert all inputs.



  • That way we can identify zeros as logic 1. and Logic 1 can be quantified easily with a half adder as oppose to logic 0.


Phase 2, Combine half-adders to make a 4-bit adder.




  • Half-Adder can add 2-bits

  • Full-Adder can add 3-bits

  • Hald-Adders + Full-Adders + Ripple Carry can add n-bits




What Half Adder and Full Adder look like enter image description here




How to build an inverter with a half-adder:




  • keep one of the exclusive-or inputs high. Then the exclusive-or gate acts like an inverter


schematic


simulate this circuit – Schematic created using CircuitLab


NOT gate using a single Half-Adder




How to build an or gate with only half-adders, in case you need it to build the full-adder and n-bit adder:


First, build a nand gate using a half adder. Second, build an or gate from nand gates.



  • You can do it by attaching the input of the not gate to the and gate.



schematic


simulate this circuit


NAND gate using 2 half-adders


enter image description here


OR gate using 3 NANDs


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...