TECHNOLOGY 

Published on
KembaraXtra-Computer Science-Sequential Logic Circuits and Memory
1. What are Sequential Logic Circuits?
  • Definition: Digital circuits where the output depends on:
    • The present inputs.
    • The past inputs (history/state of the circuit).
  • Key Feature: Possess "memory" of past events.
2. The Role of Memory
  • Purpose: Stores a record of the circuit's past state.
  • Function: Allows for the storage and retrieval of binary data.
  • Importance: Enables sequential logic.
3. Example: Coin-Operated Vending Machine
  • Inputs: Coin slot, vend button.
  • Behavior: The vend button only works if a coin has already been inserted.
  • Why it's Sequential:
    • The machine "remembers" (stores in memory) whether a coin has been inserted.
    • The output (dispensing an item) depends on both:
      • The present input (vend button press).
      • The past input (coin insertion).
  • Contrast with Combinational Logic: A combinational logic vending machine would require simultaneous coin insertion and button press.
4. Memory Capacity
  • What Memory Stores: Binary data (bits).
  • Units of Measurement:
    • Bits: Basic unit of memory (0 or 1).
    • Bytes: Groups of 8 bits.
  • Modern Devices: Have large memory capacities (e.g., 1 GB = over 8 billion bits).



Picture
Published on
<

KembaraXtra – Computer Science – Unsigned Numbers

1. The Need for Unsigned Numbers

