Presentation is loading. Please wait.

Presentation is loading. Please wait.

General Purpose Processors: Software. This Week In DIG II  Introduction  Basic Architecture  Memory  Programmer’s view (that would be you !)  Development.

Similar presentations


Presentation on theme: "General Purpose Processors: Software. This Week In DIG II  Introduction  Basic Architecture  Memory  Programmer’s view (that would be you !)  Development."— Presentation transcript:

1 General Purpose Processors: Software

2 This Week In DIG II  Introduction  Basic Architecture  Memory  Programmer’s view (that would be you !)  Development environment  Application specific instruction-Set Processors (ASIPs)  Selecting a microprocessor  Z-World  General – purpose processor design Chapter 3 General-Purpose Processors: Software

3 Basic Architecture  Control unit and datapath  Note similarity to single- purpose processor  Key differences  Datapath is general  Control unit doesn’t store the algorithm – the algorithm is “programmed” into the memory Processor (CPU) Control unit Datapath ALU Registers IRPC Controller Memory I/O Control /Status

4 Architectural Considerations  Clock frequency  Inverse of clock period  Must be longer than longest register-to- register delay in entire processor  Memory access is often the longest  The path that takes the longest time is called critical path. Clock period must be longer than the critical path. Processor Control unitDatapath ALU Registers IRPC Controller Memory I/O Control /Status

5 Memory: Two Memory Architectures Processor Program memory Data memory Processor Memory (program and data) HarvardPrinceton  Registers serve as short time storage space, the memory serves as the long time storage space  Memory:  Data  Program  Princeton  Data and program stored together  Fewer memory wires  Harvard  Data and program have separate memory locations  Simultaneous program and data memory access RAM:ROM,

6 Cache Memory  Memory access may be slow  On-chip memory (faster)  Off-chip memory (slower)  Cache is small but fast memory close to processor  Holds copy of part of memory that is most likely to be needed often  Underlying principle: If processor access a specific part of the memory, chances are it will need to access that immediate neighborhood of memory block again sometime soon  Hits and misses Processor Memory Cache Fast/expensive technology, usually on the same chip Slower/cheaper technology, usually on a different chip

7 Pipelining: Increasing Instruction Throughput 12345678 12345678 12345678 12345678 Fetch-instr. Decode Fetch ops. Execute Store res. 12345678 12345678 12345678 12345678 12345678 Wash Dry Time Non-pipelinedPipelined Time Pipelined pipelined instruction execution non-pipelined dish cleaningpipelined dish cleaning Instruction 1

8 Programmer’s View  Programmer doesn’t need detailed understanding of architecture  Instead, needs to know what instructions can be executed  Two levels of instructions:  Assembly level (processor specific)  Structured languages (C, C++, Java, etc., processor independent) »How about machine language?  Most development today done using structured languages  But, some assembly level programming may still be necessary  Drivers: portion of program that communicates with and/or controls (drives) another device Often have detailed timing considerations, extensive bit manipulation Assembly level may be best for these

9 Assembly-Level Instructions opcodeoperand1operand2 opcodeoperand1operand2 opcodeoperand1operand2 opcodeoperand1operand2... Instruction 1 Instruction 2 Instruction 3 Instruction 4  Instruction Set  Defines the legal set of instructions for that processor. If programming in assembly, you need to know these…!  An instruction typically has two parts: opcode field and operand field. Three types of instructions: Data transfer: memory/register, register/register, I/O, etc. Arithmetic/logical: implement a function, move register through ALU and back Branches: determine next PC value when not just PC+1 –Unconditional jumps  determine the address of next instruction –Conditional jumps  ditto, if a condition is satisfied The operation to take place during the instruction Locations of actual data that takes place in an operation (source / destination operand)

10 Addressing Modes Data Immediate Register-direct Register indirect Direct (regular variables) Indirect (pointer variables) Data Operand field Register address Memory address Data Memory address Data Addressing mode Register-file contents Memory contents The operand field may indicate the data’s location through one of several addressing modes:

11 A Simple (Trivial) Instruction Set opcode operands MOV Rn, direct MOV @Rn, Rm ADD Rn, Rm 0000Rndirect 0010Rn 0100RmRn Rn = M(direct) Rn = Rn + Rm SUB Rn, Rm 0101Rm Rn = Rn - Rm MOV Rn, #immed. 0011Rnimmediate Rn = immediate Assembly instruct.First byteSecond byteOperation JZ Rn, relative 0110Rnrelative PC = PC+ relative (only if Rn is 0) Rn MOV direct, Rn 0001Rndirect M(direct) = Rn Rm M(Rn) = Rm

