TECHNOLOGY 

Published on
KembaraXtra-Computer Science-Bus Communication
Introduction
  • Explains how the CPU communicates with memory and I/O devices.
  • Focuses on the hardware communication system called a "bus."
What is a Bus?
  • A hardware communication system used by computer components.
  • Early buses were sets of parallel wires, each carrying an electrical signal (a bit).
  • Modern buses can be more complex, but the core principle of data transfer remains.
Three Common Bus Types
  1. Address Bus:
    • Selects the specific memory address the CPU wants to access.
    • The CPU writes the desired memory address onto the address bus.
    • Example: To access address 0x2FE, the CPU writes 0x2FE to the address bus.
  2. Data Bus:
    • Transfers the actual data being read from or written to memory.
    • For writing: The CPU writes the data to the data bus.
    • For reading: The CPU reads the data from the data bus.
    • Example: To write the value 25 to memory, the CPU writes 25 to the data bus.
  3. Control Bus:
    • Manages and coordinates operations across the address and data buses.
    • Carries signals indicating the type of operation (read or write).
    • Indicates the status of an operation.
    • Example: The CPU uses the control bus to signal a "write" operation.
Example: CPU Reading from Memory
  • Scenario: The CPU wants to read the value at memory address 000003F4.
  • Steps:
    1. The CPU writes 000003F4 to the address bus.
    2. The CPU sets a specific signal on the control bus to indicate a "read" operation.
    3. The memory controller (circuit managing memory interactions) receives these signals.
    4. The memory controller retrieves the data stored at address 000003F4 (which is 84 in the example).
    5. The memory controller writes the value 84 to the data bus.
    6. The CPU then reads the value 84 from the data bus.



Picture
Published on
KembaraXtra-Computer Science-Bus Communication
Introduction
  • Explains how the CPU communicates with memory and I/O devices.
  • Focuses on the hardware communication system called a "bus."
What is a Bus?
  • A hardware communication system used by computer components.
  • Early buses were sets of parallel wires, each carrying an electrical signal (a bit).
  • Modern buses can be more complex, but the core principle of data transfer remains.
Three Common Bus Types
  1. Address Bus:
    • Selects the specific memory address the CPU wants to access.
    • The CPU writes the desired memory address onto the address bus.
    • Example: To access address 0x2FE, the CPU writes 0x2FE to the address bus.
  2. Data Bus:
    • Transfers the actual data being read from or written to memory.
    • For writing: The CPU writes the data to the data bus.
    • For reading: The CPU reads the data from the data bus.
    • Example: To write the value 25 to memory, the CPU writes 25 to the data bus.
  3. Control Bus:
    • Manages and coordinates operations across the address and data buses.
    • Carries signals indicating the type of operation (read or write).
    • Indicates the status of an operation.
    • Example: The CPU uses the control bus to signal a "write" operation.
Example: CPU Reading from Memory
  • Scenario: The CPU wants to read the value at memory address 000003F4.
  • Steps:
    1. The CPU writes 000003F4 to the address bus.
    2. The CPU sets a specific signal on the control bus to indicate a "read" operation.
    3. The memory controller (circuit managing memory interactions) receives these signals.
    4. The memory controller retrieves the data stored at address 000003F4 (which is 84 in the example).
    5. The memory controller writes the value 84 to the data bus.
    6. The CPU then reads the value 84 from the data bus.
    • ddress space are mapped to I/O devices.
    • The CPU communicates with the device by reading/writing to its assigned memory address(es).
    • No special CPU instructions are needed for I/O.
  • Port-Mapped I/O (PMIO):
    • Devices are assigned an I/O port (a separate address space from memory).
    • Special CPU instructions are used to access I/O devices via their port numbers.
    • x86 CPUs support both MMIO and PMIO.
  • Device Controllers:
    • I/O ports and MMIO addresses generally refer to a device controller.
    • The controller provides an interface for the CPU to request operations (read/write) on the device.
    • The actual data on the device (e.g., bytes on a hard drive) is not directly mapped into address space.



Picture
Published on
KembaraXtra-Computer Science – CPU (Central Processing Unit)
I. Central Processing Unit (CPU) Fundamentals
A. Role of the CPU
  • Executes program instructions.
  • Enables computers to run diverse software.
  • Implements a specific set of instructions.
