ROBOTIC SYSTEMS:
Robotic systems rely on processors to access user provided values and data. It is essential to note here that allthe data is sent via the processor in a binary format so conversions and storage has to be provided by theprocessor.
Example 1
The device on the left is a mobile trolley with 3 wheels. Allthree wheels can turn left or right and each wheel has itsown electric driving motor. Sensors at the front and rear ofthe trolley detect an object in its path which wouldsubsequently stop all movement. An 8-bit register is used to
control the device.
Chapter: 1.1 Data representation
Hence, the trolley is moving forward and turning left.
(i) What does this register mean?
“0 0 0 1 0 1 11”
(ii) How would the following be represented using the above register?
- front wheel turning right
- back wheels turning left
- moving in a forward direction
- motors on
- no object in its path
Answers
- front wheel not turning left or right
- Rear wheels turning right
- going in backward direction
- motors on
- Error – object in path
So the vehicle is going nowhere.
(ii) 0 1 1 0 1 0 1 0
1.1.1 Binary systems
Chapter: 1.1 Data representation
EXAMPLE#2:
SENSORS IN PRINTING DEVICES:
Three sensors are attached to a printing device, with three alarms attached to the sensors. The first sensor, "A,"detects if the device needs ink. The second sensor, "B," detects if the device needs repair. The third sensor,"C," detects if the device has jammed paper. If the device jams or needs repair, alarm 1 sound. If the devicejams or is short on ink, alarm 2 sounds. If two or more problems occur at once, alarm 3 sounds.It can now be implied that:
- A=1 refers to “low ink”
- B=1 refers to “Device needs repair”
- C=1 refers to “device should jam”
The outputs to the system are as follows:
- A1: alarm 1 sounds if B=1 or C=1(either of B=1 or C=1 will result in A1)
- A2: Alarm 2 sounds if C=1 or A=1 (either of A or C being true will result in A2)
- A3= any two or more of A, B, and C being ‘1’ will result in A3.
Let us now look at the cases that will form:
Questions:
1) What binary values can the register hold to alert the user of a “low ink” situation?
2) The register is holding “010”. Which alarm will sound?
3) Is the system accurate in telling the user of exactly which problem is being occurred? Point out any
one situation where user is misguided?
Answers:
1) 010, 111, 111, 111
2) A2 will sound.
3) No. System has the same alarm for one problem or more than one problem. E.g. 111 could mean that
all three problems have occurred but 111 can be received even if printer is “full on ink” or not having
“jammed paper.”
1.1.1Binary system
PSEPS
PSEPSEUDOCODE EXAMPLES WITH SOLUTIONS
VON NEUMANN ARCHITECTURE
Although computers can have many different forms, there are four functional components that all computers must have:
- Input/Output (I/O)
- Memory
- A Control Unit
- An Arithmetic Logic Unit (ALU)
This idea about how computers should be built, called the von Neumann Architecture after mathematician John von Neumann who proposed it in 1945, is still the basis for computers today. Using these four components, a von Neumann computer will execute a series of instructions, called a program, which are stored in the computer's memory. This is called the stored program concept.
INPUT/OUTPUT (I/O):
The Input/Output (I/O) components of a computer are hardware devices that are responsible for getting data from the computer to the user or from the user to the computer. Data going from the user to the computer is called "input." The two main input devices are the mouse and the keyboard. With both of these devices the user can transmit information (in letters or clicks) to the computer. These are not the only types of input devices that are possible -- there are also graphics tablets, touch screens, and voice recognition devices, among others.
Output devices are used to transmit data from the computer's memory to the user. The two output devices almost every computer system has are the monitor and the printer.
Another common output device is a speaker system for sound. The specific input devices change over time, but every computer must have input and output devices.
The remaining three components of the von Neumann model of a computer are found inside the system unit.
MEMORY :
Although a computer has several types of memory, the memory referred to in the Von Neumann model is the main memory, also called RAM or Random Access Memory. Main memory is used by the computer for storing a program and its data while the program is running. What distinguishes a computer from a calculator is the ability to run a stored program; main memory allows the computer to do that.
RAM can be thought of as a sequence of boxes, called cells, each of which can hold a certain amount of data. RAM is constructed from circuitry that can hold data in the form of an electronic charge that is either high or low. Conceptually, a high charge represents the number 1 and a low charge the number 0.
RAM must be coded in binary - in terms of 0's and 1's. One of the high or low charges stored in memory (one 0 or one 1) is called a bit and 8 bits is called a byte. For every computer, each memory cell can hold a certain fixed number of bits, usually 8.
A CONTROL UNIT:
Inside the computer, the remaining two components of the von Neumann Architecture are found on the CPU (Central Processing Unit) chip. The control unit controls the sequencing and timing of all operations. It contains a "clock," that is actually a quartz crystal (Quartz is a type of crystal used in watches, computers, and other devices to keep time. The .0.quartz crystal vibrates or ticks an exact 60-seconds per minute when electricity is applied to it )that oscillates at a regular frequency when electrical power is applied. The clock emits an electronic signal for each oscillation. Each separate operation is synchronized to the clock signal.
The three main elements of the control unit are as follows:
Decoder
This is used to decode the instructions that make up a program when they are being processed, and to determine in what actions must be taken in order to process them. These decisions are normally taken by looking at the opcode of the instruction, together with the addressing mode used. This is covered in greater detail in the instruction execution section of this tutorial.
Timer or clock
The "clock" is the heart beat of any processor...
The processor executes one thing at "a time": the time is given by the clock.
The clock is just an oscillator running 0,1,0,1,0... Each time the clock changes level, the processor executes ONE instruction. (Not totally true, as some instructions require more than one clock, but take it as I said!)
Control logic circuits
The control logic circuits are used to create the control signals themselves, which are then sent around the processor. These signals inform the arithmetic and logic unit and the register array what they actions and steps they should be performing, what data they should be using to perform said actions, and what should be done with the results.
AN ARITHMETIC LOGIC UNIT (ALU):
Also on the CPU chip is circuitry for performing arithmetic and logical calculations. This is called the Arithmetic/Logic Unit or ALU for short. It can be thought of as being similar to a calculator, except that, in addition to normal math, it can also do logical (true/false) operations, such as comparing two numbers to see which one is larger. Logical operations are important in computer programming.
HOW IT ALL WORKS:
No matter what you are doing on a computer, it is always running one or more computer programs. A computer program is just a series of computer instructions. At the most basic level, a computer instruction may be something simple like adding two numbers and storing the result. Even complicated computer programs at the deepest level, the computer just does one thing -- it executes one instruction after another, over and over, millions of times every second.
In the next section we will see how a simplified model of a computer uses the basic hardware components we have discussed (memory, the control unit, and the ALU) - and some we haven't (registers, bus) - in order to execute instructions.
THE INSTRUCTION CYCLE INTRODUCTION THE COMPUTER MODEL :
To illustrate how a computer works - how it executes one instruction - we will use a simplified model of a computer, using the memory, control unit, and ALU componentsthat we have already discussed. The control unit and the ALU are both found on the CPU (central processing unit).
In addition to these main components, there are 3 smaller components within the CPU that require explanation when demonstrating how a computer executes an instruction.
A register is a small, fast unit of memory located on the CPU, and used temporarily for storing data. Because the registers are close to the ALU, they are made out of fast memory, efficientlyspeeding up calculations. This model shows 4 general-purpose registers, but computers usually have 16 or more.
The computer model also needs a decoder - circuitry that will take a computer instruction stored in main memory in binary (as a long string of 0's and 1's) and then convert itto signals that can execute an instruction.
Transmitting data between the different components is done using circuitry known as a data bus or bus.One bus connects memory to the CPU and another bus connects the relevant parts of the CPU.
THE INSTRUCTION CYCLE MACHINE AND ASSEMBLY LANGUAGE INSTRUCTIONS :
What distinguishes a computer from a calculator is that the computer stores its program, the instructions it will be executing, in its own memory. Computer instructions are encoded and stored in memory as a language called machine code or machine language.
However, there is another language called assembly language, which uses more English like words to tell the computer what to do.The upcoming animations will use assembly language to issue commands.
THE INSTRUCTION CYCLE BASIC STEPS OF THE INSTRUCTIONS CYCLE :
At its core, all the computer ever does is execute one instruction in memory after another, over and over. Although there are many different possible (assembly language)instructions that the computer can execute, the basic steps involved in executing an instruction are always the same, and they are called the instruction cycle
1. Fetch the instruction (transfer the instruction from main memory to the decoder)
2. Decode the instruction (from machine language)
3. Execute the instruction (e.g., add, divide, load, store...)
4. Store the result (for instructions like ADD,place the 'answer' in the specified register.)
The control unit guides the computer's components through this cycle to execute one instruction.
When that instruction is done, the cycle starts all over again with the next instruction.
There is a special register, called the program counter (PC) that stores the address of the next instruction.
In the example above the PC says the next instruction is in memory location 8.
The decoder will decode the instruction. This instruction says to store the data in R2 in memory location 2000
For this instruction, there is not a separate STORE step - the instruction is done.
SUMMARY :
Throughout their brief history, the physical appearance of computers has changed dramatically, but their basic function - to store and execute a series of instructions - has remained the same.The von Neumann model of computer architecture characterizes computers as having four functional units: I/O, Memory, Control Unit and ALU.Basically all the computer ever does is repeat the four steps of the instruction cycle -- fetch, decode, execute and store -- over and over.
2nd version of VON NEUMANN ARCHITECTURE
Once a program is in memory it has to be executed. To do this, each instruction must be looked at, decoded and acted upon in turn until the program is completed. This is achieved by the use of what is termed the 'instruction execution cycle', which is the cycle by which each instruction in turn is processed. However, to ensure that the execution proceeds smoothly, it is also necessary to synchronize the activities of the processor.
To keep the events synchronized, the clock located within the CPU control unit is used. This produces regular pulses on the system bus at a specific frequency, so that each pulse is an equal time following the last. This clock pulse frequency is linked to the clock speed of the processor - the higher the clock speed, the shorter the time between pulses. Actions only occur when a pulse is detected, so that commands can be kept in time with each other across the whole computer unit.
The instruction execution cycle can be clearly divided into three different parts, which will now be looked at in more detail. For more on each part of the cycle click the relevant heading, or use the next arrow as before to proceed though each stage in order.
Fetch Cycle
The fetch cycle takes the address required from memory, stores it in the instruction register, and moves the program counter on one so that it points to the next instruction.
Decode Cycle
Here, the control unit checks the instruction that is now stored within the instruction register. It determines which opcode and addressing mode have been used, and as such what actions need to be carried out in order to execute the instruction in question.
Execute Cycle
The actual actions which occur during the execute cycle of an instruction depend on both the instruction itself, and the addressing mode specified to be used to access the data that may be required. However, four main groups of actions do exist, which are discussed in full later on.
The first part of the instruction execution cycle is the fetch cycle. Once the instruction has been fetched and stored in the instruction register, it must then be decoded.
Once the instruction has been fetched and is stored, the next step is to decode the instruction in order to work out what actions should be performed to execute it. This involves examining the opcode to see which of the machine codes in the CPU's instruction set it corresponds to, and also checking which addressing mode needs to be used to obtain any required data. Therefore, using the CPU model from this tutorial, bits 16 to 23 should be examined.
Once the opcode is known, the execution cycle can occur. Different actions need to be carried out dependant on the opcode, with no two opcodes requiring the same actions to occur. However, there are generally four groups of different actions that can occur:
- Transfer of data between the CPU and memory.
- Transfer of data between the CPU and an input or output devices.
- Processing of data, possibly involving the use of the arithmetic and logic unit.
- A control operation, in order to change the sequence of subsequent operations. These can possibly be conditional, based on the values stored at that point within the flag register.
For greater simplicity, and as describing all the possible instructions is unnecessary, the following tutorial pages will only look at a few possible instructions. These are:
Mnemonic / DescriptionMOV / Moves a data value from one location to another
ADD / Adds to data values using the ALU, and returns the result to the accumulator
STO / Stores the contents of the accumulator in the specified location
END / Marks the end of the program in memory
The four instructions used in the examples for the remainder of this section of the tutorial
The following three pages of the tutorial will look at the first two of these instructions, and how they are executed in each of the three main addressing modes. These addressing modes are:
Immediate addressing
With immediate addressing, no lookup of data is actually required. The data is located within the operands of the instruction itself, not in a seperate memory location. This is the quickest of the addressing modes to execute, but the least flexible. As such it is the least used of the three in practice.
Direct addressing
For direct addressing, the operands of the instruction contain the memory address where the data required for execution is stored. For the instruction to be processed the required data must be first fetched from that location.
Indirect addressing
When using indirect addressing, the operands give a location in memory similarly to direct addressing. However, rather than the data being at this location, there is instead another memory address given where the data actually is located. This is the most flexible of the modes, but also the slowest as two data lookups are required.
The first of the three addressing modes to be looked at is immediate addressing. When writing out the code in mnemonic form, operands that require this mode are marked with a # symbol. With immediate addressing, the data required for execution of the instruction is located directly within the operands of the instruction itself. No lookup of data from memory is required.
The next of the three addressing modes that will be looked at is direct addressing.
The second of the three addressing modes to be looked at is direct addressing. When writing out the code in mnemonic form, no symbol is required to mark operands which use this form. Direct addressing means that the operands of the instruction hold the address of the location in memory where the data required can be found. The data is then fetched from this location in order to allow the instruction to be executed. The final of the three modes of addressing to be looked at is indirect addressing .