Presentation is loading. Please wait.

Presentation is loading. Please wait.

Datapath and control Dr. ir. A.B.J. Kokkeler 1. What is programming ? “Programming is instructing a computer to do something for you with the help of.

Similar presentations


Presentation on theme: "Datapath and control Dr. ir. A.B.J. Kokkeler 1. What is programming ? “Programming is instructing a computer to do something for you with the help of."— Presentation transcript:

1 Datapath and control Dr. ir. A.B.J. Kokkeler 1

2 What is programming ? “Programming is instructing a computer to do something for you with the help of a programming language” Different ways to control a computer: High level programming language (e.g. JAVA) No details of the hardware, easier to program but less efficient code Low-level programming language (e.g. C) More hardware knowledge required, more control, more efficient Assembly (machine instructions) Detailed hardware knowledge, Ultimate control, Highly efficient Simple to use more control runs faster

3 A C program #include int main(void) { int a; a = 10; printf("a is now %d\n", a); a = a + 15; printf("a is now %d\n", a); return 0; } Output: a is now 10 a is now 25

4 From C code to program execution (1) C code a = a + 15; Machine code (.exe file) 0100 00000010 0110 00001111 0101 00000010 assembler Assembler code load R2 add 15 store R2 compiler editor execute Data Example: Together also often called compiler Explained in this lecture. Interpretation of this code is described in the Instruction Set Architecture (ISA) Level used in the project

5 Processor blockdiagram 5

6 Processors Important elements – Combinatorial circuits Operations on binary signals – Switches Selection of 1 out of multiple – Memory elements Registers Memories – Clock signal 6

7 Combinatorial circuits + 1 0 1 Input signals are presented Collection of transistors is executing the calculation This takes time After some time, the result is available ‘+’ indicates the arithmetic operation ‘addition’ 3 Volt 0 Volt 3 Volt 7

8 Combinatorial circuits + 1 0 0 1 1 1 lsb msb Input signals are presented Collection of transistors is executing the calculation This takes time After some time, the result is available 8

9 Combinatorial circuits + 01 10 11 2 2 2 Input signals are presented Collection of transistors is executing the calculation This takes time After some time, the result is available 9

10 Combinatorial circuits * 01 10 Except + and * there are many other operations Input signals are presented Collection of transistors is executing the calculation This takes time After some time, the result is available ‘*’ indicates the arithmetic operation ‘multiplication’ 10

11 Switches * 10 + 01 10 11

12 Switches * 10 + 01 10 11 10 This switch has two options => Control uses 1 bit 12

13 Switches * 10 + 01 10 11 0 13

14 Switches * 10 + 01 10 11 10 1 14

15 * 10 + 01 10 11 10 1 (very simple) ALU Data Instruction (0 = ‘+’ 1 = ‘*’) ALU = Arithmetic & Logic Unit 15

16 Memory elements Where do data and instruction come from? Where is data going to? Three options – (individual) register – Register banks (“registers” in AVR blockdiagram) – Memory banks (“memory” in AVR blokdiagram) ALU Data in Data out Instruction 16

17 Register Data out 0 0 17

18 Register Data out 1 1 18

19 Register Data out Data in 1 1 0 19

20 Register Data out Data in 0 0 0 01 At a transistion from 0 to 1 on this input, “Data in” is stored and “Data out” takes over this value Reasoning backwards: “Data in” comes from -Another memory element -“outside” the processor (I/O) Reasoning forward: “Data out” goes to -Another memory element -“outside” the processor (I/O) In both cases, data can pass via combinatorial circuits, e.g. an ALU 20

21 Register Data out Data in 8 01 8 Storage of 8 bits At a transistion from 0 to 1 on this input, “Data in” is stored and “Data out” takes over this value 21

22 Register banks 22

23 Register banks Switch with 4 possible positions => coded via 2 bits 00 Data out 23

24 Register banks 01 Data out Switch with 4 possible positions => coded via 2 bits 24

25 Register banks 10 Data out Switch with 4 possible positions => coded via 2 bits 25

26 Register banks 11 Read address Data out Switch with 4 possible positions => coded via 2 bits 26

27 Register banks 11 Read address 00 Write address 01 Data in Data out Switch with 4 possible positions => coded via 2 bits Switch with 4 possible positions => coded via 2 bits 27