Signed vs. Unsigned:

  • Signed integers (using two's complement) represent both positive and negative numbers.
  • Unsigned integers represent only non-negative numbers (positive and zero).

Why Use Unsigned?

  • When negative values are unnecessary, using signed integers wastes half the representable range.
  • Unsigned integers allow representing larger positive values with the same number of bits.

2. Understanding Unsigned Representation

Interpretation Matters: A binary sequence can represent different values depending on whether it's interpreted as signed or unsigned.

Example (4-bit):

Binary Signed Decimal Unsigned Decimal
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 -8 8
1001 -7 9
1010 -6 10
1011 -5 11
1100 -4 12
1101 -3 13
1110 -2 14
1111 -1 15

Generalization (n-bit unsigned number):

  • Maximum value: (2n) − 1
  • Minimum value: 0
  • Count of unique values: 2n

3. Operations and Interpretation

Adder Circuit's Perspective: The adder circuit performs the same binary addition regardless of whether the numbers are signed or unsigned.

Interpretation is Key: After calculation, the program decides how to interpret the result (signed or unsigned).

Example: Adding 1011 and 0010 results in 1101.

  • Signed: −5 + 2 = −3
  • Unsigned: 11 + 2 = 13

4. Integer Overflow

Carry-out Bit (Unsigned): A carry-out of 1 indicates an integer overflow. The result is too large to be represented with the given number of bits.

Carry-in/Carry-out (Signed):

  • Overflow: Most significant carry-in bit not equal to most significant carry-out bit.
  • No Overflow: Most significant carry-in bit equal to most significant carry-out bit (carry-out can be ignored).

Importance of Overflow Detection: Overflows can lead to incorrect results and unexpected program behavior if not handled properly.

Real-world Example: Pac-Man level 256 glitch is caused by an integer overflow in the level counter.

Picture
Published on
KembaraXtra-Computer Science-Signed Numbers
1. Introduction to Signed Numbers
  • Need for Signed Numbers: Computers represent data as 0s and 1s. A convention is needed to represent negative numbers since "-" isn't a binary digit.
  • Signed Number Definition: A sequence of bits used to represent both positive and negative numbers. The interpretation depends on the bits' values and the chosen system.
2. Signed Magnitude Representation
  • Concept: Assign one bit (usually the most significant bit) to represent the sign. 0 for positive, 1 for negative. Remaining bits represent the magnitude (absolute value).
  • Drawback: Requires extra complexity in hardware design (e.g., adder circuits need modification) to handle the sign bit separately.
3. Two's Complement Representation
  • Definition: The two's complement of a number represents the negative of that number.
  • Calculation:
    1. Flip the bits: Replace every 0 with a 1 and every 1 with a 0 (also known as the one's complement).
    2. Add 1: Add 1 to the result of step 1.
  • Example:
    1. 5 (0101 in 4-bit binary)
    2. Flip bits: 1010
    3. Add 1: 1011. Therefore, -5 is 1011 in two's complement.
  • Reversing the Process: Taking the two's complement of a negative number (in two's complement form) results in the original positive number. two_comp(two_comp(x)) = x
4. Benefits of Two's Complement
  • Simplified Arithmetic: Addition and subtraction operations work directly without needing special handling for negative numbers. Standard adder circuits can be used.
  • Example: 7 + (-3)
    • 7 = 0111
    • -3 = 1101 (two's complement)
    • 0111 + 1101 = 10100
    • Ignore the carry-out bit, the result is 0100, which is 4.
5. Two's Complement Terminology
  • Dual Meaning:
    • Notation: A system for representing positive and negative integers.
    • Operation: A process to negate an integer already in two's complement format.
6. Understanding Two's Complement with Place Values
  • Key Concept: The most significant bit's place value is the negative of its usual positive value. All other place values are positive.
  • Example (4-bit):
    • Bit positions (right to left): 20, 21, 22, 23
    • Place values: 1, 2, 4, -8
  • Example: -3 (1101)
    • (1 * -8) + (1 * 4) + (0 * 2) + (1 * 1) = -8 + 4 + 0 + 1 = -3
7. Range of Values in Two's Complement
  • 4-bit Example:
    • Maximum positive: 7 (0111)
    • Minimum negative: -8 (1000)
    • All possible values illustrated in Table 5-3 of the source material.
  • Generalization for n-bit signed number:
    • Maximum value: (2n-1) - 1
    • Minimum value: -(2n-1)
    • Count of unique values: 2n
  • Example (8-bit):
    • Maximum value: 127
    • Minimum value: -128
    • Count of unique values: 256
Picture
Published on
KembaraXtra-Computer Science-4-Bit Adder
1. Building a 4-Bit Adder
  • Foundation: The 4-bit adder is constructed using a combination of half adders and full adders.
    • A half adder is used for the least significant bit because it doesn't require a carry-in.
    • Full adders are used for all other bits to incorporate the carry-out from the previous stage.
  • Interconnection: The carry-out from each adder stage (full or half) is connected to the carry-in of the next adder stage. This "strings" the adders together.
  • Bit Significance: The adders are arranged with the least significant bit on the right, progressing to the most significant bit on the left. The carry propagates from right to left.
2. How it Works
  1. Input: Two 4-bit binary numbers (A and B) are fed into the adder, bit by bit.
  2. Addition Process:
    • The least significant bits (A0 and B0) are added using the half adder.
    • The sum (S0) is output, and any carry is passed to the next full adder.
    • Subsequent bits (A1, B1, A2, B2, A3, B3) are added by full adders, along with the carry-in from the previous stage.
    • Each full adder generates a sum bit (S1, S2, S3) and a carry-out bit (C2, C3, C4).
  3. Output: The final result is a 4-bit sum (S3 S2 S1 S0) and a final carry-out bit (C4).
3. Ripple Carry Adder
  • Carry Propagation: The carry bit "ripples" through the adder circuit from the least significant bit to the most significant bit.
  • Delay: Each full adder introduces a small delay as the carry bit propagates.
  • Speed Limitation: The "ripple" effect means that adding more bits will increase the delay, making the adder slower.
  • Inaccuracy: Until all carry bits have fully propagated, the circuit output will be inaccurate.
4. Practical Implementation
  • ICs: Pre-built 4-bit adders are available as integrated circuits (ICs) like those in the 7400 series. Using an IC is more efficient than building from individual logic gates.
5. Connection to Computing
  • Mathematical Operations: Logic gates can be combined to perform mathematical operations like addition.
  • Fundamental Computer Operations: Other fundamental computer operations can be implemented using logic gates.
  • Computer Functionality: Computers use simple logic gates working together to perform complex tasks.



Picture
Published on

KembaraXtra – Computer Science – Full Adders

1. Introduction

Problem: Half adders only work for the least significant bits. Subsequent bits require handling a "carry-in" bit from previous additions.

Solution: A "full adder" circuit.

2. Full Adder: Definition

A full adder handles the addition of a single bit (place value) including a carry-in bit (Cin).

3. Full Adder: Symbol

A full adder has three inputs: A, B, and Cin.

A full adder has two outputs: S (Sum) and Cout (Carry-out).

4. Full Adder: Functionality

Inputs:

  • A: First bit to be added.
  • B: Second bit to be added.
  • Cin: Carry-in bit from the previous bit position.

Outputs:

  • S: The sum bit for the current bit position.
  • Cout: The carry-out bit to be used as the carry-in for the next higher bit position.

5. Full Adder: Truth Table

A B Cin S Cout
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

Explanation: This table shows all possible input combinations (A, B, Cin) and the corresponding output values (S, Cout).

6. Full Adder: Implementation

  • Realization: A full adder can be built using two half adders and one OR gate.
  • Half Adder 1 (HA1): Adds A and B, producing a partial sum and a carry-out.
  • Half Adder 2 (HA2): Adds the partial sum from HA1 and Cin, producing the final sum (S).
  • OR Gate: The carry-out from the full adder (Cout) is 1 if either of the half adders produced a carry-out of 1. Therefore, the carry-out outputs of HA1 and HA2 are fed into an OR gate.

7. Encapsulation

Once constructed, the internal details of the full adder become hidden. You only need to understand its inputs (A, B, Cin) and outputs (S, Cout) to use it.

Picture
Published on
KembaraXtra-Computer Science-Binary Addition
Core Concept:
Binary addition follows the same principles as decimal addition, but uses base-2 (only 0 and 1).
Steps for Binary Addition:
  1. Start from the Rightmost Bit (Least Significant Bit): Just like decimal addition, begin with the rightmost column.
  2. Add the Bits in Each Column: Add the two bits in the current column. Remember these rules:
    • 0 + 0 = 0
    • 0 + 1 = 1
    • 1 + 0 = 1
    • 1 + 1 = 10 (which means 0 in the current column and carry-over 1 to the next column on the left)
  3. Handle Carry-Over:
    • If the sum of two bits is "10", write down "0" in the current column and carry-over the "1" to the next column on the left.
    • If there is a carry-over from the previous column, include it when adding the bits in the current column. (You could be adding 1 + 1 + 1, which equals binary 11, resulting in a sum of 1 and a carry-over of 1.)
  4. Repeat for All Columns: Continue adding each column, moving from right to left, until you've added all the bits, including any final carry-over.
  5. Final Carry-Over: If after adding the most significant bits there is still a carry-over, write it down to the left of your result.
Outputs of Binary Addition:
Each binary addition operation produces two key outputs:
  • Sum Bit (S): This is the result of the addition for the current column (either 0 or 1). This is the rightmost digit of the operation.
  • Carry-Out Bit (Cout): This is the bit that is carried over to the next column if the sum of the current column is 2 (binary 10) or greater.
Sanity Check:
To verify your binary addition, you can convert the binary numbers to decimal, perform the addition in decimal, and then convert the decimal result back to binary.
Example:
0010 + 0011 = 0101
  • Rightmost (LSB): 0 + 1 = 1
  • Next Bit: 1 + 1 = 10 (0 with a carry-over of 1)
  • Next Bit: 0 + 0 + 1 (carry-over) = 1
  • Leftmost (MSB): 0 + 0 = 0
Result: 0101
Conversion to Decimal for Verification:
  • 0010 (binary) = 2 (decimal)
  • 0011 (binary) = 3 (decimal)
  • 2 + 3 = 5 (decimal)
  • 0101 (binary) = 5 (decimal) - Confirmed!
Picture
Published on

KembaraXtra – Computer Science – Integrated Circuits

I. Introduction to Integrated Circuits (ICs)

Definition: An integrated circuit (IC), also known as a "chip," contains multiple electronic components (transistors, resistors, etc.) on a single piece of silicon. It is packaged with external pins for electrical connections.

Advantage over Discrete Components:

  • Smaller size
  • Faster operation
  • Lower cost

II. Integrated Circuit Packaging

Dual In-Line Package (DIP): A common IC package with a rectangular shape and two parallel rows of pins. Suitable for breadboard use.

III. Evolution of Logic Circuits

  • Resistor-Transistor Logic (RTL): Early logic circuits built using resistors and transistors.
  • Diode-Transistor Logic (DTL): An improved logic family that uses diodes and transistors.
  • Transistor-Transistor Logic (TTL): A widely used logic family that uses transistors.

IV. The 7400 Series

Description: A popular line of TTL logic circuits introduced in the 1960s, still widely used today. It includes logic gates and other digital components.

  • Operating Voltage (Vcc): Typically 5V.
  • Logical 1 (High): Ideally 5V, but typically registers between 2V and 5V.
  • Logical 0 (Low): Ideally 0V, but is considered low between 0V and 0.8V.

V. Example: The 7432 IC (Quad OR Gate)

  • Function: Contains four independent OR gates.
  • Package: 14-pin DIP.
  • Pin Configuration:
    • Each OR gate uses 3 pins (2 inputs, 1 output).
    • 1 pin for Vcc (positive voltage).
    • 1 pin for Ground (GND).
  • Orientation: A half-circle notch on the package indicates the correct pin orientation.
  • Breadboard Placement: Straddle the gap in the center of the breadboard to avoid accidental connections between opposite pins.

VI. Pinout Diagrams

Definition: A diagram that labels the electrical contacts (pins) of an electronic component.

Purpose: Shows the external connection points of the component. Does not usually document the internal design.

Usage: Use the pinout diagram to identify the function of each pin and connect them appropriately.

VII. Connecting a Single OR Gate in a 7432 IC (Example)

Pin Connection Description
1 Connect to 5V or GND A input of the OR gate (5V = 1, GND = 0)
2 Connect to 5V or GND B input of the OR gate (5V = 1, GND = 0)
3 Expect 5V or GND Output of the OR gate (5V = 1, GND = 0)
7 Connect to Ground (GND) Ground connection for the IC
14 Connect to 5V power source (Vcc) Power supply for the IC

VIII. Common 7400 Series ICs

  • The 7400 series contains hundreds of components, including various logic gates.
  • Pinout diagrams for different 7400 series ICs can be found online.
Published on
KembaraXtra-Case Law-Designing with Logic Gates
Core Idea
  • Complex logical statements/truth tables can be physically implemented using logic gates.
Example: (A AND B) OR C
  1. Logical Statement: IF it is sunny AND warm, OR it is my birthday, THEN I am going to the beach.
  2. Simplified Statement: (A AND B) OR C
  3. Logic Gate Diagram:
    • A and B are inputs to an AND gate.
    • The output of the AND gate and C are inputs to an OR gate.
    • The output of the OR gate is the final output.
  4. Functionality:
    • If both A and B are 1, the AND gate outputs 1.
    • If either the AND gate output or C is 1, the OR gate outputs 1.
Combinational Logic Circuits
  • Definition: A circuit where the output is ONLY a function of the present inputs.
  • Key Feature: A specific set of present inputs always produces the same output.
Sequential Logic (Brief Mention)
  • Definition: The output is a function of both present and past inputs.
·
  • Not covered in detail yet.
Exercise 4-2: (A OR B) AND C
  • Goal: Translate the truth table and logical expression (A OR B) AND C into a logic gate diagram.
  • Steps:
    1. Create a truth table for (A OR B) AND C (refer to Chapter 2, Exercise 2-5 if needed).
    2. Draw a logic gate diagram:
      • A and B are inputs to an OR gate.
      • The output of the OR gate and C are inputs to an AND gate.
      • The output of the AND gate is the final output.
Picture
Published on
KembaraXtra-Computer Science-Logic Gates
Introduction
  • Logic gates are circuit elements that implement logical functions (AND, OR, NOT, etc.).
  • Inputs and outputs are represented by high and low voltages (logical 1 and 0, respectively).
  • Transistors act as electrically controlled switches within logic gates.
Building Logic Gates with Transistors
AND Gate
  • Concept: Use transistors as switches to mimic the AND logic.
  • Implementation:
    • Transistors are connected in series.
    • If both inputs (VA and VB) are high (1), both transistors conduct, and the output (Vout) is high (1).
    • If either VA or VB is low (0), at least one transistor is off, and Vout is low (0).
OR Gate (Exercise)
  • Concept: Implement OR logic using transistors as switches.
  • Implementation: (Refer to Appendix A for a solution)
    • Similar to the mechanical switch OR circuit, but use NPN transistors.
Abstraction and Encapsulation
Logic Gate as a Black Box
  • Shift in Perspective: Treat the entire logic gate as a single circuit element, hiding the transistor-level implementation.
  • Practical Relevance: Logic gates are purchased as pre-packaged components, eliminating the need to build them from transistors in most cases.
  • Standard Symbols: Defined circuit symbols represent different logic gates (see Figure 4-10).
NOT/Inversion
  • Symbol: Represented by a small circle in logic gate symbols.
  • Function: Inverts the input (1 becomes 0, 0 becomes 1).
  • Examples:
    • NOT gate: Simple inversion of a single input.
    • NAND gate: NOT + AND (inverts the output of an AND gate).
    • NOR gate: NOT + OR (inverts the output of an OR gate).
Encapsulation
  • Definition: Hiding the internal details of a component while documenting how to interact with it (inputs and outputs).
  • Purpose:
    • Simplifies usage and allows building upon components without full understanding of implementation.
    • Enables internal improvements without affecting external behavior.
    • Facilitates collaborative work on large projects by isolating components.






Picture
Published on
KembaraXtra-Computer Science-The Amazing Transistor
1. Introduction to Transistors
  • Problem: Mechanical switches are impractical for complex digital circuits because computers need numerous inputs and outputs from one circuit need to feed into another.
  • Solution: Transistors act as electrically controlled electronic switches.
2. What is a Transistor?
  • Definition: A device used to switch or amplify current.
  • Focus: Primarily on the switching capabilities for digital circuits.
  • Significance: The foundation of modern electronics and computing devices.
3. Types of Transistors
  • Two main types:
    • Bipolar Junction Transistors (BJTs)
    • Field-Effect Transistors (FETs)
  • Focus (for simplicity): BJTs
4. Bipolar Junction Transistors (BJTs)
  • Terminals: Base, Collector, Emitter
  • Types:
    • NPN
    • PNP
  • Focus (for explanation): NPN BJTs
5. NPN Transistor Operation
  • Core Principle: Applying a small current at the base allows a larger current to flow from the collector to the emitter.
  • Analogy:
    • Applying current to the base = Turning the switch ON
    • Removing current from the base = Turning the switch OFF
6. Transistor as an Electronic Switch (NPN)
  • Setup: NPN transistor connected with resistors and voltage sources.
  • Components:
    • Vcc: Positive supply voltage applied to the collector (provides power). "cc" stands for "common collector." Standard positive voltage in NPN circuits.
    • Vout: Output voltage to be controlled (High when transistor is ON, Low when transistor is OFF).
    • Vin: Input voltage that electrically controls the switch.
7. How Vin Controls the Switch
  • Vin is LOW (connected to ground):
    • No current flows to the base.
    • Transistor acts like an open circuit between collector and emitter.
    • Vout is LOW.
    • Analogy: The transistor is OFF, like an open (disconnected) switch.
  • Vin is HIGH:
    • Current flows to the base.
    • Transistor conducts current from collector to emitter.
    • Vout is HIGH (effectively connected to Vcc).
    • Analogy: The transistor is ON, like a closed (connected) switch.



Picture