Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

CALCULATOARE NUMERICE

Bibliografie:

Noam Nisan and Shimon Schocken - “The Elements of Computing Systems”, MIT Press, 2005.

slide 1
Pe scurt

Obiective:

 Intelegerea modului in care sunt construite sisteme hardware si software si


cum lucreaza impreuna

 Invatarea modalitatilor de impartire a unor probleme complexe in altele mai


simple

 Invatarea modului de planificarea si realizare a proiectelor de dezvoltare a


sistemelor complexe

Metodologie:

 Construirea unui calculator complet, de uz general si functional.

 Experimentarea cu acest calculator.

slide 2
Detalii
 6 proiecte, realizabile individual sau in echipe de cate 2

 Proiectele hardware sunt dezvoltate si simulate in HDL (Hardware


Description Language)

 Proiectele software pot fi realizate in orice limbaj de programare


(recomandabil Java)

 Metodologia proiectelor:

 Se dau API-uri si materiale de test

 Studentii realizeaza implementarea

 Instrumente: simulatoare, tutoriale, scripturi de test

slide 3
Demo

Pong, 1985 Pong, 2011

Pong, pe
computer

slide 4
Structura cursului

Human Abstract design Software


abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language

Assembler

Chapter 6

abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

(Abstraction–implementation paradigm)

slide 5
Nivelul aplicatiei: (de exemplu Pong)

Ball
abstraction

Bat
abstraction

slide 6
Human Abstract design Software
abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language

Assembler

Chapter 6

abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

slide 7
Nivelul programului la nivel inalt (limbajul Jack)
/** A Graphic Bat for a Pong Game */
class Bat {
field int x, y; // screen location of the bat's top-left corner
field int width, height; // bat's width & height

// The class constructor and most of the class methods are omitted

/** Draws (color=true) or erases (color=false) the bat */


method void draw(boolean color) {
do Screen.setColor(color);
Apelare tipica a
do Screen.drawRectangle(x,y,x+width,y+height);
return;
unei metode a
} sistemului de
operare
/** Moves the bat one step (4 pixels) to the right. */
method void moveR() {
do draw(false); // erase the bat at the current location
let x = x + 4; // change the bat's X-location
// but don't go beyond the screen's right border
Ball
if ((x + width) > 511) { abstraction
let x = 511 - width; Bat
} abstraction

do draw(true); // re-draw the bat in the new location


return;
}
}

slide 8
Nivelul sistemului de operare (Jack OS)
/** An OS-level screen driver that abstracts the computer's physical screen */
class Screen {
static boolean currentColor; // the current color

// The Screen class is a collection of methods, each implementing one


// abstract screen-oriented operation. Most of this code is omitted.

/** Draws a rectangle in the current color. */


// the rectangle's top left corner is anchored at screen location (x0,y0)
// and its width and length are x1 and y1, respectively.
function void drawRectangle(int x0, int y0, int x1, int y1) {
var int x, y;
let x = x0;
while (x < x1) {
let y = y0;
while(y < y1) {
do Screen.drawPixel(x,y);
let y = y+1; Ball
abstraction
}
Bat
let x = x+1; abstraction

}
}
}

slide 9
Human Abstract design Software
abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language

Assembler

Chapter 6

abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

slide 10
Metoda moderna de complilare

slide 11
Compilare efectiva

Cod intermediar
>
Cod sursa push x
Generare push width
(x + width) > 511 parsare + 511 cod add
push 511
gt
x width

Abstractizare Analiza Arbore de Siteza Implementare


sintactica parsare semantica

slide 12
Masina virtuala (VM) (VM bazata pe stiva, similara cu cea Java JVM)
memory (before) s2
if ((x+width)>511) {
let x=511-width; ... 75
} width 450 450
... sp
// VM implementation x 75
push x // s1 ...
push width // s2
s4 s5 s9
add // s3
push 511 // s4 525 1 511
gt // s5 511 sp 450
if-goto L1 // s6 sp sp
goto L2 // s7
L1:
push 511 // s8 s10 memory (after)
push width // s9
61 ...
sub // s10
sp width 450
pop x // s11
...
L2:
x 61
...
...

slide 13
Human Abstract design Software
abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language

Assembler

Chapter 6

abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

slide 14
Programare de nivel jos (pe calculatorul Hack)

Virtual machine program

...
push x
push width
add
push 511 VM
translator Assembly program
gt
if-goto L1 // push 511
goto L2 @511
L1: D=A // D=511
push 511 @SP
push width A=M
Assembler
M=D // *SP=D
Executable
sub
pop x @SP
@SP 0000000000000000
L2: M=M+1 // SP++ 1110110010001000
...

slide 15
Human Abstract design Software
abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language

Assembler

Chapter 6

abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

slide 16
Semantica limbajului masina (platforma Hack)

Code semantics, asa cum este interpretata de platforma hardware Hack

Instruction code
Address
(0=“address” inst.)

Code syntax
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0000000000000000 @0
1111110111001000 M=M-1
1 1 1 1 1 1 0 1 1 1 0 0 1 0 0 0

Instruction code ALU Destination Jump


(1=“compute” inst.) operation code Code Code

(M-1) (M) (no jump )

 Avem nevoie de o arhitectura hardware care sa realizeze aceasta


semantica
 Platforma hardware trebuie proiectata pentru:
 A parsa instructiunile, si
 A le executa.
slide 17
Arhitectura calculatorului (platforma Hack)

instruction

D
Data

ALU
Instruction Memory
Memory A
data out (M)
M

address of next
instruction
Program data in RAM(A)
Counter

 O masina tipica von Neumann

slide 18
Human Abstract design Software
abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language

Assembler

Chapter 6

abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

slide 19
Proiectare logica

 Logica combinationala (care conduce la ALU)

 Logica secventiala (care conduce la RAM)

 Punerea tuturor elementelor impreuna (care conduce la

Computer)

Folosind … porti logice.

slide 20
Porti logice
 Platforma Hardware = o multime de chip-uri inter-conectate

 Chip-urile sunt realizate din altele mai simple pana la porti logice

 Poarta logica = element hardware element care implementeaza o anumita


functie Booleana

 Fiecare chip si poarta are o interfata, care specifica CE realizeaza si o


implmentare, care specifica CUM realizeaza.
Interfata Implementare

a a
Xor out And
b Not

Or out
a b out
Not
0 0 0
And
0 1 1 b
1 0 1
1 1 0

slide 21
Hardware Description Language (HDL)

a
And
Not

Or out

Not
And
b CHIP Xor {
IN a,b;
OUT out;
PARTS:
Not(in=a,out=Nota);
Not(in=b,out=Notb);
And(a=a,b=Notb,out=w1);
And(a=Nota,b=b,out=w2);
Or(a=w1,b=w2,out=out);
}

slide 22
Interfata O optiune de implementare (CMOS)

a
Nand out
b

a b out
0 0 1
0 1 1
1 0 1
1 1 0

slide 23
Human Abstract design Software
abstract interface
Thought hierarchy
Chapters 9, 12
H.L. Language Compiler
& abstract interface
Chapters 10 - 11
Operating Sys.
Virtual VM Translator
abstract interface
Machine Chapters 7 - 8

Assembly
Language
Pe scurt:
Assembler Realizarea acestui
Chapter 6
calculator
de jos in sus
abstract interface
Computer
Machine Architecture
abstract interface
Language
Chapters 4 - 5
Hardware Gate Logic
abstract interface
Platform Chapters 1 - 3 Electrical
Chips & Engineering
Hardware Physics
Logic Gates
hierarchy

slide 24

You might also like