B. Types of CPU Instructions
  • Memory Access: Reading and writing data to memory.
  • Arithmetic: Performing calculations (add, subtract, multiply, divide, increment).
  • Logic: Executing logical operations (AND, OR, NOT).
  • Program Flow: Controlling the order of instruction execution (jump, call).
C. Program Execution
  • Programs are sequences of CPU instructions stored in memory.
  • The CPU fetches and executes these instructions in order.
  • Analogy: CPU is the cook, program is the recipe, instructions are the steps.
II. Instruction Set Architectures (ISAs)
A. ISA Definition
  • A family of CPUs that share the same instruction set.
  • Defines how a CPU works.
  • Software built for a specific ISA can run on any CPU implementing that ISA.
B. Prevalent ISAs
  • x86:
    • Dominant in desktops, laptops, and servers.
    • Originated with Intel's 8086 processor.
    • Includes processors from Intel and AMD.
    • Maintains backward compatibility (older software runs on newer CPUs).
    • Generations: 16-bit, 32-bit (IA-32), and 64-bit (x64 or x86-64).
  • ARM:
    • Predominant in mobile devices (smartphones, tablets).
    • Developed by ARM Holdings and licensed to manufacturers.
    • Often used in System-on-Chip (SoC) designs.
    • Known for low power consumption and cost.
    • Versions: 32-bit and 64-bit.
C. Processor Bitness (Word Size)
  • Refers to the number of bits a CPU can process at once.
  • Indicates the size of registers, address bus, and data bus.
  • Examples: 32-bit CPU, 64-bit CPU.
III. CPU Internals
A. Key Components
  • Processor Registers:
    • Internal storage locations for temporary data during processing.
    • Fast access but small capacity.
    • Implemented in the register file using SRAM.
  • Arithmetic Logic Unit (ALU):
    • Performs logical and mathematical operations.
    • Receives operands and an operation code as input.
    • Outputs the result and status.
  • Control Unit:
    • Directs the CPU, coordinating with registers, ALU, and memory.
    • Works in a repeating cycle: fetch, decode, execute.
    • Uses the program counter (PC) to track the memory address of the next instruction.
B. Fetch-Decode-Execute Cycle
  1. Fetch: Retrieve instruction from memory address indicated by the program counter (PC).
  2. Decode: Interpret the instruction.
  3. Execute: Perform the action specified by the instruction, using the ALU and registers as needed.
IV. Performance Enhancements
A. Clock Speed
  • Controls the rate at which the CPU transitions between states.
  • Measured in gigahertz (GHz).
  • Higher clock speed generally means more instructions per second.
  • Limited by heat generation and logic gate speed.
B. Multicore CPUs
  • CPUs with multiple processing units (cores).
  • Each core is an independent processor.
  • Enables parallel execution of instructions.
  • Software must be designed for parallelism to fully utilize multicore CPUs.
C. CPU Cache
  • Small amount of memory within the CPU that stores frequently accessed data.
  • Reduces the need to access main memory.
  • Levels: L1 (fastest, smallest), L2 (slower, larger), L3 (slowest, largest).
  • Can be core-specific (L1) or shared (L2, L3).
V. Key Terms
  • Instruction Set Architecture (ISA): The instruction set that a CPU family uses.
  • x86: A popular ISA used in most desktop computers.
  • ARM: A popular ISA used in most mobile devices.
  • Register: Small, fast storage location within the CPU.
  • ALU (Arithmetic Logic Unit): Performs arithmetic and logical operations.
  • Control Unit: Coordinates CPU operations.
  • Program Counter (PC): Holds the address of the next instruction to execute.
  • Clock Speed: The rate at which a CPU executes instructions (GHz).
  • Multicore: A CPU with multiple processing cores.
  • Cache: Small, fast memory within the CPU for frequently accessed data. L1, L2, and L3 are different levels of cache.



Picture
Published on

KembaraXtra-Computer Science - Main Memory

1. Purpose of Main Memory
• Stores program instructions and data needed for execution.
• Example: Word processor program, document content, editing state.
• Stores data as bits (1s and 0s) that the CPU can access.

2. Types of Memory
• SRAM (Static Random Access Memory):
- Uses flip-flops to store bits.
- Static: Retains data as long as power is supplied.
- Faster, more expensive.
- Used in cache memory (where speed is critical).

• DRAM (Dynamic Random Access Memory):
- Uses a transistor and capacitor to store bits.
- Dynamic: Capacitor charge leaks, so data must be periodically refreshed (rewritten).
- Slower, less expensive.
- Commonly used for main memory.

