ECE 101

ECE 101 ECE 101 - Start

2017-01-16 37K 37 0 0

Description

Exploring Electrical Engineering. Chapter . 9. Programming Development Environment. Herbert G. Mayer, PSU. Status . 3. /1/. 2016. Syllabus. What is a Program?. What is a Computer?. Holding Data. Programming Languages. ID: 510365 Download Presentation

Embed code:
Download Presentation

ECE 101




Download Presentation - The PPT/PDF document "ECE 101" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.



Presentations text content in ECE 101

Slide1

ECE 101Exploring Electrical EngineeringChapter 9Programming Development Environment

Herbert G. Mayer, PSU

Status

3

/1/

2016

Slide2

Syllabus

What is a Program?

What is a Computer?

Holding Data

Programming Languages

Machine Language Sample

Compiler

Linker

Loader

Slide3

What is a Program

A computer

program

is a sequen

ce

of executable machine instructions, reading information (input), computing new data, and generating output, according to the steps of an algorithm

An

a

lgorithm

is a finite sequence of instructions,

reading information (input), computing new data, and generating

output

The two are almost synonymous, except that the program

executes

(AKA runs)

on a computer, the algorithm is just an abstraction in our mind or written on paper

Slide4

What is a Program

The algorithm coded in a programming language becomes your

program

(noun)

Why relevant to Electrical Engineers?

Sooner or later you will acquire programming skills

Either in a general purpose programming language

Or a special programming language controlling a connected board

Can be external or inserted internal into backplane of a computer

But you will

program

(verb) eventually

Slide5

What is a Computer

A

computer

is a physical device that can read input, compute, and produce corresponding output

It “understands” a small set of

machine instructions

, which it can execute, one at a time (for a

uni

-processor

)

It is possible, but very tedious, to write a

program in such machine instructions

An

Assembler

eases this tediousness by allowing users to write abstract data and symbolic instructions, which the assembler then translates into machine code

A

compiler

(similar: an interpreter) reads higher-level programs and maps them into assembly code; or sometimes into machine code directly

And you, EEs, will design and build the next generation of computers

Slide6

What is a Computer

Main Memory

(RAM, ROM)

Auxiliary Storage

(e.g., disk drives)

Input

(e.g., keyboard, mouse)

Output

(e.g., monitor, printer)

Processor

(CPU)

Slide7

Computer’s Processor – CPU or ALU

Registers

(fast

storage)

Memory Interface

Instruction Decoder

To main memory

The ALU (Arithmetic Logic Unit) performs basic arithmetic, logic, and comparison operations.

ALU

Slide8

Holding Data

A computer holds a good amount of data in

memory

The

size

of such a memory (AKA primary storage) is defined by the architecture’s

address range

E.g. on a 32-bit architecture, memory can be as large as

2

32

different addressable units

Often such units are

bytes

, i.e. 8-bit addressable, contiguous units; other architectures use 60-bit words

Large amounts of data are stored on

secondary

storage devices, such as rotating disks or SSDs

Access to data in

memory is slow

, about 10-100 times slower than executing one instruction

Access to data on disk is even 10,000s of times slower

Slide9

Holding Data

Getting data from memory into the processor (usually a machine register) is called a

load

operation

Moving data from a register to memory is called a

store

operation

Such transport proceeds on a

bus

; the width of the bus and its speed are critical for the overall execution speed of the machine and thus of your programs

Slide10

Programming Languages

Even writing

assembly source

code is highly tedious

Since the 1960s,

higher-level

programming languages have been developed

Some of these are

machine-independent

; others highly machine-dependent (AKA architecture-dependent), e.g. C++ or Java

A machine-independent language allows writing of source programs (code) that can be

executed on different machines

, provided a compiler is available on each

Th

is is referred to a

portability

of source programs, quite a desirable property!

Slide11

Programming Language Milestones

Slide12

1969 to 1973

– C (Bell Labs initial development)1978 – K&R C (Kernighan and Ritchie)1989 – C89 (ANSI)1990 – C90 (ISO)1995 – C90 Normative Amendment 1 → "C95”1999 – C99 (ISO)2011 – C11 (ISO)

