⚡ TechVani: AI, Technology, Apps, Coding & Digital World
TechVaniAI • Technology • Apps • Coding • Digital World
HomeAI & TechAppsCodingFree AI ToolsStudent TechSecurityAboutContactPrivacy
TECHVANI // LEARN. BUILD. TEST.

Learn the tech. Build the idea.

Clear study notes, tested lab files and practical guides for coding, AI and digital safety.

Explore Latest →
šŸ¤– AI & TechAI news, tools & guides šŸ“± Apps & ToolsUseful apps & websites šŸ’» CodingProgramming & web development šŸŽ“ Student TechStudy & career technology šŸ” Cyber SecuritySafety & awareness

Latest Posts

Circuit Notebook theme

Exam Notes

šŸ“š BTech CSE Exam Notes

Find Semester 1-8 subjects in one place. Choose a semester and open the notes you need. This is a general study guide, not an official syllabus.

Open Exam Notes →🧪 Open Lab Files →

Exam Numericals & Study Series

Practice CPU scheduling and explore OS and DBMS topics in separate, easy-to-follow parts. New topics will appear in the hub as they are published.

Open Numericals Hub →

Start here and stay in touch

New to TechVani? Start with our free AI tools guide for students. It covers which tools to try and what to check before relying on an answer.

For step-by-step videos, visit SiteSudhar on YouTube.

Join TechVani on WhatsApp

Get new AI tools and coding guides in your WhatsApp Updates tab.

Browse Topics

Popular Posts

TechVani

Digital Electronics | Semester 4 Core Notes

Semester 4 - Page 5: Digital Electronics. 29 numbered topics, highlighted rules, worked examples, answered exam questions, diagrams, truth/state tables and three complete Python 3 logic simulations. General common-core guide, not an official syllabus or hardware wiring instruction. Device details must come from the exact datasheet and your supervised lab rules.

Logical correctness is only one layer: width, signedness, voltage limits, reset and timing assumptions must also be stated. The Python programs model ideal discrete logic, not analog voltage, physical propagation, metastability or electrical safety. Run each complete block separately; no external packages are required.

Topic map

  1. Digital abstraction and real voltages
  2. Number systems and base conversion
  3. Signed representations and overflow
  4. BCD, Gray and error-detecting codes
  5. Logic gates and universal gates
  6. Boolean algebra and De Morgan laws
  7. SOP, POS and canonical forms
  8. Karnaugh maps and don't-cares
  9. Tabular minimization and hazards
  10. Half and full adders
  11. Subtractors and arithmetic blocks
  12. Multiplexers and demultiplexers
  13. Decoders and priority encoders
  14. Comparators, parity and ALU
  15. Latches and flip-flops
  16. JK, T and excitation tables
  17. Setup, hold and metastability
  18. Registers and shift registers
  19. Ripple counters and modulus
  20. Synchronous counters and worked alarm
  21. FSM design, Mealy and Moore
  22. Memories and programmable logic
  23. DAC principles and ideal resolution
  24. ADC architectures and quantization
  25. Sampling, aliases and converter limits
  26. Logic families, fan-out and noise margin
  27. HDL, simulation and synthesis
  28. Lab safety and systematic testing
  29. Exam revision checklist

1. Digital abstraction and real voltages

Digital logic represents values with defined voltage ranges, not magically exact zero and one volts. The logic abstraction hides analog behavior only within the device's specified operating limits.

Worked example: A sensor signal must satisfy the receiver's low/high thresholds; a voltage between them has no guaranteed logic interpretation.
Exam question: Why is a truth table insufficient for wiring hardware?
Answer: Voltage, current, power, timing, pinout and environmental limits still apply.

2. Number systems and base conversion

Binary is base 2, hexadecimal base 16 and octal base 8. One hex digit represents four binary bits; assign place values before converting.

Worked example: 101101 binary=32+8+4+1=45 decimal=2D hex. Group from the radix point, padding only when representation permits.
Exam question: Does leading-zero padding change an unsigned integer?
Answer: No. It changes the written width, not its numerical value.

3. Signed representations and overflow