12 Sample Programs int total = 0; for (int i=10; i!=0; i--) total += i; // next instructions... C program MOV R0, #0; // total = 0 MOV R1, #10; // i = 10 JZ R1, Next; // Done if i=0 ADD R0, R1; // total += i MOV R2, #1; // constant 1 JZ R3, Loop; // Jump always Loop: Next:// next instructions... SUB R1, R2; // i-- Equivalent assembly program MOV R3, #0; // constant 0 0 1 2 3 5 6 7  Try some others (exercise)  Handshake: Wait until the value of M[256] is not 0, set M[257] to 1, wait until M[256] is 0, set M[257] to 0 (assume those locations are ports).  (Harder) Count the occurrences of zero in an array stored in memory locations 100 through 199.

13 Programmer Considerations  Program and data memory space  Embedded processors often very limited e.g., 64 Kbytes program, 256 bytes of RAM (expandable) Find out the program and memory space in BL-1800  Registers: How many are there?  Only a direct concern for assembly-level programmers  However, all programmers need to know “special-function” registers (used for configuring built-in timers, counters, serial communication devices or read/write external pins). Find the number of registers in BL-1800  I/O  How communicate with external signals?  Serial / parallel ports, system bus Find the I/O capabilities and features of BL-1800  Interrupts  Causes the processor to suspend execution of the main program and jump to an interrupt service routine (ISR) to execute a special, short-term need program. Controlled by the PC. Examples…?

14 Example: parallel port driver  Using assembly language programming we can configure a PC parallel port to perform digital I/O  write and read to three special registers to accomplish parallel communications. Table provides list of parallel port connector pins and corresponding register location for the PC  Example : parallel port monitors the input switch (pin 13) and turns the LED (Pin 2) on/off accordingly LPT Connection PinI/O DirectionRegister Address 1Output0 th bit of register #2 2-9Output0 th ~7 th bit of register #0 14,16,17Output1,2,3 rd bit of register #2 10,11,12,13,15Input6,7,5,4,3 rd bit of register #1

15 Parallel Port Example ; This program consists of a sub-routine that reads ; the state of the input pin, determining the on/off state ; of our switch and asserts the output pin, turning the LED ; on/off accordingly.x86 CheckPortproc pushax; save the content pushdx; save the content movdx, 3BCh + 1; base + 1 for register #1 inal, dx; read register #1 and al, 10h; mask out all but bit # 4 cmpal, 0; is it 0? jneSwitchOn; if not, we need to turn the LED on SwitchOff: movdx, 3BCh + 0; base + 0 for register #0 inal, dx; read the current state of the port andal, feh; clear first bit (masking) outdx, al; write it out to the port jmpDone ; we are done SwitchOn: movdx, 3BCh + 0; base + 0 for register #0 inal, dx; read the current state of the port oral, 01h; set first bit (masking) outdx, al; write it out to the port Done: popdx; restore the content popax; restore the content CheckPortendp extern “C” CheckPort(void);// defined in // assembly void main(void) { while( 1 ) { CheckPort(); } LPT Connection PinI/O DirectionRegister Address 1Output0 th bit of register #2 2-9Output0 th bit of register #2 14,16,17Output1,2,3 th bit of register #2 10,11,12,13,15Input6,7,5,4,3 th bit of register #1 3BCh: Base address of LPT port (most PCs)

16 Operating System  Optional software layer providing low-level services to a program (application).  File management, disk access  Keyboard/display interfacing  Scheduling multiple programs for execution Or even just multiple threads from one program  Program makes system calls to the OS  OS responds to these “service calls” based on this priority order.  OS determines which program use the system resources (CPU, memory, etc.) when and how long.

17 Chapter Summary  General-purpose processors  Good performance, low NRE, flexible  Controller, datapath, and memory  Structured languages prevail  But some assembly level programming still necessary  Many tools available  Including instruction-set simulators, and in-circuit emulators  ASIPs  Microcontrollers, DSPs, network processors, more customized ASIPs  Choosing among processors is an important step  Designing a general-purpose processor is conceptually the same as designing a single-purpose processor


Download ppt "General Purpose Processors: Software. This Week In DIG II  Introduction  Basic Architecture  Memory  Programmer’s view (that would be you !)  Development."

Similar presentations


Ads by Google