3. Memory Organization
• Internally organized as grids of memory cells (each storing 1 bit).
• Cells are accessed using two-dimensional coordinates.
• Multiple grids are accessed in parallel to read/write multiple bits at once (e.g., a byte).

4. Memory Addresses
• Memory Address: A numeric value that identifies a specific location in memory.
• Byte-Addressable: Each memory address refers to 8 bits (1 byte) of data.

5. Example: 64KB Memory System
• Memory Size: 64KB (64 x 1024 = 65,536 bytes).
• Address Range: 0 to 65,535 (0x0000 to 0xFFFF in hexadecimal).
• Address Representation: Binary numbers.

• Calculating Bits Required for Addressing:
- 2^n = number of unique addresses
- n = log₂(number of unique addresses)
- For 65,536 bytes: log₂(65,536) = 16 bits.
- Alternatively: 0xFFFF (hex) = 4 hex characters × 4 bits/character = 16 bits.
• Significance of Number of Bits: Limits the maximum amount of memory the computer can access.

6. Memory Layout Example
• Memory addresses (in binary or hex) are associated with data bytes.
• Example: Storing the ASCII string "Hello" starting at address 0x0002:

Memory Address   Data Byte (Hex)   Data as ASCII
0000             00
0001             00
0002             48                H
0003             65                e
0004             6C                l
0005             6C                l
0006             6F                o
0007             00                (Null Term.)

• Null Terminator: Some languages use a null terminator (byte equal to 0) to mark the end of a string.

7. Memory Inspection Tools
• Display memory contents in hexadecimal format.
• Show a memory address followed by 16 bytes of data at that address and the subsequent 15 addresses.

8. Modern Memory Sizes
• Modern devices have much larger memories (GBs).
• Example: Smartphones (1GB+), Laptops (4GB+).

9. Practice: Calculating Bits for 4GB Memory
• 4GB = 4 × 2³⁰ bytes = 2² × 2³⁰ = 2³² bytes
• log₂(2³²) = 32 bits required to address 4GB of memory.

Published on
KembaraXtra-Case Law-Computer Hardware Overview
I. The Essence of a Computer: Programmability
  • Limitation of Hardware-Defined Features: Hard-wiring features into a circuit's design restricts innovation and modification after manufacturing.
  • Programmability as a Key Differentiator: Computers can perform new tasks without hardware changes by accepting and executing instructions (a program).
  • Hardware vs. Software:
    • Hardware: Physical components of a computer (covered in this chapter).
    • Software: Instructions that tell the computer what to do (covered in the next chapter).
  • The ability to run software is what makes a computer a general-purpose device, instead of a fixed-purpose device
II. Minimum Hardware Requirements for a General-Purpose Computer
  1. Memory:
    • Main Memory (RAM): The primary memory used in a computer.
    • Volatility: Data is retained only while the computer is powered.
    • Random Access: Any memory location can be accessed in roughly the same amount of time.
    • A conceptual extension of simple memory devices like latches and flip-flops.
  2. Central Processing Unit (CPU):
    • Also called a processor.
    • Executes instructions specified in software.
    • Can directly access main memory.
    • Microprocessors: CPUs on a single integrated circuit (lower cost, improved reliability, increased performance).
    • A conceptual extension of digital logic circuits.
III. Input/Output (I/O) Devices
  • Necessity: Required for computers to interact with the outside world.
  • Function: Facilitate communication into the computer (input) and out of the computer (output).
  • Examples: Not explicitly mentioned in the provided text, but think of things like keyboards, mice, monitors, printers, network interfaces, etc.
Picture
Published on

KembaraXtra-Case Law-3-Bit Counter

Core Concept

  • A 3-bit counter is a digital circuit that counts from 0 to 7 in binary.
  • It consists of three memory elements (flip-flops), each representing a bit.
  • A clock signal synchronizes state changes (increments) of these bits.

Binary Counting Review

Table 6-5: Shows the decimal equivalents of 3-bit binary numbers.

Binary Decimal
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7

Memory Element Assignment

  • Table 6-6: Assigns each bit of the 3-bit number to a memory element (Q0, Q1, Q2).
  • Q0 = Least Significant Bit (LSB)
  • Q2 = Most Significant Bit (MSB)
All 3 bits Q2 Q1 Q0 Decimal
000 0 0 0 0
001 0 0 1 1
010 0 1 0 2
011 0 1 1 3
100 1 0 0 4
101 1 0 1 5
110 1 1 0 6
111 1 1 1 7

