程序代写代做代考 clock assembly compiler mips data structure assembler kernel algorithm 8/27/2020

8/27/2020
CSC 252:
General Computer Organization
Dr. Jonathan Misurda
jmisurda@arizona.edu
Five Classic Components
1. Memory – Stores data and instructions
2. Input – Writes data to memory
3. Output – Reads data from memory
4. Datapath – Combined with control,
forms the processor
5. Control – Directs the operation of datapath, input, output, and memory
12
Programs
A file containing code and data (executable file).
Program code is comprised of one or more algorithms and data structures to solve a problem.
The code in a program is a static sequence of instructions.
Those instructions execute and become a dynamic sequence of instructions.
}
00000000101000010… 00000000000110000… 10001100011000100… 10001100111100100… 10101100111100100… 10101100011000100… 00000011111000000…
Machine code
Assembler
Machine Code
void swap(int v[], int k) {
int temp;
temp = v[k]; v[k] = v[k+1]; v[k+1] = temp;
swap:
multi $2, $5, 4 add $2, $4, $2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31
High-level source code
Assembly language
Compiler
34
Static vs. Dynamic
Static instructions are those that are not yet running.
These instructions are produced by the compiler or by you, but have not executed
yet.
The count of these instructions is the static instruction count.
Dynamic instructions are those that are executed by the processor.
They come from the static instruction stream in a program or in memory.
The dynamic instruction count may be less, more, or the same as the static count.
Example
for(int i=0; i<10; i++) { if(i%2 == 0) { evenSum += i; } else if(i%2 == 1) { oddSum += i; } else { 7 lines of useful code (excludes ‘}’) • Static count The for and if will run 10 times. There are 5 even numbers to sum. There are 5 odd numbers to sum. The else will never execute (dead code). } } System.out.print(“Hmm...”); 56 1 8/27/2020 Instruction Count 90-10 (or 80-20) rule: • 90% of execution in 10% of the code • Pareto principle Typically, dynamic instruction count is higher than the static instruction count, even though much of the static code may not be executed in a given run (error handlers, functionality not used, etc.). The fewer instructions executed, the faster the program on the same computer. Instruction Set Architecture The ISA is the interface presented by the hardware to software. Documented in the programmer’s reference manual for a particular processor. Components of ISA : • Data types the processor supports • Registers and their usage • Instructions and their definitions • Processor modes • Exception mechanism • (Compatibility issues) Application Software Systems Software ISA Hardware 78 Register Storage that is directly accessible to the instructions executing on the processor. Fastest level of storage, can be accessed at the speed of the processor. Used for intermediate calculations. Processors have a native word size, such as a 32-bit computer. Registers are usually this width. In the past, registers were few because the resources to create them (transistors) were scarce and devoted to other tasks. Now, we can have many registers, but may be limited by power consumption or time to access. Instructions Fundamental operations that the processor knows how to perform. • Much simpler than statements in a high-level language. • Each “line of code” may result in multiple instructions. • Add two numbers in registers (add $t0,$t1,$t2) • Compare two numbers in registers (slt $t0,$t1,$t2) • Make a jump in the program if the first number is smaller than the second number Complex instructions may require less instructions and be easier to code with. A complex instruction might be to copy a string from one memory location to another. CISC (Complex Instruction Set Computers) might be slower, more expensive, or use more power than RISC (Reduced Instruction Set Computers). 9 10 Intel 4004 Often considered the first microprocessor, it was released in 1971. Clock speed of 740 kHz (740,000 cycles per second). One instruction took 1350ns to execute. The 4-bit processor (word size) was built from about 2300 transistors. It only has 1 register called the accumulator. MIPS Registers 32 bits $zero r0 $at r1 $v0 r2 $v1 r3 $a0 r4 $a1 r5 $a2 r6 $a3 r7 $t0 r8 $t1 r9 $t2 r10 $t3 r11 $t4 r12 $t5 r13 $t6 r14 $t7 r15 32 bits r16 $s0 r17 $s1 r18 $s2 r19 $s3 r20 $s4 r21 $s5 r22 $s6 r23 $s7 r24 $t8 r25 $t9 r26 $k0 r27 $k1 r28 $gp r29 $sp r30 $fp r31 $ra 32 bits HI LO PC Special-Purpose Registers General-Purpose Registers 11 12 2 8/27/2020 Instruction Manual Processor Modes Certain instructions control the low-level operation of the processor, memory, and I/O devices. These instructions, used incorrectly or maliciously, may cause the computer to stop working, or deny programs the ability to run. To avoid these problems, processors usually have two or more modes. Privileged Mode (or Kernel Mode) can execute all instructions. The CPU starts up in this mode and whatever program runs first is, in essence, the Operating System. We trust the OS to keep the system stable and working correctly. Protected Mode (or User Mode) can only execute a subset of “safe” instructions. If a protected mode program tries to issue a privileged instruction, the CPU may cause an exception and the OS will likely kill the program. 13 14 Switching Modes After OS boots, user space programs start to run in protected mode. To get back into the OS (and privileged mode), we need a special operation. Software-based exception, trap, or interrupt: • System calls • Divide by zero • Bad memory accesses Hardware interrupts: • Clock • I/O devices such as keyboard, mouse, hard disk, etc. Computer components 15 16 Inside Your PC Integrated circuits (ICs) • CPU (central processing unit), chipsets, memory, peripheral I/O chips (e.g., for USB, Firewire [IEEE1394], ...) Printed circuit boards (PCBs) • Substrate for ICs and interconnection • Distribution of clock, power supply • Heat dissipation Hard drive Optical storage (CD-ROM, DVD-ROM, CD-RW, ...) Power supply • Converts line AC voltage (~120V) to regulated DC low voltage levels • GND (0V), ±12V, ±5V, ... Chassis • Holds boards, power supply, and provides physical interface for user and other system components Connectors and cables Integrated Circuits Primarily crystalline silicon that is 1mm to ~25mm on a side. Feature size: 14 to ~250nm 100 million to 2 billion+ transistors Intel Broadwell-E5 22-core: 7.2 billion transistors 3 to ~10 metal “conductive” layers built from CMOS (complementary metal-oxide semiconductor) technology Package spreads chip level signal paths to board level and provides heat dissipation 17 18 3 8/27/2020 Printed circuit board Fiberglass or ceramic 1 to ~20 conductive layers 1 to ~20 inches on a side IC packages are mounted and soldered on a board Input devices Desktop computers • Keyboard (wireless / Bluetooth) • Mouse (from mechanical to optical, touchpad) • Joystick (Atari 400 to Guitar Hero) • Web camera, voice recognition, home control (e.g., video streaming) Servers • Terminals on network, home control Cell phone – embedded computer • Keypad • Voice recognition • Gesture based (e.g., bumping to exchange contact) Atari 400, see Atari Museum 19 20 Output devices Passes information to human, machine, actuator Desktop computers • Display (transition from CRT to LCD, 10 to 30”, possibly more than one) • Sound (from little speaker to complete stereo sound system) • Printer (from line dot matrix to high DPI color photo printing at home) Servers • Terminals (thin client) or other computer on network Cell phone – embedded computer • Screen • Sound • Vibration Main memory DRAM (dynamic random access memory) is the choice technology (invented mid 1960s, capacity 1024 bits) • Large capacity • Low price • Standard products from multiple vendors SRAM (static random access memory) is fast and low power, used for things like registers 21 22 Storage Secondary storage (main memory) Non-volatile Stores programs, user-saved data, etc. In PC/server domain, magnetic disk (hard disk) is dominant In embedded computers, “flash” and “ROM” are popular Due to performance, power, and reliability issues, solid-state disk drives (based on flash memory technology) become increasingly common • Here today, but limited capacity (256 GB & HUGE demand for parts!) • Can’t quite compete (yet) with hard disks for cost per gigabyte • Requires techniques to work around “wear-out” Cloud storage has just recently become a genuine possibility.... Computer networks Local area network (LAN) • Within a limited distance (e.g., inside a building) • 100/100/1000Mbps, ... Wide area network (WAN) • Connecting smaller networks far apart At home • Modem: acoustic coupler - 110 baud, 300 baud to direct connect - 14.4kbps, 28.8kbps, 33.6kbps, 56kbps • Cable modem/DSL: several hundred kbps to about several Mbps • Optical connection delivering multiple media streams (Verizon FiOS) • Home network Proliferation of wireless LAN (IEEE 802.11) • 1 to ~100Mbps (newest proposed standard 802.11n up to 600 Mbps) 23 24 4 8/27/2020 Exponential Technology Advances Memory • DRAM capacity: 2x / 2 years (since 1996) • 64x capacity improvement in the last decade Processor • Speed (in terms of clock frequency): 2x / 1.5 years (since 1985) • Continual improvements in clock speed have been replaced by increasing the number of cores – processing elements in a single chip. • 100x performance improvement in the last decade Disk • Capacity: 2x / 1 year (since 1997) • 250x capacity improvement in the last decade Moore’s Law: Double Transistor Count Every 18 Months 25 26 5