28 Register banks 11 01 01 Data in Data out Switch with 4 possible positions => coded via 2 bits Switch with 4 possible positions => coded via 2 bits Read address Write address 28

29 Register banks 11 10 01 Data in Data out Switch with 4 possible positions => coded via 2 bits Switch with 4 possible positions => coded via 2 bits Read address Write address 29

30 Register banks 11 01 Data in Data out Switch with 4 possible positions => coded via 2 bits Switch with 4 possible positions => coded via 2 bits Read address Write address 30

31 Register banks 1 1 0 0 0 1 1 1 1 0 0 0 Data out Read address Data in Write address Register bank 01 31

32 Register bank (RB) RB Read address Write address Data out Data in 01 32

33 Memory (MEM) Same functionality as Registerbank Read and Write not simultaneously => 1 address input + additional line that indicates read or write Consists of a lot more memory elements (larger address range) MEM R/W address Data out Data in 1 bit that indicates whether you read or write 01 33

34 Register bank (RB) In Atmega: Two registers can be read from the same bank RB Read adddress 1 Data out 1 Data in Data out 2 01 Read address 2 Write address 34

35 Clock signal ALU Data in Data out Instruction RB Read address 1 Data out 1 Data in Data out 2 01 Read address 2 Write address 35

36 Clock signal ALU Data in Data out RB Data in Clock Data available for ALU ALU busy Result of ALU can be taken over Instruction Read address 1 Read address 2 Write address 36 New Data available for ALU Again, result of ALU can be taken over ALU busy Because of the clock, time is divided into ‘timeslots’. What happens during a timeslot is determined by Read addresses 1 and 2, Write address and Instruction

37 Clock signal ALU Data in Data out RB Data in Clock timeslot i: Read address 1, Read address 2, Instruction, Write address timeslot i timeslot i+1 Instruction Read address 1 Read address 2 Write address Data available for ALU Result of ALU can be taken over timeslot i+1: Read address 1, Read address 2, Instruction, Write address 37

38 Program timeslot i: 0, 0, 1, 1 timeslot i+1: 1, 0, 0, 2 Example What calculation is executed here? timeslot i: Read address 1, Read address 2, Instruction, Write address timeslot i+1: Read address 1, Read address 2, Instruction, Write address 38

39 Program timeslot i:0, 0, 1, 1 timeslot i+1: 1, 0, 0, 2 Example Instruction (0 = ‘+’ 1 = ‘*’) Register 0‘*’ Register 1 Register 0 Register 1 Register 2 ‘+’ R2 = (R0*R0)+R0 This way, lists of tasks (instructions) can be made that have to be executed on consecutive timeslots = Program Program is stored in a memory = Program memory timeslot i: Read address 1, Read address 2, Instruction, Write address timeslot i+1: Read address 1, Read address 2, Instruction, Write address What calculation is executed here? 39

40 Program ALU Data in Data out RB Data in Clock Read address 1, Read address 2, Instruction, Write address Counter that is Incremented each timeslot and points to the active instruction = Program counter Program memory timeslot i timeslot i+1 Data available for ALU Result of ALU can be taken over Read address 1, Read address 2, Instruction, Write address 40

41 Program ALU Data in Data out RB Data in Clock 10 Program counter 00 01 10 11 Read address 1, Read address 2, Instruction, Write address timeslot i timeslot i+1 Data available for ALU Result of ALU can be taken over 41

42 Program for ATmega ALU Data in Data out RB Data in Clock 10 address 1, address 2, Instruction Program counter 00 01 10 11 address 1, address 2, Instruction timeslot i timeslot i+1 Data available for ALU Result of ALU can be taken over 42

43 Program for ATmega Instruction, address 1, address 2 For the atmega, the order is 1.Instruction 2.Address 1 which acts as both ‘source’ and ‘destination’ address 3.‘Source’ address 2 address 1, address 2, Instruction Instruction, address 1, address 2 43

44 Program for ATmega Examples are based on arithmetic operations (addition, multiplication) Indicated as: 0 = ‘+’ en 1 = ‘*’ In programs operations are coded by ‘Mnemonics’. For example ‘+’ = ADD, ‘*’ = MUL. 44

