Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be...

22
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission

Transcript of Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be...

Page 1: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Levels ofArchitecture & LanguageCHAPTER 1

© copyright Bobby Hoggard / material may not be redistributed without permission

Page 2: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Low Levels of Languages

Level L0:

The set of instructions that can be directly executed by the computer

Machine language

Level L1:

A set of instructions that are easier to use than L0

Assembly language

Cannot be directly executed by the computer

Need to translate L1 programs into equivalent L0 programs

Page 3: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Compilers (translators)

A L0 program that reads lines of a L1 program, and outputs copies of them in L0 language

Performs a one-time translation from L1 to L0

The translation process is fairly simple

Substitutes each L1 command with an equivalent L0 command

We will have two copies of the program (one in L1 language and one in L0)

If program changes are needed, you change the L1 program and then you must re-translate

Page 4: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Interpreters (Virtual Machines)

A L0 program that reads L1 programs and executes them directly

L1 line 1 read by the interpreter executed by the interpreter

L1 line 2 read by the interpreter executed by the interpreter

L1 line 3 read by the interpreter executed by the interpreter

Execution is done by performing an equivalent set of L0 instructions

Will not have a copy of the L1 program in L0 language

“Translation” is performed every time the program executes

Two programs execute: the interpreter + the L1 program (data to the interpreter)

If changes are needed, you simply change the L1 program (no translation step)

Page 5: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Low Level Languages (summary)

L0 = machine language / L1 = assembly language

One-to-one translation of the lines

i.e. a 7-line L1 program will produce a 7-line L0 program

Easy to translate

Translation is performed by fairly simple substitution

Programs are long (many steps required to do simple tasks)

Machine dependent

Page 6: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Level L0: Machine Language

The set of instructions that can be directly executed by the computer

Language of 1’s and 0’s

Commands are combinations of 1’s and 0’s

Ex: a command to perform addition: 10110

Data are combinations of 1’s and 0’s

Ex: the data to be added: 10110 and 11100

Memory cells are addressed with combinations of 1’s and 0’s

Ex: put the answer from the addition into memory cell 10110

Can’t distinguish the data from the commands or memory cells

Page 7: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Level L1: Assembly Language

A set of instructions that are easier to use than L0

Uses words to represent machine language commands

Ex: a command to perform addition: ADD

Uses numbers for data

Ex: the data to be added: 22 and 28

Can use also use words for data (strings)

Uses words to represent memory cells (variables)

Page 8: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Level L1: Translation

Translation from assembly language into machine language is done by a type of compiler called an assembler

Level L1

ADD 22 28

Level L0

10110 10110 11100

Page 9: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

How Assemblers Use Variables

Program without variables

00: Add mem cells 04 and 06

02: Halt

04: 0005

06: 0008

Program with variables

Add mem cells X and Y

Halt

X: 0005

Y: 0008

Adding a line to this program will require updating the memory cells used in line 04 and 06

Adding a line to this program will not require updating any memory cell references

Page 10: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Low Level vs. High Level Languages

Low Level Languages

One-to-one translation

Easy to translate

Programs are long

Machine dependent

High Level Languages One high level line translates into several lower level

lines

A 5-line L3 program might translate into a 50-line L0 program

Harder to translate

Translation often requires looking at the meaning of several lines of code rather than just performing a simple substitution

Programs are much shorter

Machine Independent

Programs written in a high level language can be moved to a different machine architecture and will still work

Page 11: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

High Level Languages

Level L2:

Uses sentences to 1) say what you want to do and 2) explain how to do it

Ex: C, C++, Java, Basic, Pascal, Fortran, COBOL, php

Level L3:

Uses sentences to say what you want to do

Ex: SQL, *Prolog

Level L4:

Natural language

Ex: English, Spanish, Pictures

*note: many references classify Prolog as Level L4 language

Page 12: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

High Level Language Comparison

Level L4Print the last name of all customers whose balance is above 100

Level L3SELECT LastName

FROM Customer

WHERE Balance > 100

Level L2try {

in = new Scanner(new FileReader(“customer.txt”);

while (in.hasNext()) {

name = in.next();

balance = in.nextInt();

if (balance > 100)

System.out.println(name);

}

}

Requires some knowledge of the data file structure

Requires no knowledge of the data file structure

Requires a lot of knowledge of the data file structure

English

SQL

Java

Page 13: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Generations of Languages

1st 2nd 3rd 4th 5th

MachineLanguage

AssemblyLanguage

Easier for humans to read

NaturalLanguage

generation generation generation generation generation

Easier to translate to machine language

SoftwareDevelopment

Language

ProblemSolving

Language

Low Level Languages High Level Languages

Page 14: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture

The set of “items” that can be seen and directly used at any particular level

Includes things like how much memory is available

Does not include things like what kind of technology is used to implement the memory

Levels of architecture

Defines different sets of items with which to work

High levels of architecture “hide” the low level items

Makes the entire system easier to work with

Page 15: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture Levels – L0

Digital logic level (digital systems course)

AND, OR, and NOT gates

These gates are assembled to create larger circuits (which can be packaged into a single chip)

Arithmetic Circuits, Counters, Multiplexers, Encoders, etc.

Memory

Flip-flops hold 1 bit of information each

Registers a combination of several flip-flops working together to store multiple bits

Ex: A 32-bit register = a combination of 32 flip-flops where each store a single bit at the same time

Page 16: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture Levels – L1

Microarchitecture level (architecture course)

ALU (arithmetic logic unit)

A chip capable of performing arithmetic and logic operations

Programming involves using binary numbers to select an operation

Ex: 2-wires (input to the ALU) used to select an operation to perform

00 = ADD 01 = SUB 10 = MUL 11 = DIV

Registers

Memory cells to hold commands and data

Page 17: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture Levels – L1 (cont)

Data Path

The path that data follows when flowing from circuit to circuit

Often forms a complete circle

Programming involves using binary numbers to:

Turn on some circuit outputs while turning off othersThis allows data to flow out of some circuits while blocking the flow of data from others

Turn on some circuit inputs while turning off othersThis allows data to be stored into some circuits, while preventing it from being stored in others

Page 18: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture Levels – L1 (cont)

Microprogram (possibly)

A program which controls the ALU, data path and registers to make them work properly

Usually embedded in a ROM (read only memory) chip

In a special purpose computer (ex: a microwave), this is the only program that the computer ever executes

In this computer, a RAM chip would be used to hold data needed by the program, such as user inputer

In a general purpose computer (ex: a PC), this program is an interpreter

Interpreter = a program which fetches, decodes, and executes instructions from a higher level language

This interpreter is what allows the PC to execute different programs

In this computer, a RAM chip holds both a program to be executed and the data the program needs

Page 19: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture Levels – L2

ISA level (Instruction Set Architecture) (architecture/assembly language courses)

Machine Language Level

Registers

Memory cells to hold commands and data

A different set, and by different names, than the ones from L1

ALU

Page 20: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Architecture Levels – Higher Levels

Level 3: Operating System level (operating systems course)

Combination of level 2 + some new instructions

Usually has a different memory organization

Ability to execute two concurrent programs

Level 4: Assembly Language level (assembly language course)

Level 5: High Level Languages (traditional programming courses)

Page 21: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

von Neumann Architecture

Memory

Control Unit

Arithmetic Logic Unit

Input

Output

Page 22: Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.

Omnibus Architecture

CPU Memory Console Tape I/O

Bus: a collection of parallel wires connecting various computer components