C Language Milestones

Slide13

Machine Language Sample

600: A9 5A LDA #$5A ; Load accumulator with number

602: 18 CLC ; Clear carry flag

603: 69 20 ADC #$20 ; Add $20 to accumulator w/carry

605: 8D 00 10 STA $1000 ; Store accumulator at $1000

A

ssembler

translates an assembly program to machine language

Assembly

language still requires a high level of programmer expertise

Slide14

Compiler

Compiler is a special-purpose system program that reads source programs, written in the

source language

and translates them into machine language

Mapping into machine language (AKA object code) sometimes involves an intermediate step:

C

reating assembly source first, and then using the assembler to generate machine code

A compiler generally understands just

one input language

; exceptions are some C++ compilers that also read C source

Compilers emit error messages when certain violations are detected, referring messages to line numbers

Slide15

Compiler

Source files contain the

C++

program

code

.

cpp

extension (file is in text format

); also

.c

Header files can contain prototypes, macros, data type declarations, or

source code

.h

extension (file is in text format)

Object files contain intermediate compiled

code

.o

-or-

.

obj

extension

Executable files contain runnable binary

code

.out

-or-

.exe

-or- no extension

Slide16

Compiler

preprocessor

→ handles preprocessor directives and expands macro

definitions

compiler

→ takes preprocessed source code files and translates them to intermediate

code; for beginners it is convenient to view the other system programs as part of

t

he compiler

assembler

→ takes intermediate code files and translates them to binary object

code

linker

→ resolves references among the object files and the libraries. It puts all the parts together to create the

single, final,

executable

object file

Slide17

16

prog_1.c

prog_2.c

prog_3.c

etc.

Source files

prog_1.o

prog_2.o

prog_3.o

etc.

Object files

prog

Executable

file

stdio

stdlib

math

etc.

Library files

Compiler

Preprocessor

Linker

prog_1.h

prog_2.h

prog_3.h

etc.

User

Header files

stdio.h

stdlib.h

math.h

etc.

Library

Header files

Assembler

Compiler

Slide18

Linker

Often programs are composed of

multiple source

programs

For example, some projects are too large to have a single programmer develop all code in sequence

Also system function, such as

input, output, heap

acquisitions etc. are provided in the PDE, and do need to be coded by the programmer

All such elements are

linked together

into a single, executable object program

That is the work of the

system’s linker

For

C or C++ on

Unix the link step is frequently hidden, i.e. not visible to the programmer

Slide19

Loader

When a program has been linked, it is still not

executing, not even loaded!

Instead, it is just a binary file, residing on some disk, as an object

file, but ready to run

To run such object code, it must be loaded into memory and be granted processor execution time

That is the purpose of the system loader

Generally, the loader and load function are not directly visible to the user = programmer

Slide20

19

Example: Vintage CPU (1975)MOS 6502Chuck Peddle at MOSSingle core8-bit dataMemory64 KB mainRegisters:Accumulator (A)Index (X, Y)Processor Status (P)Stack Pointer (S)Program Counter (PC)Speed: 1 to 2 MHz <- not a typo!Process: 8 m# of transistors: ~3500

Die Shot

Pin-out

Slide21

20

Example: Modern CPU (2013)Intel i7-4770 HaswellFour cores = processors = CPUs64-bit dataMemory4x256 KB L2 cache8 MB L3 cache32 GB main (3.2x107 KB)Registers:8 32-bit16 64-bitIntegrated GPUSpeed: 3.4 GHz (3400 MHz)Process: 22 nm (0.022 m)# of transistors: ~1.4 billion

Die Shot

Package

Slide22

Slide23

Slide24


About DocSlides
DocSlides allows users to easily upload and share presentations, PDF documents, and images.Share your documents with the world , watch,share and upload any time you want. How can you benefit from using DocSlides? DocSlides consists documents from individuals and organizations on topics ranging from technology and business to travel, health, and education. Find and search for what interests you, and learn from people and more. You can also download DocSlides to read or reference later.