Unsigned n-bit values range 0..2^n-1; two's-complement values range -2^(n-1)..2^(n-1)-1. Carry-out and signed overflow are different conditions.

Worked example: Four-bit 1111 is unsigned 15 or signed -1. 0111+0001=1000 has signed overflow, although no carry-out.
Exam question: When does signed addition overflow?
Answer: Adding same-sign operands produces an opposite-sign fixed-width result.

4. BCD, Gray and error-detecting codes

BCD encodes each decimal digit in four bits; Gray code changes one bit between adjacent code words. Parity detects any odd number of bit flips but does not generally correct them.

Worked example: Decimal 12 in BCD is 0001 0010, not its binary integer form 1100. Two-bit Gray sequence is 00,01,11,10.
Exam question: Can even parity detect every two-bit error?
Answer: No. Flipping two bits preserves parity.

5. Logic gates and universal gates

AND, OR, NOT, XOR, NAND and NOR define Boolean functions. NAND and NOR can each implement any Boolean function through composition. A truth table for n binary inputs has 2^n rows.

Worked example: NOT A=NAND(A,A); A AND B is an inverted NAND. XOR is one only for unequal two-input bits.
Exam question: Is XOR the same as OR?
Answer: No. OR outputs one for input11; XOR outputs zero.

6. Boolean algebra and De Morgan laws

Boolean identities include idempotence, complement, absorption and distributivity. De Morgan swaps AND/OR while complementing all inputs; draw parentheses before transforming.

Worked example: NOT(A AND B)=(NOT A) OR (NOT B); A OR (A AND B)=A.
Exam question: Why verify a simplified expression with a truth table?
Answer: It confirms equivalence on every finite input combination, not just selected examples.

7. SOP, POS and canonical forms

A minterm is an AND term containing every variable exactly once; a maxterm is an OR term containing every variable. Canonical SOP lists rows where F=1; canonical POS lists rows where F=0.

Worked example: For variables A,B,C with A most significant, minterm5 is A AND NOT B AND C.
Exam question: Must a minimal SOP remain canonical?
Answer: No. Simplification commonly removes variables from product terms.

8. Karnaugh maps and don't-cares

K-maps use Gray-code adjacency; group powers of two, wrap across edges and never group diagonally. Groups remove changing variables. Don't-cares may be chosen to simplify only when those input cases truly are irrelevant.

Worked example: Minterms1,3,5,7 in a three-variable map share C=1, so F=C. The Python block checks all eight combinations.
Exam question: Must every don't-care cell be grouped?
Answer: No. Use it only when helpful; do not change required zero/one cells.
Three-variable K-map: F=sum m(1,3,5,7)
BC columns: 00  01  11  10
A=0          0   1   1   0
A=1          0   1   1   0
Group the four 1s: only C stays 1.
Gray-code columns make adjacent cells differ in one bit. The group simplifies to C.

K-map simplification truth-table check

from itertools import product
# Minterms 1,3,5,7: C is the least-significant input bit.
for a, b, c in product([0, 1], repeat=3):
    index = 4*a + 2*b + c
    original = int(index in {1, 3, 5, 7})
    simplified = c
    assert original == simplified
print("8 rows: F = C verified")
# De Morgan's two identities, all two-input cases.
for a, b in product([0, 1], repeat=2):
    assert int(not (a and b)) == int((not a) or (not b))
    assert int(not (a or b)) == int((not a) and (not b))
print("4 rows: both De Morgan laws verified")

Checked output:

8 rows: F = C verified
4 rows: both De Morgan laws verified

9. Tabular minimization and hazards

Quine-McCluskey combines implicants differing in one bit and selects a covering set. Static hazards can occur when unequal path delays create a brief wrong output even though the Boolean function is correct.

Worked example: F=AB+NOT(A)C can glitch during A's transition when B=C=1; consensus term BC can cover the static-1 hazard under the relevant assumptions.
Exam question: Does minimum gate count guarantee minimum glitches?
Answer: No. Logical minimization and timing/hazard design are different objectives.

10. Half and full adders