45 Program for ATmega Atmega can do a lot more than addition and multiplication (has more instructions and thus more hardware blocks than “RB” and “ALU”) – Data movement MOV (move): between registers LD (load) and ST (store): amongst others between registers and memory IN and OUT: All other addressable elements – Adjusting the program counter JMP: fill the program counter with another value => the next timeslot, not the ‘next’ instruction will be executed but execution will proceed at another point in program memory. – …….. 45

46 Unconditional Jump ALU Data in Data uit RB Data in Clock 00 address 1, address 2, Instruction Program counter 00 01 10 11 address 1, address 2, Instruction 46

47 Unconditional Jump ALU Data in Data out RB Data in Clock 01 Program counter address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 47

48 Unconditional Jump ALU Data in Data out RB Data in Clock 10 Program counter address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 48

49 Unconditional Jump ALU Data in Data out RB Data in Clock 11 Program counter address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 49

50 Unconditional Jump ALU Data in Data uit RB Data in Clock 00 address 1, address 2, Instruction Program counter 00 01 10 11 address 1, address 2, Instruction 50 00 JMP

51 Unconditional Jump ALU Data in Data out RB Data in Clock 01 Program counter address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 51 00 JMP

52 Unconditional Jump ALU Data in Data out RB Data in Clock 10 Program counter At a JMP instruction: -Program counter is not increased automatically -Value in the address field is loaded into the Program counter address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 00 JMP address 1, address 2, Instruction 52

53 Unconditional Jump ALU Data in Data out RB Data in Clock 00 Program counter address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 00 JMP address 1, address 2, Instruction 53 At a JMP instruction: -Program counter is not increased automatically -Value in the address field is loaded into the Program counter

54 Unconditional Jump ALU Data in Data out RB Data in Clock 00 Program counter This way, ‘loops’ can be realized. address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 00 JMP address 1, address 2, Instruction 54

55 Conditional Jump ALU Data in Data out RB Data in Clock 00 Program counter ==01 Zero Flag there are multiple of these Flags, each with its own condition address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 55 00 BREQ

56 Conditional Jump ALU Data in Data out RB Data in Clock 00 Program counter ==01 Zero Flag there are multiple of these Flags, each with its own condition address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 56 00 BREQ

57 Conditional Jump ALU Data in Data out RB Data in Clock 10 Program counter Data that belongs to this instruction (CP, CPI, SUB and SUBI) is used during the BREQ instruction ==01 Zero Flag address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 00 BREQ address 1, address 2, Instruction 57

58 Conditional Jump ALU Data in Data out RB Data in Clock 00 Program counter If Zero Flag == 1 ==01 Zero Flag Data that belongs to this instruction (CP, CPI, SUB and SUBI) is used during the BREQ instruction address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 00 BREQ address 1, address 2, Instruction 58

59 Conditional Jump ALU Data in Data out RB Data in Clock 11 Program counter If Zero Flag == 0 ==00 Zero Flag Data that belongs to this instruction (CP, CPI, SUB and SUBI) is used during the BREQ instruction address 1, address 2, Instruction 00 01 10 11 address 1, address 2, Instruction 00 BREQ address 1, address 2, Instruction 59

60 Processor blockdiagram 60

61 Assignment Learning objectives – Design an embedded system involving both hardware and software – Implement the system – Test the system 61

62 Assignment Activities – Weeks 1+2: Tuesday March 15, 2015 – Lecture Philips – Lecture on Cyberphysical Systems – Introduction to the assignment Getting familiar with the Arduino kit and development environment Write a project proposal (deadline, Monday, March 27, 9:00 h.) 62

63 Assignment Activities – Weeks 3+4: Tuesday March 29, 2015 – Lecture Philips – Presentations by the project group: 20 minutes presentations + 10 minutes questions for each group Start with exectution of the projectplan 63

64 Assignment Activities – Weeks 3+4: Execution of the projectplan Registration of a demo on a video Submit video to lecturers (deadline Friday, April 8, 23:59 h.) 64

65 Assignment More information on http://wwwhome.ewi.utwente.nl/~kokkeler/ (also the ‘knight rider’ example) http://wwwhome.ewi.utwente.nl/~kokkeler/ Layout Breadboard 65


Download ppt "Datapath and control Dr. ir. A.B.J. Kokkeler 1. What is programming ? “Programming is instructing a computer to do something for you with the help of."

Similar presentations


Ads by Google