How do computers work? CPU, ROM, RAM, address bus, data bus, control bus, address decoding.
Summary
TLDRThis script delves into the fundamentals of computing, focusing on the CPU and memory interaction. It explains how CPUs execute programs, the role of ROM and RAM, and the significance of address decoding. The video illustrates how data is read and written between the CPU and memory chips, the use of address, control, and data buses, and the importance of decoding in a computer system. It also touches on the evolution of computer buses and the principles behind input/output operations, concluding with a simple example of controlling an LED, showcasing the practical application of these concepts.
Takeaways
- π‘ The CPU is the heart of any computing device, executing programs and consuming data from external memory.
- π The CPU reads programs byte by byte, similar to reading a book word by word, with each byte having a value from 0 to 255.
- π Computer memory is organized as an array of bytes, each with a unique address starting from zero.
- π’ Memory types include ROM, which contains pre-programmed code, and RAM, which holds temporary data and is erased when power is interrupted.
- π€οΈ The address bus is a set of wires that encode memory cell addresses in binary for the CPU to communicate with memory chips.
- π The control bus, with signals like read (Rd) and write (WR), determines the operation the CPU intends to perform with memory.
- π The data bus is bi-directional, transferring data between the CPU and memory or peripherals, with its size impacting system performance.
- π Address decoding is crucial for memory chips to know which device the CPU is addressing, preventing data bus collisions.
- π The size of the address space is determined by the number of address bus lines and is tied to the CPU model.
- π Hexadecimal is used in computing for its efficiency in representing binary numbers, simplifying memory address and data representation.
- π© Real computers use a more complex decoding mechanism to allow for multiple memory and input/output devices to be addressed individually.
Q & A
What is the primary function of a CPU in a computing device?
-The primary function of a CPU in a computing device is to execute programs or code. This involves reading and processing data from external memory as long as power is applied.
How is computer memory organized?
-Computer memory is organized as an array of integer numbers called bytes, with each byte capable of taking a value from 0 to 255.
What is the difference between ROM and RAM in a computer system?
-ROM (Read-Only Memory) typically contains pre-programmed code for the CPU to execute, while RAM (Random Access Memory) mostly contains temporary data that can be both read and written to by the CPU. ROM retains data even when the power is off, whereas RAM is erased when power is interrupted.
What is the purpose of the address bus in a computer system?
-The address bus is used by the CPU to communicate the memory cell address it wants to read from or write to. It's a set of electrical wires that encode memory cell addresses using binary system (ones and zeros).
Why are read and write signals in a computer system active low?
-Read and write signals are active low due to power consumption considerations. This means that the CPU pulls the read line low to perform a read operation and the write line low to perform a write operation.
What is the significance of the data bus in a computer?
-The data bus is crucial for transferring data between the CPU and memory chips. It's bi-directional and its size directly affects the performance of the system. The data bus carries data in binary format, with the size of the data bus determining the size of a single memory cell.
How does address decoding help in differentiating between different memory chips in a computer system?
-Address decoding uses logic gates to output logic 0 when a certain pattern of ones and zeros is present on its inputs. This mechanism allows the CPU to differentiate between memory chips by assigning them specific address ranges.
What is the role of the control bus in a computer system?
-The control bus is a signaling system that includes lines like read (Rd) and write (WR) to indicate the operation the CPU intends to perform. It helps in managing the communication between the CPU and other devices on the computer motherboard.
Why is the hexadecimal numbering system used in computers and programming?
-The hexadecimal numbering system is used because it simplifies the representation of binary numbers. It replaces every combination of four binary digits with one hexadecimal digit, making it easier to work with memory addresses and data.
How does the CPU interact with input/output devices in a computer system?
-The CPU interacts with input/output devices using read and write operations, which are decoded into a separate address space. This is facilitated by additional signals on the control bus, such as input/output request (IOWR) and memory request (MEMR).
Outlines
π₯οΈ CPU and Memory Basics
This paragraph introduces the central processing unit (CPU) as the core of any computing device, responsible for executing programs. It explains how the CPU reads programs byte by byte from memory, similar to reading a book. The concept of memory cells, addresses, and the types of memory (ROM and RAM) are discussed, highlighting the permanence of ROM and the volatility of RAM. The BIOS chip and its role in system startup are also mentioned, along with a simple example of how a CPU and ROM chip interact using an address bus to read program code.
π Understanding Memory Operations
The second paragraph delves into the mechanics of memory operations, focusing on the unidirectional address bus and the control bus that signals read (Rd) and write (WR) operations. It discusses the mutual exclusivity of read and write signals and the rationale behind active low signals for power consumption. The paragraph also introduces the data bus, which is bi-directional and central to the system's performance, with an example of how the CPU reads a byte of data from ROM and interprets it as a machine code instruction.
π Address Decoding and Memory Mapping
This section explains the concept of address decoding, which is essential for distinguishing between different memory devices in a computer system. It describes how the address space is divided into fixed ranges for ROM and RAM, using the CPU's address lines to determine the maximum addressable space. The paragraph also covers the hexadecimal numbering system as a more convenient way to represent binary numbers and how memory chips are activated based on address ranges, with examples of how ROM and RAM are assigned to different parts of the address space.
π Chip Select and Memory Interaction
The fourth paragraph discusses the chip select (CS) signal and its role in activating memory chips based on address ranges. It explains how the least significant bit (LSB) and most significant bit (MSB) of an address determine which memory chip is active. The paragraph also describes the use of control lines like output enable (OE) for ROM and the right signal for RAM, and how these are used in conjunction with address decoding to prevent data bus collisions during read or write operations.
π Memory Access and I/O Operations
This section describes the process of memory access and input/output (I/O) operations in a computer system. It explains how the CPU interacts with memory and I/O devices through a contiguous address space, with each device responding based on its assigned address range. The paragraph also introduces the concept of memory request and input/output request signals on the control bus to differentiate between memory and I/O operations, using an example of how to add an output port to control an LED.
π Expansion and Decoding in Computer Systems
The final paragraph explores the principles of expansion and decoding in computer systems, comparing the traditional parallel connection and individual addressing of peripheral devices with modern approaches used in PCI Express buses. It discusses how expansion cards and slots operate, the role of decoder chips, and the shift towards independent communication lines for each expansion board in contemporary systems. The paragraph concludes with an invitation for viewers to engage with the content and the channel.
Mindmap
Keywords
π‘CPU (Central Processing Unit)
π‘Program Execution
π‘Memory Cell
π‘Address
π‘ROM (Read-Only Memory)
π‘RAM (Random Access Memory)
π‘Address Bus
π‘Control Bus
π‘Data Bus
π‘Firmware
π‘Address Decoding
π‘Hexadecimal
π‘I/O Ports (Input/Output Ports)
Highlights
The CPU is the heart of any computing device, executing programs and code.
CPUs read programs byte by byte, similar to reading a book word by word.
Computer memory is organized as an array of bytes, each with a value from 0 to 255.
Memory cells are numbered starting from zero, with the ordinal number called the address.
There are two types of memory: read-only memory (ROM) and random access memory (RAM).
ROM contains pre-programmed code, while RAM mostly contains temporary data.
ROM retains data even when the computer is off, unlike RAM which is erased when power is interrupted.
BIOS is a small program that executes every time you boot up your system.
The address bus is a communication system that uses binary to encode memory cell addresses.
The control bus uses signals like read (Rd) and write (WR) to indicate the operation intended by the CPU.
The data bus is bi-directional and carries data between the CPU and memory chips.
Address decoding is a mechanism used to determine which device the CPU is addressing.
The address space is divided into ranges, with each memory device assigned a specific address range.
Hexadecimal numbering is used in computers and programming for easier representation of binary numbers.
The CPU accesses memory cells by address and receives data based on the address range decoded by memory ICs.
Real computers use more complex decoding mechanisms to allow multiple memory and input/output devices to be addressed.
Input/output ports allow the CPU to interact with peripheral devices through read and write operations.
The video demonstrates how to add a simple one-bit output port to control an LED, showcasing the principles of computer engineering.
Transcripts
the heart of absolutely any Computing
device be it personal computer
smartphone or a programmable calculator
is the center processor or CPU
the cpu's main job is to execute
programs or code
what this actually means is that as soon
as power is applied the processor hungry
for executable code starts consuming
data from external memory
just like a person who reads a book word
by word the processor reads the program
by it by bite as long as power is
applied to the Circuit the CPU cannot
stop and program execution continues
forever
and just like a book is made up of
sequence of letters words and sentences
computer memory is organized as array of
integer numbers called bytes and each
byte can take a value from 0 to 255.
in order for the CPU to know which
memory cell exactly IT addresses all
cells are numbered starting from zero
the ordinal number of a cell is called
address
for example memory cell number 300 has
an address of 299
that's because cell numbers start from
zero
computer memory is very similar to a
sheet of paper you can write something
in it that can be read later there are
basically two types of memory read-only
and random access
read-only memory or ROM usually contains
pre-programmed code which is intended
for the CPU to execute while random
access memory or ROM mostly contains
temporary data either generated by the
CPU itself or loaded by the CPU from
external media during program execution
as the name suggests read-only memory
can only be read by the CPU while Random
Access Memory can be both read and
written to
this means that ROM retains data even if
you turn off your computer while Ram is
erased every time Powers interrupted
dim sticks installed in your PC or
laptop is RAM
and bios chip is wrong
bios is a small program that is executed
every time you boot up your system
let's now take a glance at how it works
imagine a very simple Computing device
consisting of a CPU and a ROM chip
the ROM chip contains a program called
firmware
the name firmware suggests that it's a
proprietary piece of software that can
only run on a certain device
as the power is applied the CPU
immediately addresses the ROM chip in an
effort to read program code that it
could execute
obviously for that to happen it needs to
read data from a number of memory cells
so each cell is read by specifying its
address which like was mentioned above
is its unique ordinal number
for the CPU to be able to tell the ROM
chip the address of the cell it wants to
read all computers have a communication
system called address bus
by Design it's basically a set of
regular electrical wires that use binary
system that's ones and zeros to encode
memory cell address
this method in fact is always used by
computers to communicate numbers between
devices
imagine that the CPU wants to read cell
whose address is 44 206.
this is just a random sample number it
doesn't mean anything
let us now open Windows calculator and
convert it to binary
the result is this binary number
note that it has 16 bits that's binary
digits
so exactly these ones and zeros the CPU
will put up on the address bus to reach
cell number 44 206.
yep it's that simple
please note and that is very important
the least significant bit LSB of the
address which is zero in our case will
be put up at address line a0
well the most significant bit MSB will
be at line a15
address numbering like everything in
programming also starts at zero
because the address is always sent from
the CPU to external devices and never in
the reverse Direction the address bus is
unidirectional which means the CPU
address lines are outputs and the ROM
chips address pins are inputs
so all devices on a computer motherboard
are connected to the address bus in
parallel
but it's obvious that computer memory
supports two types of communication
reading and writing
how would the memory chip know which
operation exactly the CPU intends to
perform
for that computers use a signaling
system called the control bus
it also consists of regular wires and
its two most important lines are read
and write designated as Rd and WR
please note both the read and write
signals are active low meaning if the
CPU intends to perform a read operation
it pulls the read line low
if it wants to write data it pulls the
right line low
these two signals are mutually exclusive
because it's not possible to read and
write simultaneously
the reason why I read and write and
other control signals are active low is
power consumption considerations
okay so the CPU outputs the binary value
of 44 206 to the address bus
now to let the ROM chip know it intends
to read the contents of this memory cell
it also activates the read line
you might wonder now why would the ROM
chip need the read signal if read is all
it can do and the CPU cannot write
anything to it
well thing is the CPU has no idea what
type of memory it's addressing
actually doesn't care
so every time it wants to read something
no matter if it's ROM or Ram it's
reading from it will always pull the
ridline low
and in fact the ROM chip does need the
read signal because it needs to know
when exactly it's supposed to send the
data requested to the CPU
looks like now we need a mechanism to
transfer data
and here comes to play
the data bus
probably the most important and also
complicated communication system in a
computer and it's bi-directional in our
example the data bus carries exactly
eight bits of data
because the size of the data bus
directly affects the performance of the
entire system it is precisely this that
we mean when we say for example that the
computer is 8-bit and the game console
is 16-bit and the version of Windows is
32 or 64-bit
in response to the cpu's request the ROM
chip puts the contents of the memory
cell located at address
44206 onto the data bus
let's say the value is 112.
naturally the data will also be
presented in binary format
112 will look like this
while the read operation is in progress
the CPU becomes the receiving side and
its data bus lines act as inputs and the
ROM chips data bus pins act as outputs
our little computer here has an 8-bit
data bus which means the size always
single memory cell is one byte which is
exactly 8 Bits
so our CPU has read exactly one byte of
data and its value equals 112.
like I said before the ROM chip contains
firmware a computer programming machine
code written by a programmer
so 112 which is again just a sample
value I picked is the command that tells
the CPU to perform a certain task
these commands are also called operation
codes opcodes or machine code
instructions
so imagine it's the instruction to write
a value of 205 to the memory cell
located at address 62 088
please allow me to add a ram chip to
write to to our improvised computer
it will be connected in parallel to both
the address and the data bus of our
system
like I said the address bus is
unidirectional and in theory we can
connect an infinite number of devices to
it
but now we got a problem
when the CPU initiates a read or write
operation because we now got two memory
chips in our system how would they know
which one the CPU is addressing
if both of them get activated
simultaneously their outputs will
struggle and we're going to have a
collision on our data bus
here another very important mechanism in
computer engineering comes into play
it's called address decoding
the term decoding here has nothing to do
with ciphering or encryption
it's merely a set of logic gates that
output logic 0 whenever a certain
pattern of ones and zeros is present on
its inputs
what exactly this combination should be
is determined by the Circuit of the
decoder itself
so in order for the CPU to know exactly
which device it's addressing when
designing a computer system all address
space is divided into ranges
some part of it is taken by Rome another
part by Ram
imagine a book that has several chapters
we know exactly which page each chapter
starts and ends in
and it's impossible to move chapters if
the book had already been printed
same thing happens in a computer's
address space
each memory device is assigned a certain
address range which is fixed and cannot
be altered
the size of the entire address space is
determined by the number of address bus
lines and is always tied to the CPU
model
our computer here has a CPU with 16
address lines so the maximum number of
bytes the CPU can address is 2 to the
power of 16. which is 65
536 bytes or 64 kilobytes
you can also come up with this number
using Windows calculator
16 binary Ones Will yield a decimal
value of 65
535 because memory cell number one mind
you as the address 0 not 1.
so the address space of our computer
starts at byte number zero and NZ byte
number 65
535 and the total number of bytes that
can be addressed is 65 536.
for the CPU to be able to work both with
ROM and RAM
we need to wire them in such a way that
they're activated whenever accessing the
address range that is assigned to each
of them based on our concept
or we can say these two chips must be
properly decoded
to keep things simple in our little
experiment each chip will have exactly
half the memory space which is 32
kilobytes a piece
ROM will take the lower 32k and RAM the
upper 32k
so the ROM will be located in the
address range from 0 to 32
767 and Ram from 32
768 to 65 535.
why exactly like that and not the other
way around
ROM is usually placed at the start of
the address space because that's where a
typical CPU starts program execution
after the reset signal arrives
when you hit reset what you actually do
is zero the program counter PC
so address 0 is where the very first
firmware instruction must be located
all data between the CPU and memory
chips will naturally be transferred in
binary format
here's what it's going to look like
to be honest these numbers do not really
fit well with the ear and are pretty
hard to perceive
so in computers and programming a
hexadecimal numbering system is used
it differs from decimal system and that
in addition to digits from 0 to 9 Latin
letters from A to F are used that also
act as digits
so hexadecimal uses a total of 16 digits
instead of 10.
in essence the hexadecimal system is a
simplified way of representing binary
numbers
it basically boils down to a simple
replacement of every combination of four
binary digits there are also 16 of them
with one hexadecimal digit like this
so 8-bit of binary data can be
represented by two hex digits while 16
bit of binary data will take up four hex
digits and so on
by the way in programming four bits are
called a nibble 8 Bits are called a byte
and 16 bits and up are called a word
now these values will look like this and
our ROM chip will decode to addresses
from 0 to 7 FFF while the ram chip will
take up address range from 8000 to ffff
we must pronounce hex numbers by a
single digit because 8000 is not 8 000.
it's a different number
hex numbers have their own designation
and programming for example the C
language uses prefix Ox while in
Assembly Language Latin letter H H for
hex uppercase or lowercase doesn't
matter is appended at the end of the
number
all these designations are equivalent
okay let us take a close look at these
values and try to figure out how they
differ in terms of address Buzz bits
their binary representation tells us
that their distinct difference is their
most significant bit
any HEX number in the range above 7ff
has the highest address line that's a15
equal to 1.
any HEX number below 800 has address
line a15 equal to zero
so we need the ROM chip to activate when
a15 is low and RAM chip to activate when
a15 is high
memory chips have a special control line
for Activation called CS chip select or
C chip enable which is basically the
same
the Cs signal is also active low
if the IC is not active its outputs will
be in the so-called z-state High
impedance
which means that the pin is effectively
disconnected
such outputs are also called Tri-State
memory ICS also have the OE control
signal which stands for output enable
since ROM can only send data the Cs and
oeither have basically the same meaning
but for Ram active OE means the data is
being read from the memory
so to decode these two memory ICS all we
have to do is use a simple inverter gate
the ROM c signal will be wired directly
to the a15 address line and ram C will
be fed from the inverter
the read signal will be wired to the
output enable pins of both chips while
the right signal will go to the right
enable input of the ram chip
the right signal is not used with the
wrong chip naturally
before us ladies and gentlemen is the
real working Circuit of the simplest
computer
so how does it work
once the CPU is reset its address
pointer the program counter PC is zeroed
so all address lines are set to logic 0.
as the CPU immediately starts reading
program code from memory it sets the
read line low
because the CE line of the ROM chip is
also pulled Low by the a15 address line
the ROM IC activates
and puts up the contents of the
requested memory cell address 0 on the
data bus
although Ram is wired to all buses in
parallel it does not interfere because
it's not active
it's CS input is fed logic high from the
inverter and its data lines are in the Z
State effectively disconnected
now imagine the CPU reads the upcode
that instructs it to write byte AA 1070
decimal to address b00 45 056 decimal
the CPU sets its address bus to this
value in binary format
then it puts the integer number AA which
is
1010101 or binary on the data bus
the AA and 55 bytes alternating zeros
and ones is the value often used in
programming for memory testing
so we got the binary representation of a
a integer on our data bus
what happens next is the CPU pulls the
right line low and the ram chip mind you
the a15 is high and CS is low which
means it's active performs the right
operation storing value a a in a memory
cell whose address is b00
now this data is stored and whenever the
processor needs it it can read it
to do this it has to set the address bus
to b00 and pull the read signal low
the chip enable line of the ram chip
will also be pulled Low by the inverter
and it will place the contents of the
memory cell b00 on the data bus and the
CPU will read it switching its data
lines to input mode
okay so we have created a contiguous
address space of 64 kilobytes covered by
two memory chips
the CPU has no idea about the structure
it simply accesses a Cell by address and
receives data and each of the memory ICS
responds to the CPU based on which range
the address requested belongs to
in real computers decoding is of course
much more complex
the decoder can use several address
lines and other signals to obtain a
narrower address range
using this mechanism several memory and
input output devices can be decoded
in any case it's up to the developer to
decide which address range each memory
chip must be decoded
and when firmware is written the
programmer naturally must be aware which
devices decode to which address range
for example every personal computer has
this thing called display memory area
also known as video Ram or vram
it's basically your regular Random
Access Memory however writing data to it
changes the contents of the computer
screen
typically vram memory cells are located
according to their position on the
screen that is from left to right and
from top to bottom the lower address is
the upper left corner the higher address
is the lower right corner
all those are maybe exceptions
now we have studied a very important
mechanism that explains the interaction
of the servo processor and memory
devices
with this knowledge it's easy to
understand the principles of operation
of any computer
but it seems our virtual PC is missing
something
it does not in any way interact with the
user
all real computers in addition to memory
have input output ports this is where
you plug in your keyboard mouse or
gamepad
to work with ports the CPU also uses
read and write operations
but they are decoded into a separate
address space and accessed with separate
machine language instructions
the address bust used however is the
same so to separate ports from memory
devices there exists additional signals
on the control bus called input output
request Iowa REC and memory request
memric
traditionally their active level is also
low
so for the CPU to be able to talk to
memory correctly we must also decode the
memory request signal
here's what the schematic will look like
then
now both memory chips can get a logic
low on their chip enabled inputs only on
condition the memory request line is
also low
so what are we gonna do with our little
computer now
say we want to impersonate Arduino and
Flash an LED
let us add a simple one bit output port
to our system
we will use add d-type flip flop to
implement it
the data input will be wired directly to
the data bus
while the clock input needs to be
properly decoded
let our Port use the address FF
this number corresponds to eight ones in
binary
like I said CPU uses the same address
bus to the code ports so we will need an
and gate with 8 inputs to track this
combination on the address bus
our Port will be right only so we also
need to decode the cpu's bright line
the device must react only to Port
output instructions and ignore memory
right instructions so we also need to
decode the input output request signal
if we don't the CPU won't know how to
differentiate between memory cellff and
port number FF and when it performs a
write operation both will be affected
okay
let us analyze the circuit step by step
say the CPU wants to turn on the LED
so it executes a machine code
instruction that writes value 1 to Port
FF
as we have wired the flip-flop D input
to the d0 line the state of the LED will
correspond to the least significant bit
LSB of the data byte
so the CPU sets the address lines from
a0 to A7 to 8 ones that's value FF and
puts up logic 1 on d0 line
then it pulls the right and input output
request lines low
at this very moment the flip-flop will
be clocked at the scene Boot and data
will be copied into the register
the LED will illuminate
to turn the LED off the CPU must perform
exactly the same action except the value
written to the flip-flop board must be
zero
this principle of parallel connection
and individual addressing of peripheral
devices with the help of decoding has
been used in computer engineering for
decades
and that's exactly how Isa and PCI buses
and personal computers work
all slots and such systems are connected
in parallel and decoding happens on the
expansion cords inserted
if you've ever used the ISA Sound
Blaster you remember you had to set up
its address and interrupt line
what you were actually doing is setting
up its decoder chip
so any expansion card can be inserted
into any slot and will work the same way
however starting with a PCI Express Bus
manufacturers have abandoned this
principle and today each motherboard
slot has independent lines for
communication with every individual
expansion board installed
and that would be it for today I hope
you enjoyed this video and learned
something new
if you did make sure to give it a thumbs
up and hit the Subscribe button if you
haven't already
and please don't hesitate to share it on
social media
this was Ron matino
take care see you soon
[Music]
foreign
Browse More Related Video
1. OCR GCSE (J277) 1.1 The purpose of the CPU - The fetch-execute cycle
Registers & Special Purpose Registers in Assembly Language Urdu/Hindi | Lecture # 2 | very Important
L-1.2: Von Neumann's Architecture | Stored Memory Concept in Computer Architecture
3. OCR GCSE (J277) 1.1 Von Neumann architecture
M1. L3. Measuring Computer Power
L-1.4:Types of Buses (Address, Data and Control) in Computer Organization and Architecture
5.0 / 5 (0 votes)