Академический Документы
Профессиональный Документы
Культура Документы
1.
COMPUTER SYSTEMS
09/09/05
1.1
1.2
Data Storage
The computer system stores different types of data in different ways, depending on what the
data is, how much storage space it requires, and how quickly it needs to be accessed. This data
is stored in its "short term" memory and its "long term" memory.
The computer system's main memory ( or primary storage) holds data that you or the computer
are working with right now. This is the computer's "short term memory", and is designed to be
able to feed data to the processor at high speed so the processor isn't slowed down too much
while waiting for it. However, this short-term memory disappears when the computer is turned
off.
Longer-term storage, referred to as secondary storage, may consist of magnetic tapes,
magnetic disk, optical memory device, or similar device, where data is stored permanently in the
form of files, ready for you to retrieve when you need it. When you want to use your computer
program, for example, the computer loads the instructions that are stored on the hard disk that
tell the computer how to run it, from long-term storage (your hard disk) into short-term memory.
1.3
Data Movement
The computer also controls the movement of data from place to place. It reads the data you type
on the keyboard, moves it into memory and eventually displays it on the screen or stores it in a
file. This movement is called input/output or I/O and is how the computer talks to you as well
as devices that are connected to it.
Moving data between machines is also an important part of modern computing. The computer
uses networking components, modems and cables to allow it to communicate with other
machines.
1.4
Control
The computer system must control the above three functions. Within the computer, a control
unit directs and co-ordinates the operation of all the other components of the computer by
providing timing and control signals and by executing the instructions of a program.
COMP1208-Notes06-CompSys.doc
Page 1
COMPUTER SYSTEMS
COMP1208
2.
09/09/05
(ii)
(iii)
(iv)
Input and Output (I/O) devices - moves data between the computer and its external
environment
(v)
Microcomputer System
Secondary
Storage
Main Memory
(ROM and RAM)
Output
Devices
Printer
Microprocessor
(ALU + CU)
Input
Devices
Output to printer
-Tape
-Disc
-Teleprinter
-Data from
transducers
I/O Unit
Output
to VDU
Keyboard
COMP1208-Notes06-CompSys.doc
Page 2
Visual
Display
Unit
(VDU)
COMPUTER SYSTEMS
COMP1208
2.1
09/09/05
CPU
The Central Processing Unit (CPU) is the central component of the PC. This vital component
is responsible for every single thing the PC does. It determines, at least in part, which operating
systems can be used, which software packages the PC can run, how much energy the PC uses,
and how stable the system will be, among other things. The processor is also a major
determinant of overall system cost: the newer and more powerful the processor, the more
expensive the machine will be.
The underlying principles of all computer processors are the same. Fundamentally, they all take
signals in the form of 0s and 1s (binary signals), manipulate them according to a set of
instructions, and produce output in the form of 0s and 1s.
The CPU has three main units:
Arithmetic and Logic Unit (ALU): Performs arithmetic operations and Performs logical
operations. Performs arithmetic and logical operations. For example, it can add together
two binary numbers either from memory or from some of the CPU registers.
Control Unit: controls the action of the other computer components so that instructions
are executed in the correct sequence.
Registers - Temporary storage inside CPU. Registers can be read and written at high
speed as they are inside the CPU
Main Memory
Control
Unit
System
Clock
Input
Port
Output
Port
Registers
Arithmetic
Logic Unit
CPU
Figure 2: CPU
COMP1208-Notes06-CompSys.doc
Page 3
COMPUTER SYSTEMS
COMP1208
09/09/05
The figure below shows an example of the organisation of an accumulator based CPU
organisation.
Memory (RAM)
data bus
Address bus
MAR
MDR
PC
ALU
ACC - Accumulator
IR
CPU
In the following example, there are two input registers A and B and one ALU output register
which can be stored back into a register.
A+B
A
registers
ALU
A+B
COMP1208-Notes06-CompSys.doc
Page 4
COMPUTER SYSTEMS
COMP1208
09/09/05
If we take the example of addition performed by the ALU, in a high level program we may have
one statement, such as
Z = x + y;
Where x, y, z are all integer variables in memory and lets assume that x = 7, and y=5; and
inititally z = 0;.
In order to perform the addition of the following machine code instructions may be used for this
example:
1)
2)
3)
4)
Exercise:
What steps might be involved for the example in Figure 3: Example 1 Accumulator ALU?
Most instructions can be divided into one of two categories: register-memory or register-register.
Register-memory instructions allow memory words to be fetched into registers, where they can
be used as ALU inputs, or they allow registers to be stored back into memory.
A typical register-register instruction might be ADD register A to register B.
Instruction Execution
Figure 5: Machine CycleControl Unit repeats the four operations of the Machine Cycle
COMP1208-Notes06-CompSys.doc
Page 5
COMPUTER SYSTEMS
COMP1208
2.2
09/09/05
CONTENT
A data word
A data word
A data word
A data word
:
:
:
A data word
A data word
A data word
A data word
A data word
A data word
A data word
The CPU can directly access data stored in Main Memory. When a memory location is
accessed (READ), the contents of the memory location are unchanged (an exact copy of the
contents of that location is made for processing by the CPU). When new information is placed
COMP1208-Notes06-CompSys.doc
Page 6
COMPUTER SYSTEMS
COMP1208
09/09/05
in a memory location (WRITE), the existing data is overwritten with the new data. Data is stored
in binary (1s and 0s).
A byte is 8-bits and bytes are grouped into words. A computer with a 32-bit word has 4 bytes
per word, whereas a computer with a 64-bit word has 8 bytes per word. Most instructions
operate in entire words, for example, adding two 32-bit integers. Thus a 32-bit machine will
have 32-bit registers and instructions for manipulating 64-bit words, whereas a 64-bit machine
will have 64-bit registers and instructions for manipulating 64-bit words.
Byte ordering
The bytes in a word can be numbered:
For example IBM mainframes and SPARC.computer systems use big endian, whereas the Intel
family use little endian
Address
Big Endian
Address
Little Endian
0 3
4 7
10
11
8 11
10
12
12
13
14
12 15
14
13
15
Byte
-------------32-bit word ----
12
Byte
-------------32-bit word ----
00000000 00000000
00000000
00000000 00000000
00000110
Little Endian
00000000
COMP1208-Notes06-CompSys.doc
Page 7
COMPUTER SYSTEMS
COMP1208
09/09/05
2. Cheap
3. Low capacity
3. Large capacity
Floppy disks are mostly used for transferring software between computer systems and for
casual backup of software. They have low capacity, and are very, very slow compared to other
storage devices.
COMP1208-Notes06-CompSys.doc
Page 8
COMPUTER SYSTEMS
COMP1208
2.3
09/09/05
Input/output devices
Input/output devices provide an interface between the computer and the user. There is at least
one input device (e.g. keyboard, mouse, measuring device such as a temperature sensor) and
at least one output device (e.g. printer, screen, control device such as an actuator). Input and
output devices like keyboards and printers, together with the external storage devices, are
referred to as peripherals
2.4
On-chip bus
CPU chip
registers
ALU
system bus
memory bus
main
memory
I/O
bridge
bus interface
I/O bus
USB
controller
mousekeyboard
graphics
adapter
disk
controller
monitor
disk
Figure 8:
COMP1208-Notes06-CompSys.doc
Page 9
COMPUTER SYSTEMS
COMP1208
09/09/05
3.
Microprocessors/MicroControllers/Embedded Systems
3.1
What is a Microprocessor
Memory
CPU
(P)
Input
Output
Microprocessor
Figure 9:
A microprocessor (P) is a Central Processing Unit (CPU) on a single chip. The P contains
the arithmetic, logic, and control circuitry required to interpret and execute instructions from a
computer system. A microprocessor by itself is not a computer, when combined with other ICs
that provide storage for data and programs, often on a single semiconductor base to form a
chip, the microprocessor becomes the heart of a small computer or microcomputer.
Microprocessors are classified by
the width of the data format (4-bit, 8-bit, 16-bit, 32-bit, or 64-bit) they process
Microprocessors evolution is driven by performance, i.e. increased and faster processing power
with the ability to store more data. Examples of first-generation 8-bit P families include for
example: Intel's 8080, Zilog's Z80 and Motorola's 6800. The 32-bit and 64-bit microprocessors
found in today's workstations and servers include the x86, PowerPC, Alpha, MIPS and SPARC
series.
COMP1208-Notes06-CompSys.doc
Page 10
COMPUTER SYSTEMS
COMP1208
3.2
09/09/05
What is a Microcontroller?
Memory
CPU
(P)
Input
Output
Microcontroller
Figure 10:
3.3
General-Purpose Computers
Embedded Systems
The first, and most obvious, is that of the general-purpose computer (i.e. PCs). The application
programs themselves determine the functionality of the computer system. For the computer to
fulfill a new role, all that is required is for a new application to be loaded.
In contrast with this is the embedded system. Embedded systems are systems that are
dedicated to perform specific functions, with the hardware and software being tailored directly
to the application. They differ from conventional computer systems in that they are not required
to be general purpose. Real-time operation is also often very important for embedded systems.
Some examples of embedded systems are microwave ovens, VCRs, CD players, video
cameras, remote controls, video games, laser printers, fax machines, photocopiers, ATM
machines, automotive control, climate control in buildings, aircraft and spacecraft avionics and
control, railway signalling systems, music synthesisers, traffic-light controllers and cash registers
(to name just a few!). All of these systems have a microprocessor, memory and I/O devices.
Each of them runs software specifically written to control their host application.
COMP1208-Notes06-CompSys.doc
Page 11
COMPUTER SYSTEMS
COMP1208
09/09/05
The processors used in PCs make up only a small percent of the overall number of processors
sold. The majority of processors made are used in embedded applications. Embedded
applications usually require the processor (and/or system) to have high-integration (i.e. be very
compact), low-power consumption, fast response and high performance. Embedded systems do
not have the ability to run different software such as is possible on a general-purpose computer.
There is no requirement for a VCR to run Windows 2000. The only software required by the
VCRs embedded controller is that which reads user input through the console buttons or
remote control, and based upon that input, controls the various subsystems of the VCR. It is
possible to change the functionality of an embedded system by changing the systems
controlling software, but this is not as easy as running a new application on a conventional
computer. The most commonly used processors in small applications are the Intel 8051 (and
derivatives) and the Motorola 68HC11 (and derivatives).
3.4
Microprocessors:
high performance, general purpose "brains " for PCs and workstations (i.e. Pentium 4).
It includes a control units, an ALU and various registers. Typical cost: 100 to 500,
Annual demand: 10s of millions per year.
Microcontrollers:
devices with high levels of integration for embedded control, Microprocessor functions
plus on-chip memory and peripheral functions (e.g. ports, timers) "Swiss army knife" of
microprocessor technology , Typical cost: >1--25, Annual demand: billions.
Figure 11:
COMP1208-Notes06-CompSys.doc
Microprocessor vs Microcontroller
Page 12
COMPUTER SYSTEMS
COMP1208
4.
4.1
09/09/05
This section demonstrates the use of block diagrams and flowcharts to describe a simple
computer system. The example system chosen is a typical design of a modern washing
machine incorporating a microcomputer control system. The Motorola MC6805 P2 8-bit
microcontroller is chosen for this example as it is a complete computer system on a single chip
and its architecture is straightforward. The device is designed to be mass produced to compete
successfully with mechanical and electromechanical controllers.
The 6805 is a complete, 8-bit computer system in a single integrated circuit. This means that its
word size is eight bits, or one byte. The computer system is housed in a dual-in-line package
and has 28 connecting pins as shown in the Figure 12 below.
Figure 12:
COMP1208-Notes06-CompSys.doc
Page 13
COMPUTER SYSTEMS
COMP1208
4.2
09/09/05
XTAL
EXTAL
Memory
NUM
______
RESET
CPU
___
INT
Oscillator
Timer
ROM
RAM
Control
Unit
registers
Accumulator
Index Register
Condition
Code
Register
Stack
Pointer
Program
Counter
Program
Counter
High
Low
ALU
PORTA
Register
A0 to A7
Port A I/O Lines
PORTB
Register
B0 to B7
Port B I/O Lines
PORTC
Register
C0 to C3
Port C I/O Lines
Input/Output
Figure 13:
A program for the 6805 is held in ROM inside the package. The pattern of bits held in this ROM
is determined by a mask (an etching pattern) which acts like a stencil during manufacture. The
6805 is, therefore, called a mask-programmed computer.
4.2.1
COMP1208-Notes06-CompSys.doc
Page 14
COMPUTER SYSTEMS
COMP1208
4.2.2
09/09/05
0x000
0x009
not used
0x00A
0x03F
RAM
0x040
0x07F
0x080
:
:
0x0FF
not used
0x100
0x3BF
ROM
(main user + self test)
0x3C0
:
:
0x7F7
Interrupt vectors
0x7F8
Figure 14:
4.2.3
0x7FF
0x00
PORT B
0x01
1111
not used
Figure 15:
PORT C
0x02
not used
0x03
PORT A - DDR
0x04
PORT B - DDR
0x05
PORT C - DDR
0x06
Each port has a Data Direction Register (DDR). The contents of these registers determine
whether the port pin is input or output. If a bit in the DDR is 0, then the corresponding pin will be
input. If a bit in the DDR is 1, then the corresponding pin will be output.
COMP1208-Notes06-CompSys.doc
Page 15
COMPUTER SYSTEMS
COMP1208
4.2.4
09/09/05
4.2.5
operand 1
3 Bytes
opcode
Figure 16:
operand 1
operand2
The Arithmetic Logic Unit ( ALU) is used to perform the arithmetic and logical operations defined
by the instruction set. The CPU Control Unit sequences the logic elements of the ALU to carry
out the required operations.
Registers in the CPU are memories inside the microprocessor (not part of the memory map).
The MC6805 contains five registers, including the accumulator and the program counter.
The accumulator is a data holding. Data can be read from memory into the accumulator and
data can be written into memory from the accumulator. Arithmetic and combinatorial logic
operations can be performed on the accumulator register, thus many machine instructions
involve the accumulator in some way.
The program counter is a special address-storage register that the CPU uses to keep track of
where it is in a program. the program counter always contains the address of the next
instruction to be executed.
COMP1208-Notes06-CompSys.doc
Page 16
COMPUTER SYSTEMS
COMP1208
4.3
C0
Hot Water
Valve
C1
Cold Water
Valve
C2
Drain
Pump
C3
B0
COMP1208-Notes06-CompSys.doc
Page 17
09/09/05
COMPUTER SYSTEMS
COMP1208
4.3.2
09/09/05
1.
Algorithm
Check that the door shut and
wash programme is 1
2.
3.
COMP1208-Notes06-CompSys.doc
Page 18
COMPUTER SYSTEMS
COMP1208
START
LOAD Port A to Accumulator
FALSE
Is Accumulator = 0x03?
TRUE
STOP
Figure 18:
Aside: see an example of the machine code for the above flowchart
opcode
operands
0xB6
0x00
*0xA4
0x03
0xA1
0x03
0x26
0x04
0xA6
0xF9
0xB7
0x02
Figure 19:
Meaning
COMP1208-Notes06-CompSys.doc
Page 19
09/09/05
COMPUTER SYSTEMS
COMP1208
4.3.3
09/09/05
COMP1208-Notes06-CompSys.doc
Page 20
TRUE
COMPUTER SYSTEMS
COMP1208
4.3.4
09/09/05
Exercises:
Assuming the following:
1)
Fill Cycle
Design an algorithm for the fill cycle of the washing machine. This should include the filling of
the machine with water until the machine is full. This simple machine has two temperature
settings only for the water, hot or cold. The temperature will depend on the programme selected
by the user. The water hot sensor is used to determine if the water is hot. When the fill cycle is
complete the indicator light 1 should be illuminated.
2)
Wash Cycle
Design an algorithm for the wash cycle of the washing machine. This should include the
checking that the water level is high before spinning the motor forward for a period of time and
then spinning in the reverse direction. When the wash cycle is complete the indicator lights 1
and 2 should be illuminated.
3)
Drain Cycle
Design an algorithm for the drain cycle of the washing machine. This should include turning on
the drain pump until the water level is low. When the drain cycle is complete the indicator lights
1, 2 and 3 should be illuminated.
4)
Spin Cycle
Design an algorithm for the spin cycle of the washing machine. This should include checking
that the water is drained before spinning the motor at the required speed for a fixed period of
time. The speed will depend on the programme selected by the user. This simple machine has
two speed settings, fast or slow. When the spin cycle is complete the indicator lights 1,2,3, and
4 should be illuminated.
.
COMP1208-Notes06-CompSys.doc
Page 21