Pattern Recognition

  • Q0: Toggles (changes state) on every clock pulse.
  • Q1: Toggles when Q0 was previously 1 (high).
  • Q2: Toggles when both Q1 and Q0 were previously 1 (high).
  • General Rule: Each bit (except Q0) toggles when all preceding bits are 1.

Implementation with T Flip-Flops

  • T flip-flops are ideal for building the counter due to their toggling behavior.
  • Figure 6-15: Illustrates the 3-bit counter circuit.
  • All flip-flops share the same clock signal for synchronization.
  • T0 is connected to 5V, ensuring Q0 toggles with each clock pulse.
  • T1 is connected to Q0, so Q1 toggles when Q0 is high.
  • T2 is connected to Q0 AND Q1, so Q2 toggles when both Q0 and Q1 are high.

Applications

  • Counters can be used in vending machines to track the number of coins inserted.
  • Up/Down counters (like the 74191 IC) can both increment and decrement the count.

Key Takeaway

  • Complex digital systems (like counters) can be built from simpler components (transistors, logic gates, flip-flops) through a process of encapsulation, hiding internal details and complexity.
Picture
Published on

KembaraXtra-Case Law-T Flip-Flop

Concept:

  • A T flip-flop is derived from a JK flip-flop.
  • It simplifies operation by connecting the J and K inputs together, treating them as a single input (T).
  • The T flip-flop either toggles its output (Q) or maintains its current value based on the T input and the clock pulse.

Functionality:

  • T = 0: On a clock pulse, the flip-flop holds its current value. Q(t+1) = Q(t). No change occurs.
  • T = 1: On a clock pulse, the flip-flop toggles its output. Q(t+1) = NOT Q(t). The output inverts.

Truth Table:

T Clock Q(t+1) Operation
0 Pulse Q(t) Hold (Maintain)
1 Pulse NOT Q(t) Toggle (Invert)

Key Points:

  • The "T" in T flip-flop stands for "Toggle".
  • The clock pulse is essential for the T flip-flop to change state (either toggle or hold). The value of T only determines what happens when the clock pulse occurs.
  • T flip-flops are useful for building counters and frequency dividers because of their toggling behavior.
Picture
Published on

KembaraXtra-Computer Science - JK Flip-Flop

1. Flip-Flops vs. Latches

  • Flip-Flop: A 1-bit memory device that uses a clock to control state changes.
  • Latch: A memory device without a clock. Changes state immediately based on input.
  • Important Note: Terminology can be inconsistent. This guide uses the definitions above.

2. JK Flip-Flop Overview

  • Purpose: A clocked 1-bit memory element.
  • Analogy to SR Latch:
    • J input acts like S (Set).
    • K input acts like R (Reset).
  • Key Differences from SR Latch:
    • i. Clocked Operation: State changes only occur with a clock pulse.
    • ii. Toggle Functionality: When both J and K are high (1), the output toggles (inverts) its state on each clock pulse.

3. JK Flip-Flop Functionality Table

J K Clock Q (Output) Operation
0 0 Pulse Maintain previous value Hold
0 1 Pulse 0 Reset
1 0 Pulse 1 Set
1 1 Pulse Inverse of previous value Toggle (Invert)

Understanding the Table: The output Q changes only on the active edge of the clock pulse, and only if J or K (or both) are high.

4. JK Flip-Flop Symbols

  • Positive Edge-Triggered: Changes state on the rising edge of the clock pulse.
  • Negative Edge-Triggered: Changes state on the falling edge of the clock pulse. Indicated by a circle on the clock (CLK) input.

5. Key Concepts to Remember

  • Clocked Operation: The flip-flop only responds to inputs J and K when a clock pulse occurs.
  • Edge-Triggering: Changes happen on a specific edge (rising or falling) of the clock pulse.
  • Toggle: J=1, K=1 inverts the output with each clock pulse.
Picture
Published on
KembaraXtra-Computer Science-SR Latch in a Vending Machine Circuit
I. Vending Machine Circuit with SR Latch
A. Requirements
  1. Inputs:
    • COIN button: Simulates coin insertion.
    • VEND button: Initiates vending.
  2. Outputs:
    • COIN LED: Indicates coin insertion.
    • VEND LED: Indicates item vending.
  3. Functionality:
    • Vending only occurs after coin insertion.
    • Only one coin insertion is considered.
    • Manual reset initially (later automatic).
