Unit 1: Number systems and logic gates
Digital Circuits & Logic Design notes · PTU syllabus (BSIT204/BSBC303)
On this page
Unit summary
Digital systems represent everything with two states and process it with logic gates. This unit covers decimal, binary, octal and hexadecimal number systems and conversions, 1's and 2's complement, the AND, OR, NOT, NAND, NOR, XOR and XNOR gates, NAND and NOR as universal gates, and applications of logic gates.
After this unit you can
- Convert between number systems
- Represent negative numbers with 1's and 2's complement
- Explain the operation of logic gates with truth tables
- Realise any gate with NAND or NOR gates
PTU syllabus topics
- Decimal/binary/octal/hexadecimal number systems
- conversions
- 1's and 2's complement
- AND/OR/NOT/NAND/NOR/XOR/XNOR gates
- NAND and NOR as universal gates
- logic gate applications
AND
1
0
OR
1
1
NAND
0
1
NOR
0
0
XOR
0
1
Topic 1
Number systems and conversions
| System | Base | Digits |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0–7 |
| Decimal | 10 | 0–9 |
| Hexadecimal | 16 | 0–9, A–F |
Decimal to binary
Divide by 2 repeatedly; read remainders bottom-up
Binary to decimal
Multiply each bit by 2^position and add
Binary to octal
Group bits in threes from the right
Binary to hexadecimal
Group bits in fours from the right
Example
(25)₁₀ = (11001)₂ = (31)₈ = (19)₁₆.
Topic 2
1's and 2's complement
1's complement
Invert every bit
2's complement
1's complement + 1
Subtraction using 2's complement
A − B = A + (2's complement of B); discard the final carry
Example
9 − 5 in 4 bits: 5 = 0101; 2's complement = 1011; 1001 + 1011 = 1 0100 → discard carry → 0100 = 4.
- Signed numbers: in 2's complement, an n-bit number ranges from −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1 (−128 to 127 for 8 bits); only one representation of zero.
Topic 3
Logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR
A logic gate is an electronic circuit with one or more binary inputs and one binary output. The output depends only on the current inputs.
| Gate | Expression | Output is 1 when… |
|---|---|---|
| AND | Y = A·B | all inputs are 1 |
| OR | Y = A + B | at least one input is 1 |
| NOT | Y = A' | the input is 0 (it inverts) |
| NAND | Y = (A·B)' | not all inputs are 1 |
| NOR | Y = (A + B)' | all inputs are 0 |
| XOR | Y = A ⊕ B = A'B + AB' | the inputs are different |
| XNOR | Y = (A ⊕ B)' = AB + A'B' | the inputs are the same |
AND
0
1
OR
1
1
NAND
1
0
NOR
0
0
XOR
1
0
XNOR
0
1
Exam tip
For any gate question, give three things: the symbol, the Boolean expression and the truth table.
Topic 4
NAND and NOR as universal gates
NAND and NOR are called universal gates because any Boolean function — and therefore any digital circuit — can be built using only NAND gates or only NOR gates. This simplifies manufacturing, since one type of gate can be mass-produced.
| To build | Using only NAND | Using only NOR |
|---|---|---|
| NOT | Join both inputs: (A·A)' = A' | Join both inputs: (A + A)' = A' |
| AND | NAND followed by a NAND-inverter | Invert each input, then NOR: (A' + B')' = AB |
| OR | Invert each input, then NAND: (A'·B')' = A + B | NOR followed by a NOR-inverter |
Example
Using De Morgan's law, (A'·B')' = A + B, which is why a NAND gate with inverted inputs behaves as an OR gate.
Topic 5
Applications of logic gates
- XOR: parity generators and checkers, adders, comparators, encryption.
- AND/OR: enabling and combining signals, alarm and control logic (a car alarm sounds if door open AND ignition on).
- NOT: inverters, clock generation.
- NAND/NOR: building all digital circuits; memory latches.
Key terms
- Bit
- Binary digit, 0 or 1
- 2's complement
- Representation of negative binary numbers
- Truth table
- Table of outputs for all input combinations
- Universal gate
- Gate that can implement any Boolean function
- XOR
- Gate giving 1 when inputs differ
Quick revision
- Binary, octal, decimal, hex conversions.
- 1's and 2's complement; subtraction; signed range.
- Seven gates, symbols, truth tables, expressions.
- NAND and NOR as universal gates.
- Gate applications.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Convert (10110)₂ to decimal and hexadecimal.
- Q2.Find the 2's complement of 01101.
- Q3.Draw the truth table of XOR.
- Q4.Why are NAND and NOR called universal gates?
- Q5.Realise an OR gate using NAND gates.
- Q6.Give one application of XOR.
Long-answer questions
- Q1.Explain number systems and conversions with examples.
- Q2.Explain 1's and 2's complement and binary subtraction.
- Q3.Explain all logic gates with symbols and truth tables.
- Q4.Show how NAND and NOR gates realise basic gates.
Stuck on this unit?
Message SBS on WhatsApp for help with Digital Circuits & Logic Design, or to ask about studying B.Sc IT at Synetic.