A half-adder has sum A XOR B and carry A AND B. A full-adder includes carry-in: sum=A XOR B XOR Cin; carry=AB+A Cin+B Cin. Cascading creates a ripple-carry adder.

Worked example: Inputs1,1,1 total3, represented as carry1 and sum1. The complete program verifies every full-adder row.
Exam question: Why can ripple-carry addition be slow?
Answer: Each stage may wait for the previous stage's carry propagation.

Full-adder truth table

from itertools import product
print("A B Cin | Sum Carry")
for a, b, cin in product([0, 1], repeat=3):
    total = a + b + cin
    s = a ^ b ^ cin
    carry = (a & b) | (a & cin) | (b & cin)
    assert total == s + 2 * carry
    print(a, b, cin, "|", s, carry)

Checked output:

A B Cin | Sum Carry
0 0 0 | 0 0
0 0 1 | 1 0
0 1 0 | 1 0
0 1 1 | 0 1
1 0 0 | 1 0
1 0 1 | 0 1
1 1 0 | 0 1
1 1 1 | 1 1

11. Subtractors and arithmetic blocks

A half-subtractor difference is A XOR B and borrow=NOT A AND B. Fixed-width subtraction can use addition of the two's-complement negation. Carry-lookahead computes carry conditions in parallel groups.

Worked example: Four-bit5-3:0101+1101 gives low bits0010 with carry-out; interpret signedness and borrow convention explicitly.
Exam question: Is carry-out always the borrow bit?
Answer: No. Adder-based subtraction may use an inverted borrow convention; state the circuit's definition.

12. Multiplexers and demultiplexers

A multiplexer selects one of many inputs; a demultiplexer routes one input to a selected output. A 2:1 mux has Y=NOT(S)I0+S I1; n select bits choose up to2^n inputs.

Worked example: S=0 selects I0; S=1 selects I1. A mux can implement a Boolean function by choosing constants or residual expressions on data inputs.
Exam question: Does a mux create memory?
Answer: Not by itself. It is combinational selection.

13. Decoders and priority encoders

A decoder activates an output based on an input code, subject to enables and active-high/low conventions. A priority encoder resolves multiple asserted inputs by a defined ranking.

Worked example: A2-to4 active-high decoder selects exactly one of four outputs for a valid binary input when enabled.
Exam question: Can a plain encoder safely assume only one input is active?
Answer: Only if its stated input contract guarantees that; otherwise a priority rule is needed.

14. Comparators, parity and ALU

A magnitude comparator reports less/equal/greater for the specified representation. Parity uses XOR chains; an ALU chooses arithmetic/logic operations under control inputs.

Worked example: For unsigned1000 versus0111, the first is larger; as four-bit signed values, -8 is smaller than7.
Exam question: Why include signedness in comparator questions?
Answer: The same bit patterns can have different numerical orderings.

15. Latches and flip-flops

A latch is level-sensitive; an edge-triggered flip-flop samples near a specified clock edge. A D element stores its input subject to timing. An SR latch's forbidden condition depends on NAND/NOR and input polarity.

Worked example: For a positive-edge D flip-flop, D=1 around the edge yields Q=1 after clock-to-Q delay; changes between edges do not directly update Q.
Exam question: Are latch and flip-flop interchangeable terms?
Answer: No. Their transparency and sampling behavior differ.

16. JK, T and excitation tables

JK inputs00 hold,01 reset,10 set,11 toggle for the common active-high edge-triggered model. A T flip-flop toggles when T=1. Excitation tables ask which inputs produce a desired state transition.

Worked example: To change Q0to1 with JK, J must be1 and K is don't-care; to change1to0, K must be1 and J is don't-care.
Exam question: How does a characteristic table differ from an excitation table?
Answer: Characteristic maps input/current state to next state; excitation maps desired transition to possible inputs.

17. Setup, hold and metastability

Data must remain stable for specified setup/hold windows around capture. Violations can cause metastability; synchronizers reduce failure probability but cannot make it mathematically zero.

