TECHNOLOGY 

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-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-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 – 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 – 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- Circuit Diagrams
1. Circuit Diagram Basics
What is a Circuit Diagram?
  • A visual representation of an electrical circuit.
  • Uses standard symbols to represent circuit elements (resistors, voltage sources, etc.).
  • Lines represent wires connecting the elements.
Circuit Element Symbols
  • Resistor: Zig-zag line.
  • Voltage Source (e.g., Battery): A long line (positive terminal) and a short line (negative terminal) next to each other. The positive terminal has a voltage that is positive relative to the negative terminal.
Example: Simple Circuit
  • A 9-volt battery connected to a 10,000Ω resistor.
  • Shorthand: 10kΩ means 10,000Ω (k = kilo = thousand).
2. Current Flow
Current Loop
  • Current flows through the entire circuit in a loop.
  • From the power source, through the circuit elements, and back to the source.
Electrical Circuit Definition
  • A set of electrical components connected so that current flows in a loop.
  • If the loop is broken, current will not flow.
Open Circuit
  • A circuit with a break in the loop.
  • No current flows in an open circuit.
Short Circuit
  • A path in a circuit that allows current to flow with little or no resistance, usually unintentionally.
3. Ground
Ground (GND) Definition
  • A reference point in a circuit used to measure other voltages.
  • Considered 0V.
  • Voltages are measured relative to ground (the difference in potential matters).
Practical Implementation
  • In simple DC circuits, the negative terminal of the battery is often considered ground.
Origin of the Term "Ground"
  • Some circuits are physically connected to the earth, providing a 0V reference point.
  • Even in battery-powered devices without an earth connection, a designated 0V point is called ground.
Alternative Diagram Representation
  • Instead of drawing circuits as a loop, ground and voltage source connections can be indicated with specific symbols.
  • Ground Symbol: Series of progressively shorter horizontal lines, typically pointing downwards.
  • Voltage Source Symbol: A line connected to +, and a ground symbol connected to -.
Equivalence of Representations
  • Circuits drawn as a loop or with ground/voltage symbols are functionally equivalent.
  • Only the diagrammatic representation differs.



Picture
Published on
KembaraXtra-Computer Science-Kirchhoff's Voltage Law (KVL)
Core Concept:
  • The sum of all voltages around any closed loop in a circuit must equal zero.
  • This is a fundamental principle for analyzing circuits.
Key Ideas:
  • Voltage Source: Supplies voltage to the circuit (positive voltage).
  • Voltage Drop: Occurs across circuit elements (like resistors) as they "use" the voltage (negative voltage).
  • Closed Loop: A complete path in a circuit that starts and ends at the same point.
How it Works:
  1. Voltage Supplied: The voltage source provides a certain voltage (e.g., 10V).
  2. Voltage Drops Across Elements: As current flows through each element (e.g., resistor), a voltage drop occurs.
  3. Sum to Zero: The sum of the voltage source (positive) and all the voltage drops (negative) around the loop must equal zero.
Example:
  • A circuit with a 10V power supply and three resistors in series (4kΩ, 6kΩ, 10kΩ).
  • Total Resistance: 4kΩ + 6kΩ + 10kΩ = 20kΩ
  • Current (I): Using Ohm's Law (V = IR), I = 10V / 20kΩ = 0.5mA.
  • Voltage Drops:
    • Across 4kΩ resistor: V = (0.5mA) * (4kΩ) = 2V
    • Across 6kΩ resistor: V = (0.5mA) * (6kΩ) = 3V
    • Across 10kΩ resistor: V = (0.5mA) * (10kΩ) = 5V
  • Voltage at Points:
    • VA = 10V (connected to the positive terminal)
    • VD = 0V (connected to the negative terminal/ground)
    • VB = VA - 2V = 8V
    • VC = VB - 3V = 5V
  • KVL Confirmation: 10V (source) - 2V (drop) - 3V (drop) - 5V (drop) = 0V
Series Resistors:
  • Resistors connected along a single path are in series.
  • The total resistance of series resistors is the sum of the individual resistances: Rtotal = R1 + R2 + R3 + ...
Ohm's Law Reminder:
  • V = IR (Voltage = Current * Resistance)
  • I = V/R (Current = Voltage / Resistance)
  • R = V/I (Resistance = Voltage / Current)
Key Takeaways:
  • KVL applies to any closed loop in a circuit, regardless of resistor values.
  • Voltage drops are considered negative voltages in the KVL equation.
  • KVL helps determine unknown voltages and currents in a circuit.



Picture
Published on
KembaraXtra-Computer Science-Building Circuits in the Real World
1. Simple Circuit Example: 9V Battery and 10kΩ Resistor
  • Initial Method: The text starts with a basic circuit (like Figure 3-4) constructed using a 9V battery and a 10kΩ resistor. The example shows connecting the resistor to the battery using alligator clips (Figure 3-12).
    • While functional, this method is not the most efficient or neat.