B. Conceptual Implementation (Figure 6-7)
  1. COIN Button:
    • Sets the SR latch (COIN memory device).
    • COIN LED turns on.
  2. VEND Button:
    • AND gate: Requires both COIN (latch output = 1) and VEND button press.
    • If both conditions are met:
      • VEND LED turns on.
    • If no coin was inserted: nothing happens.
  3. Reset:
    • Manual reset required to clear COIN LED and reset the latch.
C. Automatic Reset Implementation (Figure 6-8)
  1. Connects the AND gate output (VEND signal) to the Reset input of the SR latch.
  2. Intended behavior: Vending resets the coin memory.
  3. Problem: Reset happens too quickly. VEND LED barely turns on (or not at all).
D. Automatic Delayed Reset (Figure 6-9)
  1. Problem: UI needs time for the user to see the action that has been performed
  2. Solution: Introduce a delay on the reset line.
  3. Implementation: Use a capacitor and resistor on the reset line.
II. Capacitors for Delay
A. Capacitor Basics
  1. Definition: An electrical component that stores energy.
  2. Terminals: Two terminals.
  3. Charging: Current flow charges the capacitor.
  4. Capacitance:
    • Measure of charge storage ability.
    • Unit: Farad (F). Commonly measured in microfarads (μF).
B. Capacitor Behavior
  1. Uncharged: Acts like a short circuit.
  2. Charged: Acts like an open circuit.
C. Delay Control
  1. Factors: Capacitance (C) and Resistance (R) in the circuit.
  2. Effect: Larger C and R = longer charging time = longer delay.



Picture
Published on

KembaraXtra-Case Law - The SR Latch

Definition

A latch is a basic memory element that stores one bit of data.

SR Latch Specifics

Inputs:

  • S (Set): When activated (set to 1), forces the output Q to 1.
  • R (Reset): When activated (set to 1), forces the output Q to 0.

Outputs:

  • Q: The main output, representing the stored bit.
  • Q̅: The inverse of Q. If Q is 1, then Q̅ is 0, and vice versa.

Behavior: Remembers the previous input state, acting as memory.

Truth Table (Operation of SR Latch)

S R Q (Output) Operation
0 0 Maintain prev. value Hold
0 1 0 Reset
1 0 1 Set
1 1 X (undefined) Invalid (Don't Use)

Explanation:

  • Hold (0,0): The latch maintains its previous state.
  • Reset (0,1): The latch output Q is set to 0.
  • Set (1,0): The latch output Q is set to 1.
  • Invalid (1,1): Avoid this input combination, as the output is unpredictable.

Operation of NOR Gate

A NOR gate outputs 1 only when both inputs are 0. Otherwise, it outputs 0.

1. Initial State (S=0, R=1):

  • R = 1 forces the output of NOR gate N2 (Q) to 0.
  • Q = 0 is fed back into NOR gate N1.
  • Since S = 0 and the other input to N1 is 0, the output Q becomes 1.
  • The latch is in the reset state.
  • [See Figure 6-3 in the original document]

2. Clear Inputs (S=0, R=0):

  • R goes to 0.
  • The output of N2 (Q) remains 0 because the other input to N1 is still 1.
  • The latch remembers its previous state (reset).
  • [See Figure 6-4 in the original document]

3. Activate S Input (S=1, R=0):

  • S goes to 1.
  • This forces the output of N1 (Q) to 0.
  • Now, both inputs to N2 are 0, so the output of N2 (Q) becomes 1.
  • The latch is now in the set state.
  • [See Figure 6-5 in the original document]

4. Clear Inputs Again (S=0, R=0):

  • S goes to 0.
  • Q remains 1 because the other input to N1 is still 1.
  • The latch remembers its previous state (set).
  • [See Figure 6-6 in the original document]

Pulses

  • The S and R inputs typically need to be pulsed rather than held high for a long period.
  • This means quickly setting the input high and then back to low.
  • When the circuit is at rest, both S and R are low.
  • To change its state, just need to quickly set it high and then back to low—a simple pulse of the input.

Universal Logic Gates

  • NOR gates (and NAND gates) are known as universal logic gates.
  • This means that any other logic circuit can be created using only NOR gates (or only NAND gates).

Encapsulation

  • The SR latch can be treated as a "black box" once its internal design is understood. This simplifies its use in larger circuits.
  • Encapsulation allows us to focus on the function of the SR latch (1-bit memory) rather than its internal workings.
Picture