Worked example: An asynchronous button signal crosses into a clock domain through a designed synchronizer; a multi-bit bus may require a handshake/FIFO rather than independent bit synchronizers.
Exam question: Can simulation of ideal logic prove metastability cannot occur?
Answer: No. It needs timing and device-level reasoning.

18. Registers and shift registers

A register stores a group of bits; shift registers transfer bits on clock events. SISO,SIPO,PISO and PIPO describe serial/parallel inputs/outputs, not automatically a specific physical pinout.

Worked example: A four-bit serial-in register shifts one new bit per edge; after four edges it can hold the last four samples under a stated shift convention.
Exam question: Why specify shift direction and insertion end?
Answer: Otherwise the same input stream can produce different displayed bit orders.

19. Ripple counters and modulus

Ripple counters clock successive stages from earlier outputs, so transitions propagate. A counter's modulus is the number of states in its repeating cycle; n bits permit at most2^n states.

Worked example: A two-bit binary counter has modulus4. A modulus10 counter needs at least4 state bits but does not use all16 combinations.
Exam question: Why can decoding a ripple count glitch?
Answer: Outputs do not change simultaneously, so intermediate bit patterns can briefly appear.

20. Synchronous counters and worked alarm

A synchronous counter clocks storage stages together and derives next-state inputs from current state. For two-bit up-counting, D0=NOT Q0 and D1=Q1 XOR Q0; alarm=Q1 AND Q0.

Worked example: 00->01->10->11->00; the stable-state alarm is one only at11. The Python trace uses simultaneous next-state assignment.
Exam question: Does a shared clock eliminate all output delay?
Answer: No. Clock-to-Q, logic delay, skew and timing constraints remain.
[00] -> [01] -> [10] -> [11]
  ^                       |
  +-----------------------+
D0 = NOT Q0
D1 = Q1 XOR Q0
Alarm = Q1 AND Q0
Two-bit up-counter state diagram. All next-state equations use the current state, not partially updated bits.

Two-bit synchronous counter

q1, q0 = 0, 0
print("Q1Q0 Alarm Next")
for _ in range(4):
    d1, d0 = q1 ^ q0, 1 - q0
    print(f"{q1}{q0} {q1 & q0} {d1}{d0}")
    q1, q0 = d1, d0
assert (q1, q0) == (0, 0)

Checked output:

Q1Q0 Alarm Next
00 0 01
01 0 10
10 0 11
11 1 00

21. FSM design, Mealy and Moore

A finite-state machine has state transitions and outputs. Moore outputs depend on state; Mealy outputs depend on state and current inputs. Derive a state table, encoding, next-state logic and reset behavior.

Worked example: A ticket-code detector can use states tracking a suffix; decide whether detection output should depend on the entering input or only the stored state.
Exam question: Is every Mealy output automatically registered?
Answer: No. Combinational dependence on input can affect glitches/timing unless explicitly registered.

22. Memories and programmable logic

RAM and ROM families differ in write behavior, volatility and technology. SRAM and DRAM both normally need power to retain data; DRAM also needs refresh. PLA/PAL/CPLD/FPGA implement programmable logic with different structures.

Worked example: A memory with10 address bits selects1024 locations; eight data bits per location give1024 bytes of addressed storage.
Exam question: Does ROM always mean impossible to rewrite?
Answer: No. PROM,EPROM,EEPROM and flash have different programming/erase rules.

23. DAC principles and ideal resolution

A DAC maps digital code to an analog level. Binary-weighted and R-2R networks are common teaching designs; output range, reference, settling and error specifications matter.

Worked example: For an ideal unipolar8-bit DAC with5V reference and LSB=5/256V, code128 gives2.5V and code255 gives4.98046875V.
Exam question: Why not always use5/255 as the step?
Answer: Transfer conventions differ. State whether full-scale refers to reference or the highest code output.

24. ADC architectures and quantization

An ADC maps sampled analog values to digital codes. Flash uses comparator banks, SAR searches by successive approximation, and dual-slope integrates over time. Ideal n-bit quantization has2^n bins under the stated range convention.

