Computer Science - Unit 1 Mod 1
Computer Science - Unit 1 Mod 1
Unit 1 Module 1
Types of Computers
Computers come in different types based on their processing power, size, and purpose.
The most powerful type of
computer, designed for extremely
Supercomput fast calculations and processing
vast amounts of data.
er
Used in scientific research,
weather forecasting, nuclear
simulations, and artificial
intelligence.
Interactive whiteboards
Memory
https://www.youtube.com/watch?v=H_M--weEzpA&t=120s
ROM - is a type of computer storage containing
nonvolatile, permanent data that, normally, can only be
read and not written to. ROM contains the programming
that enables a computer to start up or regenerate each
time it is turned on.
PROM - is ROM that can be modified once by a user. It
enables a user to tailor a microcode program using a
special machine called a PROM programmer.
EPROM is programmable read-only memory PROM that
can be erased and re-used. Erasure is caused by shining
an intense ultraviolet light through a window designed
Types of
into the memory chip.
EEPROM is a user-modifiable ROM that can be erased
and reprogrammed repeatedly through the application
Memory of higher than normal electrical voltage. Unlike EPROM
chips, EEPROMs do not need to be removed from the
computer to be modified.
RAM - The term is based on the fact that any storage
location can be accessed directly by the processor.
Cache Memory This temporary storage area, known as
a cache, is more readily available to the processor than
the computer's main memory source. It is also called
CPU memory because it is typically integrated directly
into the CPU chip or placed on a separate chip with a
bus interconnect with the CPU.
Source:
https://whatis.techtarget.com/definition/memory (read
Speed: RAM frequency works off of clock cycles.
Each read and write is done on a cycle. The
more cycles your RAM can perform per second
translates to how much data can be stored and
read – making for smoother user experiences.
Size: How much memory or RAM should my
computer have? This depends on what you want
to do. Usually the software come with system
Features of requirements. But for today’s standards a min of
4GB and Excellent is 16GB or more.
The access speed of a storage device refers to how quickly data can be read from or
written to it. Measured in Hertz.
The access method of a storage device refers to how the data is retrieved. It is the
technique that is used to store and retrieve data.
There are three different methods which can be used to access (locate) data stored on
a backing storage device. They are direct access, serial access and sequential access.
Direct Access
When direct access is used the
head that reads data from the
storage medium can move
directly to any point on the
storage medium. If a particular
record or file must be loaded or
saved, then the head can move
directly to the record/file's
position on the storage medium
and read the data. Magnetic disks
such as hard disks(HDD) and
floppy disks and optical disks such
as CD-ROMs use the direct access
method.
The storage medium is divided
into fixed blocks or sectors. The
system can jump to a specific
block without reading everything
before it. Still, some mechanical
movement is required.
Random Access
Any memory cell can be accessed directly and instantly, without mechanical
movement.
Data is stored in a way that allows each memory unit to be reached independently.
Each memory unit has its own set of pins, and they are all connected to the CPU.
Examples: RAM (Random Access Memory), SSDs (Solid-State Drives), Cache Memory.
Serial Access
When a serial access medium
is being used, the head that
reads data from the storage
medium has limited freedom
of movement. The only serial
access medium is magnetic
tape.
The tape head can not move
to a particular record/file on
the tape without reading
through all of the other
records that come before it.
Data is stored and accessed
in the order it was written
without any categorization.
Sequential Access
Sequential access is a slight modification of the serial access method. This method is
identical to serial access except that the records are stored on the storage medium in
a particular order, e.g. by customer number.
Sorting the data into an order may speed up operations such as searching the tape.
The sequential access method is usually used by batch processing systems using
multiple tapes.
Data is stored in a specific order and can be read sequentially eg alphabetically.
One way to think about it is a book is written and ordered by chapters and pages.
Indexed Sequential is a book that comes with a table of content that allows you to
go directly to a page/chapter. The TOC is the index. Or some books have an index at
the back. The system maintains an index table that maps key values to storage
locations.
Device
Power
Protectio
n
The biggest risk to the computer system is
electricity (too much or the lack thereof).
What do we use to protect against this risk?
Surge protector - Surge protectors, also known
as surge suppressors, are a device used to
protect against electrical surges. Electrical
surges can have many causes, such as lightning
Device strikes or faulty wiring, and can severely
damage electrical devices connected to the
Power power grid. When a surge is detected, a surge
protector diverts the surge to the ground,
preventing it from reaching the connected
Protection devices.
Voltage regulator - Voltage regulators are
devices used to provide a constant voltage to
any connected electrical devices. If the voltage
given to an electrical device is too high or too
low, it could cause damage. Voltage regulators
help prevent this, adjusting the provided voltage
up or down to keep it at the correct levels.
UPS – Uninterrupted power supply.
PP Questions
Computer
Architectur
e
describe the basic building blocks of a
computer;
Analogue data is a real-life signal that can
vary greatly in value. Examples include:
sound waves
pressure
Analogue temperature
Digital data is binary data which represents
data and analogue data. Computers work with digital
data.
NOT Gate
AND Gate
A binary operation, meaning it only
takes in 2 values at a time, is also
known as a logical conjunction.
Exclusive OR requires
exactly one True and one
False value Table; result
in True.
We have the Truth Table;
Lets build the circuit and
algebraic expression for this
gate.
Conditionality
Digital systems are constructed using logic gates. Gates are switches that produce an
output signal representing either on(1) or off (0) according to a particular logical
operation. Logic gates turn input into output according to Boolean logic.
Simplifying Boolean Logic
The Laws of Boolean Logic
From the Boolean Expression
Derive the Circuit and Truth table
Draw a circuit
from truth
table
https://www.youtube.com/wat
ch?v=ejjCMnmDx0k
Data
Representati
on
Explain how data is represented in a computer system
Bits; bytes; fixed (signed magnitude, ones and twos complement) and
floating point (sign, mantissa and exponent) numbers and character
representation; number systems/bases.
Data
Units
Number Systems
Binary, Octal, Decimal, Hexadecimal, BCD
Number
Systems
Binary Coding schemes represent the
data such as alphabets, digits 0−9,
and symbols in a standard code.
The binary coding schemes that are
Binary most commonly used are:
Extended Binary Coded Decimal
Coding Interchange Code (EBCDIC) – 8bits
Convert each octal digit to the binary equivalent and put it together in order.
728
148
4568
2018
1438
6708
Octal Binary
Separate binary in groups of 1 bits then convert each to the Octal equivalent. Add
leading 0s if necessary.
1000011
110000
10000001
111101
100011
11111
Hexadecimal Binary
What is the - 82
-21
binary Write the 4-bit binary equivalent of:
equivalent? -5
4
-7
Showing all working, find the
largest and smallest integers
that can be represented using
6 bits if signed magnitude is
used.
Past Paper
Questions State the largest positive
integer and the largest
negative integer that can be
stored using eight bits if signed
magnitude is used.
Quick Math
Sign and Advantages: Disadvantag
Magnitude Simple to understand
because it mirrors the
es:
Addition and subtraction are
more complex because the
human understanding of a sign bit must be handled
sign and magnitude. Sign in separately. The sign must be
front and number follows. checked, and different rules
apply for addition vs
subtraction. This makes it
Conversion between positive computationally inefficient.
and negative is
straightforward—just flip the
MSB(most sig. bit). Two representations for zero:
0000 (positive zero) and
1000 (negative zero). This
wastes one of the possible
values in the binary system.
Another way of representing
negative numbers is by using
the Two’s Complement method.
It eliminates the problems of sign
and magnitude.
Two's complement is the most
Two’s widely used method for representing
signed integers in computers.
Complemen It simplifies the arithmetic
operations and makes the
t representation of negative numbers
more efficient.
To find the two's complement of a
binary number:
Invert the bits.(ones complement)
Add 1 to the least significant bit (LSB).
Two’s
Complemen
t
Binary
Addition
Advantages:
• Addition and subtraction work the same
way as with unsigned numbers, and the
sign is handled naturally.
Two’s • Single representation for zero: Zero is
always represented as 0000.
Compleme • It is easier for hardware to handle
calculations. Simpler and faster to
nt implement in digital circuits, which is
why modern computers and processors
use two's complement.
Disadvantages:
• Less intuitive as representing and
reading negative numbers requires
understanding the two's complement
process.
• Conversion can be confusing for
beginners.
Dealing with Real
Numbers
Fixed and Floating Point values.
Fixed Point Binary
https://isaaccomputerscience.org/concepts/data_numbases_fixed_point?examBoard=al
l&stage=a_level
Decimal to Fixed Point Binary Conversion
When dealing with very large or very small numbers, a more flexible technique,
known as floating point representation, can be employed. This allows the way that the
bits are allocated to vary so that both very large and very small numbers can be
represented.
All large/small real numbers can be written in this common and consistent format.
123456.7 = 0.1234567 x 106
0.001234 = 0.1234 x 10-2
1234.567 = 0.1234567 x 104
To convert to binary, we convert the mantissa and
the exponent.
Floating point Numbers
Standard form but in Binary. It has 3 parts the sign, mantissa and the exponent.
Sign Bit: Indicates whether the number is positive (0) or negative (1).
Mantissa: Represents the significant digits of the number.
Exponent: Indicates the scale of the number.
Floating point numbers are stored in twos complement/sign and magnitude.
The standard format for floating-point representation is defined by the IEEE 754
standard, which specifies different formats, including single precision (32 bits) and
double precision (64 bits).
Floating point Numbers
Binary numbers are multiplied and divided through a process called shifting.
Multiplication
To multiply a number, a binary shift moves all the digits in the binary number
along to the left and fills the gaps after the shift with 0:
to multiply by two, all digits shift one place to the left
to multiply by four, all digits shift two places to the left
to multiply by eight, all digits shift three places to the left
Division
To divide a number, a binary shift moves all the digits in the binary number along
to the right:
to divide by two, all digits shift one place to the right
to divide by four, all digits shift two places to the right
to divide by eight, all digits shift three places to the right
Special Circuits
Combining basic logic gates for a desired output.
Storing bits – Sequential Logic
Circuits
0 1 0 1
0 1 0 1 Resets Q to 0
1 1
Basic SR Flip-Flop
Types of Flip
Flops
D Flip Flop
Used in basic memory
units for storing a single
Application bit.
s of SR
Employed in control
Flip-Flops circuits to remember
ON/OFF states.
In J-K flip flop when both inputs are HIGH, the output toggles i.e. it changes from high
to low and low to high periodically when both the inputs are 1. For an SR flip flop,
however, when both the inputs are HIGH, we encounter an invalid state, which is not
present for a JK flip flop.
In the SR Flip-Flop, when both inputs S and R are 1 then the output of the flip-flop is
indeterminate. That issue can be resolved using the JK Flip-Flop. Similar to the SR Flip-
Flop, the JK flip-flop has two inputs. And using the two inputs the flip-flop can be set,
reset, hold (memory) or toggled. Unlike the SR flip-flop, in the JK flip-flop, when both
inputs J and K are 1 then the output of the flip-flop toggles.
JK Flip flop
The System Clock
The D Flip-Flop (also called a Delay or Data Flip-Flop) is an improvement over the
SR Flip-Flop. It eliminates the undefined state problem by ensuring that only one
input is used. This flip-flop has a single data input (D) and a clock input (CLK).
A D Flip-Flop can be constructed using a modified SR flip-flop with an inverter placed
between the S and R inputs. This guarantees that S and R are never high at the
same time, preventing the undefined state.
D Flip-flop
Half Adder
Full Adder
The Full adder takes in 1 extra bit than
the half adder, a carry bit from a
previous computation.
A full adder adds three bits: two
input bits and a carry-in (Cin) from
the previous addition. It produces two
outputs: Sum (S) and Carry-out
(Cout).
When multiple bits need to be added,
full adders can be connected in series
to form multi-bit adders.
https://www.geeksforgeeks.org/implem
entation-of-full-adder-using-half-adders
/
Ripple Carry
Adder
An encoder is a device which converts familiar numbers or characters or symbols into a coded
format.
It accepts the alphabetic characters and decimal numbers as inputs and produces the outputs as
a coded representation of the inputs.
Encoders are used to translate the decimal values (pressing a number key on the keyboard) to the
binary in order to perform the binary functions such as addition, subtraction, multiplication, etc.
An encoder is a device used to change signals into a compressed format. This format is valuable
for transmission or storage, encrypting or adding redundancies to the input code.
https://electronicsdesk.com/encoders.html
Eg. A keyboard device where 1 of 64 lines is raised by pressing one key a corresponding 6-bit
character is produced on 6 wires coming out of the encoder. Usually two other bits are included
for parity and a control key.
Decoders
1 Mark
Research Questions - HW
https://www.techopedia.com/definition/24124/
multiplexer-mux
Computer Organization
describe the main characteristics of a processor
Digital circuits are the building blocks of computer architecture.
Running the Object Code
Digital Component uses
The Central Processing Unit is the core/brain of the computer system. It is responsible
for integrating the peripheral devices and facilitate communication. Controls and
coordinates all activities of the computer.
The CPU is responsible for the execution of the commands of the programs on the
computer system. Processes input instructions and data given to the computer
The CPU facilitates all calculations and data processing that the computer needs to
perform.
Fetch-
Decode-
Execute-
Store
Cycle
Processor Components
1. Fetch – The instruction is retrieved from memory. Fetch Data and instructions from
RAM.
2. Decode – The instruction is interpreted by the control unit. Decode and coordinate
the instructions and data received.
3. Execute – The instruction is carried out using arithmetic or logical operations.
Execute and perform instructions and data given to the computer.
4. Store – The result is written back to memory or a register.
https://www.youtube.com/wat
ch?v=jFDMZpkUWCw
Fetch Stage
The Program Counter (PC) holds the address of the next instruction to be executed.
The address from the PC is sent to the Memory Address Register (MAR) via a
multiplexer. Memory Address Register are those that holds the address of the memory
location the CPU wants to access (read or write). The data from the MAR is sent across
the address bus with the instruction to read the data sent across the control bus.
The Control Unit fetches the instruction stored at that address (the one in the MAR) and
places it (the actual instructions) in the Memory Data Register (MDR). The data from
that location in memory is sent down the data bus to the MDR. The MDR temporarily
holds the data being transferred to or from memory.
The instruction is transferred from the MDR to the Instruction Register (IR) for
decoding. Instruction Register holds the instruction to be executed.
The PC is incremented to point to the next instruction.
Types of Registers
Accumulator: This is the most common register,
used to store data taken out from the memory.
Accumulates results.
General Purpose Registers: This is used to store
data intermediate results during program execution.
It can be accessed via assembly programming.
Special Purpose Registers: Users do not access
these registers. These registers are for Computer
system,
MAR: Memory Address Register are those
registers that holds the address of the memory
location the CPU wants to access (read or write).
MDR/MBR: Memory Data/Buffer Register
Temporarily holds the data being transferred to
or from memory.
PC: Program Counter keeps track of the next
instruction to be executed.
IR: Instruction Register stores the current
instruction being executed.
BUS
A bus is an electrical path that
transports bits of instructions and
data between the different parts
of the CPU.
Address Bus - Carries the
memory address of data or
instructions the CPU wants to
access. If the CPU wants to read
from memory location 1001, the
address 1001 is sent via the
address bus.
Data Bus - Transfers actual data
between the CPU, memory, and
peripherals. The data stored at
1001 is sent via the data bus.
Control Bus - Sends control
signals to coordinate operations
between the CPU and other
components. The CPU sends a
Read or Write signal to memory to
specify the type of operation.
Decode Stage
The IR (Instruction Register) sends the fetched instruction to the Control Unit.
The Control Unit (CU) decodes the instruction in the IR.
The Decoder interprets the binary opcode and determines the required operation.
Decoders – Identify the operation (e.g., ADD, SUB, LOAD, STORE, etc).
The CPU then determines where to send data required for the operation eg to a
Register for storage or to the ALU for calculations.
Execute Stage
When a high-level program is compiled into low level binary code, it is referred as
machine code that CPU can directly execute. A machine code can have many
instructions and these instructions in binary are referred as machine instructions.
The instructions sent to the CPU is a
pattern of bits that the Control Unit
decodes.
The Instruction Set is a basic set of
commands/operations that the CPU
understands/executes.
Instructions The Instruction Set is the Range of
different types of Instructions that
the CPU knows how to execute.
The instruction size is the number
of bits within the instruction that the
CPU can hold. Instructions come in
16bit sets, 32 bits sets, 64 bit sets
etc.….
Instruction Types
Data Flow – copy/move data from one place to another (between memory, registers,
and I/O devices). Eg LDA, MOV
Arithmetic – perform operations on numeric data ADD, SUB, MUL, DIV
Logical – performs Boolean operations AND, OR, NOT
Shift – moves bits one or more places to the left or to the right.
Flow Control – permits instructions to be executed out of order. Eg GOTO, JMP
Instruction
Format
Addressing modes are part of the opcode used to indicate WHERE the data is coming from,
it can be from the Registers, Main memory or a literal value.
Immediate addressing – the operand provides the value to be used. Like a literal number.
Eg Add #4 D0 means add the value 4 to register D0. The # means that 4 isnt a memory address,
but just the number 4.
Absolute/direct addressing – the operand specifies the location of the data IN MEMORY.
Eg CLR 1234 which means clear or set the contents of memory location 1234 to zero.
Register addressing – the operand specifies the location of the data A REGISTER
Eg LDA PC which means Load the Program Counter
Indirect addressing - the operand provides a pointer to the location of the data.
Eg MOV (A0), D1 means to read the address contained in A0, then go to that address, get the actual
data and move It to D1.
CPU Clock
An internal timing device using a quartz crystal, gives the microprocessor a constant flow of
electrical pulses.
Clock Speed – The rate at which the computer processes data. The clock speed measures
the number of cycles your CPU executes per second, measured in GHz (gigahertz).
Determines how many instructions the CPU can process per second.
For example, a 200 MHz CPU receives 200 million pulses per second from the clock.
A 2 GHz CPU gets two billion pulses per second.
In general, a higher clock speed means a faster CPU.
CACHE memory is memory that stores
frequently accessed data for faster access.
Cache memory acts as a buffer
between RAM and the CPU.
The CPU checks CACHE first then RAM.
It holds frequently requested data and
Performanc
instructions so that they are immediately
available to the CPU when needed.
Cache memory is used to reduce the average
e - CACHE time to access data from the Main memory.
Cache memory can either be a reserved
section of main memory or an independent
high speed storage device on the CPU.
The purpose of cache memory is to allow the
CPU to operate at full speed without waiting for
main memory access that is very slow
(comparatively).
Parallel Processing is the simultaneous
execution of multiple instructions or tasks to
improve performance.
Multiple instructions are executed in each
clock cycle.