2. Introduction to Breadboards
  • What is a Breadboard?
    • A breadboard is a prototyping tool used to easily build and test circuits.
    • It allows components to be connected without soldering, clips, or electrical tape.
  • Breadboard Structure (Figure 3-13):
    • Power Rails (Columns): Located along the edges of the breadboard.
      • Typically marked with "+" (positive) and "–" (negative).
      • Often color-coded: Red (+) and Blue/Black (-).
      • All holes in a single power rail column are electrically connected.
      • Used to provide a common voltage source to the circuit (e.g., connecting a battery).
    • Component Rows: Groups of holes arranged in rows.
      • Typically, each row has five holes that are electrically connected.
      • Components are connected by inserting their leads into the same row.
3. Building a Circuit on a Breadboard (Figure 3-14)
  • Simpler Connections: Using a breadboard provides a cleaner and easier way to connect electrical components compared to alligator clips.
  • Example: The text refers to Figure 3-4 circuit being built on a breadboard (Figure 3-14).
  • Optimization: Resistor ends can be placed directly into the power columns for direct connection to the battery voltage.
4. Project #1 (Page 45)
  • Hands-on Learning: The text recommends doing Project #1 to solidify understanding.
  • Hardware Required: Projects involve acquiring hardware (cost and effort are mentioned).
  • Emphasis on Practical Experience: Hands-on experience is emphasized as the best way to learn and understand circuit concepts.



Picture
Published on
KembaraXtra-Computer Science-Light-Emitting Diodes (LEDs)
1. Introduction to LEDs
  • What is an LED? A light-emitting diode is a special type of diode that emits light when current flows through it.
  • Diode Functionality: A diode allows current to flow in only one direction (low resistance) and blocks current in the opposite direction (high resistance).
  • LED Colors: LEDs are available in various colors.
2. LED Circuit Symbol
  • LED Symbol: (You should refer to Figure 3-16 for the actual symbol). It resembles a standard diode symbol with arrows indicating light emission.
3. Current and LEDs
  • Maximum Current: Exceeding the maximum rated current of an LED can damage it. Example: A standard red LED has a maximum current rating of about 25mA.
  • Target Current: Aim for a current slightly below the maximum (e.g., 20mA for a standard red LED) to ensure brightness without damaging the LED. Lower current = less brightness.
  • Current Limiting: A resistor is used in series with the LED to limit the current flowing through it.
4. Forward Voltage (Vf)
  • Definition: Forward voltage is the voltage drop across the LED when current is flowing through it.
  • Typical Vf: A typical red LED has a forward voltage (Vf) of about 2V.
  • Importance: Forward voltage is crucial for calculating the correct resistor value to limit current.
5. Basic LED Circuit Analysis (Refer to Figures 3-17 and 3-18)
  • Components:
    • Battery (Voltage Source)
    • LED (with forward voltage Vf)
    • Resistor (R, to limit current)
  • Kirchhoff's Voltage Law: The sum of the voltage drops across the LED (Vf) and the resistor (VR) equals the battery voltage (Vbattery). Vf + VR = Vbattery.
  • Calculating VR: VR = Vbattery - Vf
  • Ohm's Law: R = V / I, where:
    • R is the resistance of the resistor in ohms (Ω).
    • V is the voltage drop across the resistor (VR) in volts (V).
    • I is the current flowing through the circuit in amperes (A). (Note: 20mA = 0.020A)
6. Example Calculation (Based on the Text)
  • Given:
    • Battery Voltage = 9V
    • LED Forward Voltage (Vf) = 2V
    • Target Current (I) = 20mA = 0.020A
  • Calculations:
i.VR = Vbattery - Vf = 9V - 2V = 7V
ii.R = VR / I = 7V / 0.020A = 350Ω
  • Conclusion: A 350Ω resistor is needed to limit the current to approximately 20mA in this circuit.
Picture
Published on

KembaraXtra-Case Law-Logic with Mechanical Switches

1. Representing Digital Circuits
Digital Representation: In digital circuits, high and low voltages represent 1 and 0, respectively.

2. Mechanical Switches
Definition: A mechanical switch is a circuit element that can be either on or off, acting as a simple digital component.
States:
  - On (Closed): Acts like a copper wire, allowing current to flow freely.
  - Off (Open): Acts like an open circuit, preventing current flow.
Symbol: The switch symbol represents an open circuit when off and a closed circuit when on.
Real-World Examples: Switches come in various forms, including pushbuttons (momentary switches) that are closed only when pressed.

3. Building Logic Gates with Switches
Goal: To construct digital circuits where input and output voltages are predetermined high or low values (1 or 0).
Voltage Levels:
  - Vout ≈ 5V: Logical 1
  - Vout ≈ 0V: Logical 0

4. AND Gate Implementation
Truth Table:

A B Output
0 0 0
0 1 0
1 0 0
1 1 1
Circuit Design: Switches A and B are connected in series.
Functionality:
  - If either switch A or B is off (0), no current flows, and Vout = 0V (logical 0).
  - If both switches A and B are on (1), current flows, and Vout = 5V (logical 1).

5. OR Gate Implementation
Truth Table:

A B Output
0 0 0
0 1 1
1 0 1
1 1 1
Circuit Design: Switches A and B are connected in parallel.
Functionality:
  - If both switches A and B are off (0), no current flows, and Vout = 0V (logical 0).
  - If either switch A or B is on (1), current flows, and Vout = 5V (logical 1).

Picture