Worked example: An ideal8-bit0..5V range with5/256V bins has step19.53125mV. Ideal nearest-code error is at most half a step away from clipping.
Exam question: Does more resolution guarantee better accuracy?
Answer: No. Noise,offset,gain,linearity and reference errors can dominate.
Analog signal -> filter/sample -> ADC
Digital code -> DAC -> analog output
Converter directions. Sampling and quantization have separate limits; resolution is not the same as accuracy.

25. Sampling, aliases and converter limits

Sampling must account for signal bandwidth and filtering. For a strictly band-limited signal with highest frequency B, sampling above2B supports ideal reconstruction; practical systems need anti-alias filtering and margin.

Worked example: A1kHz tone sampled at a rate too low can appear as a different lower-frequency tone; no extra ADC bits undo aliasing.
Exam question: Is sampling exactly at twice a sinusoid's frequency always safe?
Answer: No. Phase and boundary issues make a strict margin and practical design necessary.

26. Logic families, fan-out and noise margin

Logic families specify voltage/current thresholds, propagation, power and loading. Fan-out depends on both source/sink current limits and dynamic capacitive loading. Noise margins compare guaranteed output levels with required input levels.

Worked example: High-state margin=VOH(min)-VIH(min); low-state margin=VIL(max)-VOL(max). Use the actual compatible datasheets.
Exam question: Can every5V TTL output directly drive any3.3V CMOS input?
Answer: No. Threshold and absolute-maximum limits must both be checked.

27. HDL, simulation and synthesis

A hardware description models concurrent circuits; synthesis supports a subset and maps it into hardware. Testbenches can use simulation-only constructs. Blocking/nonblocking choices and reset rules depend on the HDL and process type.

Worked example: In a clocked Verilog-style process, nonblocking assignments model simultaneous register updates. A delay in a testbench is not automatically synthesizable logic.
Exam question: Does successful simulation prove timing closure?
Answer: No. Synthesis,implementation,timing analysis and hardware checks are separate stages.

28. Lab safety and systematic testing

Read the exact device datasheet for supply,pinout,limits and reset before wiring. Do not leave inputs floating unless explicitly permitted. Simulate function, then measure timing and document actual results safely.

Worked example: Set known reset,step the clock,record stable Q1/Q0 and compare with the state table. Use a scope/logic analyzer for glitches hidden by LEDs.
Exam question: Should an unknown IC be wired from a similar-looking pinout?
Answer: No. Verify its exact part and datasheet; power off before rewiring under lab rules.

29. Exam revision checklist

Start from width/signedness or the truth/state table, derive logic, then address timing and electrical assumptions. Separate combinational functions from stateful behavior and ideal simulations from hardware evidence.

Worked example: For the alarm counter, show next-state equations, four state rows,reset and alarm timing assumptions rather than only naming gates.
Exam question: What is a complete design answer?
Answer: Specification,truth/state table,simplification,circuit or HDL,correctness trace and timing/device limits.

Two-input truth table

ABANDORXORNANDNOR
0000011
0101110
1001110
1111000

Stored-state element comparison

ElementCommon input ruleTiming caution
DNextQ=D at captureSetup/hold around active edge
TToggle if T1;hold if T0Edge behavior follows device
JK00hold,01reset,10set,11toggleModel/polarity must be stated
SR NOR latchActive-high set/resetBoth asserted is forbidden
D latchTransparent while enabledNot edge-triggered

Computed numeric reference

QuantityResultAssumption
101101 binary45 decimal;2D hexUnsigned interpretation
4-bit two's complement-8..7Fixed width4
10 address bits x8 data bits1024 bytesOne8-bit word per address
8-bit converter step0.01953125V5/256V per code/bin
DAC code1282.5VIdeal unipolar5V reference
DAC code2554.98046875VHighest code below reference
3-bit flash comparators7Conventional2^n-1 thresholds

Last-minute design checklist

State input/output conventions, then truth/state table, Boolean simplification, circuit/HDL, reset and timing constraints. Check every finite truth-table row. For physical hardware, confirm exact part number, supply, thresholds, current loading and test procedure separately.

Resources and sources

Teaching references support the common principles. Examples, diagrams and simulations here are original. No named IC or physical build is claimed tested.

Comments