TECHNOLOGY 

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
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