Академический Документы
Профессиональный Документы
Культура Документы
Chapter 1: Introduction
Capitulo 1: Introduccin
1-2
Chapter 1: Introduction
1-3
Chapter 1: Introduction
Algunas Definiciones
La Arquitectura de computadoras trata sobre el comportamiento funcional de un sistema de computacin visto por un programador (en aspectos tales como que un nmero entero ocupa 32 bits).
La organizacin de computadoras muestra relaciones estructurales no visibles para un programador (tales como la frecuencia de reloj o el tamao fsico de la memoria).
Existe un concepto de niveles en la arquitectura de computadoras. La idea es que una computadoras bsica puede estudiarse en base a diferentes niveles. Desde el nivel alto en el que el usuario corre programas, al nivel mas bajo, donde existen transistores y cables.
1-4
Chapter 1: Introduction
1-5
Chapter 1: Introduction
U.de Entrada
U.de Salida
U.de Control
1-6
Chapter 1: Introduction
System Bus
1-7
Chapter 1: Introduction
1-8
Chapter 1: Introduction
Monitor
Teclado
Ranuras para memorias internas CPU (Microprocesador debajo del disipador de calor
1-9
Chapter 1: Introduction
La Placa Madre
Los cinco componentes de von Neumann se ven claramente en esta Placa Madre, en el contexto del modelo de interconexin por bus.
Input / output
Memory
1-10
Chapter 1: Introduction
(Source: http://www.paralogos.com/DeadSuper)
1-11
Chapter 1: Introduction
Ley de Moore
A igual precio las computadoras duplican su potencia cada 18 meses. Esta observacion debe considerarse seriamente : Una innovacion en la arquitectura que se hace para obtener un rendimiento cuadruple en tres aos puede llegar a ser irrelevante: Las arquitecturas que existan para entonces tal vez ya ofrezcan un cuadruple rendimiento y verse totalmente diferentes para cuando la modificacion se esperaba que estuviera disponible
2-1
2-2
Chapter Contents
2.1 Introduction 2.2 Fixed Point Numbers 2.3 Floating Point Numbers 2.4 Case Study: Patriot Missile Defense Failure Caused by Loss of Precision 2.5 Character Codes
2-3
2-4
Example: 541.2510 = 5 102 + 4 101 + 1 100 + 2 10-1 + 5 10-2 = (500)10 + (40)10 + (1)10 + (2/10)10 + (5/100)10 = (541.25)10
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-5
(23)10 = (10111)2
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-6
(.375)10 = (.011)2
2-7
. . .
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-8
Example: Show a column for ternary (base 3). As an extension of that, convert 1410 to base 3, using 3 as the divisor for the remainder method (instead of 2). Result is 1123
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-9
2-10
Binary Addition
This simple binary addition example provides background for the signed number representations to follow.
Carry in Operands 0 0 + 0 0 0 0 0 + 1 0 1 0 1 + 0 0 1 0 1 + 1 1 0 1 0 + 0 0 1 1 0 + 1 1 0 1 1 + 0 1 0 1 1 + 1 1 1
2-11
2-12
Signed Magnitude
Also know as sign and magnitude, the leftmost bit is the sign (0 = positive, 1 = negative) and the remaining bits are the magnitude. Example: +2510 = 000110012 -2510 = 100110012 Two representations for zero: +0 = 000000002, -0 = 100000002. Largest number is +127, smallest number is -12710, using an 8-bit representation.
2-13
Ones Complement
The leftmost bit is the sign (0 = positive, 1 = negative). Negative of a number is obtained by subtracting each bit from 2 (essentially, complementing each bit from 0 to 1 or from 1 to 0). This goes both ways: converting positive numbers to negative numbers, and converting negative numbers to positive numbers. Example: +2510 = 000110012 -2510 = 111001102 Two representations for zero: +0 = 000000002, -0 = 111111112. Largest number is +12710, smallest number is -12710, using an 8bit representation.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-14
Twos Complement
The leftmost bit is the sign (0 = positive, 1 = negative). Negative of a number is obtained by adding 1 to the ones complement negative. This goes both ways, converting between positive and negative numbers. Example (recall that -2510 in ones complement is 111001102): +2510 = 000110012 -2510 = 111001112 One representation for zero: +0 = 000000002, -0 = 000000002. Largest number is +12710, smallest number is -12810, using an 8bit representation.
2-15
Excess (Biased)
The leftmost bit is the sign (usually 1 = positive, 0 = negative). Positive and negative representations of a number are obtained by adding a bias to the twos complement representation. This goes both ways, converting between positive and negative numbers. The effect is that numerically smaller numbers have smaller bit patterns, simplifying comparisons for floating point exponents. Example (excess 128 adds 128 to the twos complement version, ignoring any carry out of the most significant bit) : +1210 = 100011002 -1210 = 011101002 One representation for zero: +0 = 100000002, -0 = 100000002. Largest number is +12710, smallest number is -12810, using an 8bit representation.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-16
Example: Represent +07910 in BCD: 0000 0111 1001 Example: Represent -07910 in BCD: 1001 0010 0001. This is obtained by first subtracting each digit of 079 from 9 to obtain the nines complement, so 999 - 079 = 920. Adding 1 produces the tens complement: 920 + 1 = 921. Converting each base 10 digit of 921 to BCD produces 1001 0010 0001.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-17
2-18
2-19
Normalization
The base 10 number 254 can be represented in floating point form as 254 100, or equivalently as: 25.4 101, or 2.54 102, or .254 103, or .0254 104, or infinitely many other ways, which creates problems when making comparisons, with so many representations of the same number. Floating point numbers are usually normalized, in which the radix point is located in only one possible position for a given number. Usually, but not always, the normalized representation places the radix point immediately to the left of the leftmost, nonzero digit in the fraction, as in: .254 103.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-20
2-21
2-22
2-23
Number of representable numbers: There are 5 components: (A) sign bit; for each number except 0 for this case, there is both a positive and negative version; (B) (M - m) + 1 exponents; (C) b - 1 values for the first digit (0 is disallowed for the first normalized digit); (D) bs-1 values for each of the s-1 remaining digits, plus (E) a special representation for 0. For this example, the 5 components result in: 2 ((3 - 4) + 1) (8 - 1) 84-1 + 1 numbers that can be represented. Notice this number must be no greater than the number of possible bit patterns that can be generated, which is 216.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-24
3 2
1 1 2 4 1 8
0 1 8
1 4
1 2
1 b = 2 s = 3
3 2 M = +1 m = 2
Smallest number is 1/8 Largest number is 7/4 Smallest gap is 1/32 Largest gap is 1/4 Number of representable numbers is 33.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
2-25
bs 1 bs bs 1 bs
1 bs1 1 bs1
2-26
Conversion Example
Example: Convert (9.375 10-2)10 to base 2 scientific notation Start by converting from base 10 floating point to base 10 fixed point by moving the decimal point two positions to the left, which corresponds to the -2 exponent: .09375. Next, convert from base 10 fixed point to base 2 fixed point: .09375 .1875 .375 .75 .5 2 2 2 2 2 = = = = = 0.1875 0.375 0.75 1.5 1.0
2-27
2-28
IEEE-754 Examples
Value (a) +1.101 25 (b) 1.01011 2126 (c) +1.0 2127 (d) +0 (e) 0 (f) + (g) +2128 (h) +NaN (i) +2128 Bit Pattern Sign Exponent 0 1000 0100 1 0000 0001 0 1111 1110 0 0000 0000 1 0000 0000 0 1111 1111 0 0000 0000 0 1111 1111 0 011 0111 1111 Fraction 101 0000 0000 0000 0000 0000 010 1100 0000 0000 0000 0000 000 0000 0000 0000 0000 0000 000 0000 0000 0000 0000 0000 000 0000 0000 0000 0000 0000 000 0000 0000 0000 0000 0000 010 0000 0000 0000 0000 0000 011 0111 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
2-29
2-30
Validation action
Missile
2-31
Null Start of heading Start of text End of text End of transmission Enquiry Acknowledge Bell Backspace Horizontal tab Line feed Vertical tab
Form feed Carriage return Shift out Shift in Data link escape Device control 1 Device control 2 Device control 3 Device control 4 Negative acknowledge Synchronous idle End of transmission block
Cancel End of medium Substitute Escape File separator Group separator Record separator Unit separator Space Delete
2-32
STX DLE BS ACK SOH ENQ ESC BYP CAN RES SI SO DEL SUB NL LF
Start of text Data Link Escape Backspace Acknowledge Start of Heading Enquiry Escape Bypass Cancel Restore Shift In Shift Out Delete Substitute New Line Line Feed
RS PF DS PN SM LC CC CR EM FF TM UC FS HT VT UC
Reader Stop Punch Off Digit Select Punch On Set Mode Lower Case Cursor Control Carriage Return End of Medium Form Feed Tape Mark Upper Case Field Separator Horizontal Tab Vertical Tab Upper Case
00 NUL 20 DS 40 SP 01 SOH 21 SOS 41 02 STX 22 FS 42 03 ETX 23 43 04 PF 24 BYP 44 05 HT 25 LF 45 06 LC 26 ETB 46 07 DEL 27 ESC 47 08 28 48 09 29 49 0A SMM 2A SM 4A 0B VT 2B CU2 4B 0C FF 2C 4C < 0D CR 2D ENQ 4D ( 0E SO 2E ACK 4E + 0F SI 2F BEL 4F | 10 DLE 30 50 & 11 DC1 31 51 12 DC2 32 SYN 52 13 TM 33 53 14 RES 34 PN 54 DC1 Device Control 1 BEL Bell 15 NL 35 RS DC2 Device Control 2 SP 55 Space DC416 Device Idle BS Control 36 4 UCIL 56 CU1 Customer Use 1 NUL Null IL 37 2 EOT 57 CU217Customer Use CU318Customer CAN Use 38 3 58 SYN Synchronous Idle EM 39 59 IFS 19Interchange File Separator EOT End of Transmission CC 3A 5A ! ETB1A End of Transmission Block NAK Negative 1B CU1 Acknowledge 3B CU3 5B $ SMM Start of Manual Message 1C IFS 3C DC4 5C . SOS Start of Significance IGS 1D Interchange Group Separator IGS 3D NAK 5D ) IRS Interchange Record Separator IRS 3E 5E ; IUS1E Interchange Unit Separator 1F IUS 3F SUB 5F
60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
~ s t u v w x y z
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
{ A B C D E F G H I
} J K L M N O P Q R
E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
\ S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9 |
2-33
0000 NUL 0001 SOH 0002 STX 0003 ETX 0004 EOT 0005 ENQ 0006 ACK 0007 BEL 0008 BS 0009 HT 000A LF 000B VT 000C FF 000D CR 000E SO 000F SI 0010 DLE 0011 DC1 0012 DC2 0013 DC3 0014 DC4 0015 NAK 0016 SYN 0017 ETB 0018 CAN 0019 EM 001A SUB 001B ESC 001C FS 001D GS 001E RS 001F US 0020 SP 0021 ! 0022 " 0023 # 0024 $ 0025 % 0026 & ' 0027 0028 ( 0029 ) 002A * 002B + 002C 002D 002E . 002F / 0030 0 0031 1 0032 2 0033 3 0034 4 0035 5 0036 6 0037 7 0038 8 0039 9 003A : 003B ; 003C < 003D = 003E > 003F ? 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F 0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ 0060 ` 0080 Ctrl 0061 a 0081 Ctrl 0062 b 0082 Ctrl 0063 c 0083 Ctrl 0064 d 0084 Ctrl 0065 e 0085 Ctrl 0066 f 0086 Ctrl 0067 g 0087 Ctrl 0068 h 0088 Ctrl 0069 i 0089 Ctrl 006A j 008A Ctrl 006B k 008B Ctrl 006C l 008C Ctrl 006D m 008D Ctrl 006E n 008E Ctrl 006F o 008F Ctrl 0070 p 0090 Ctrl 0071 q 0091 Ctrl 0072 r 0092 Ctrl 0073 s 0093 Ctrl 0074 t 0094 Ctrl 0075 u 0095 Ctrl 0076 v 0096 Ctrl 0077 w 0097 Ctrl 0078 x 0098 Ctrl 0079 y 0099 Ctrl 007A z 009A Ctrl 007B { 009B Ctrl 007C | 009C Ctrl 007D } 009D Ctrl 007E ~ 009E Ctrl 007F DEL 009F Ctrl CAN EM SUB ESC FS GS RS US SYN
NUL Null STX Start of text ETX End of text ENQ Enquiry ACK Acknowledge BEL Bell BS Backspace HT Horizontal tab LF Line feed Principles of Computer Architecture by M. Murdocca and V. Heuring
Start of heading End of transmission Device control 1 Device control 2 Device control 3 Device control 4 Negative acknowledge Non-breaking space End of transmission block
Cancel SP Space End of medium DEL Delete Substitute Ctrl Control Escape FF Form feed File separator CR Carriage return Group separator SO Shift out Record separator SI Shift in Unit separator DLE Data link escape Synchronous idle VT Vertical tab 1999 M. Murdocca and V. Heuring
3-1
Chapter 3: Arithmetic
Chapter 3: Arithmetic
3-2
Chapter 3: Arithmetic
Chapter Contents
3.1 Overview 3.2 Fixed Point Addition and Subtraction 3.3 Fixed Point Multiplication and Division 3.4 Floating Point Arithmetic 3.5 High Performance Arithmetic 3.6 Case Study: Calculator Arithmetic Using Binary Coded Decimal
3-3
Chapter 3: Arithmetic
Computer Arithmetic
Using number representations from Chapter 2, we will explore four basic arithmetic operations: addition, subtraction, multiplication, division. Significant issues include: fixed point vs. floating point arithmetic, overflow and underflow, handling of signed numbers, and performance. We look first at fixed point arithmetic, and then at floating point arithmetic.
3-4
Chapter 3: Arithmetic
numbers
-2 110
010 2
101 -3 100 -4
011
Adding numbers
1999 M. Murdocca and V. Heuring
3-5
Chapter 3: Arithmetic
Overflow
Overflow occurs when adding two positive numbers produces a negative result, or when adding two negative numbers produces a positive result. Adding operands of unlike signs never produces an overflow. Notice that discarding the carry out of the most significant bit during twos complement addition is a normal occurrence, and does not by itself indicate overflow. As an example of overflow, consider adding (80 + 80 = 160)10, which produces a result of -9610 in an 8-bit twos complement format: 01010000 = + 01010000 = ---------10100000 = -96 (not 160 because the sign bit is 1.)
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
80 80
3-6
Chapter 3: Arithmetic
b3 a3
c3
b2 a2
c2
b1 a1
c1
b0 a0
c0
Full adder c4 s3
Full adder
Full adder
Full adder
s2
s1
s0
3-7
Chapter 3: Arithmetic
a15 a14 a13 a12 b15 b14 b13 b12 c12 c16 4-Bit Adder #3 c4
a3 b3 b2
a2 b1
a1 b0
a0
. . .
c0 4-Bit Adder #0 0
s15
s14
s13
s12
s3
s2
s1
s0
3-8
Chapter 3: Arithmetic
Full Subtractor
Truth table and schematic symbol for a ripple-borrow subtractor:
ai bi bori 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1
diffi bori+1 0 1 1 0 1 0 0 1 0 1 1 1 0 0 0 1
3-9
Chapter 3: Arithmetic
Ripple-Borrow Subtractor
A ripple-borrow subtractor can be composed of a cascade of full subtractors. Two binary numbers A and B are subtracted from right to left, creating a difference and a borrow at the outputs of each full subtractor for each bit position.
b3 a3
b2 a2
b1 a1
b0 a0
bor0 0
Full subtractor
Full subtractor
Full subtractor
diff2
diff1
diff0
1999 M. Murdocca and V. Heuring
3-10
Chapter 3: Arithmetic
Combined Adder/Subtractor
A single ripple-carry adder can perform both addition and subtraction, by forming the twos complement negative for B when subtracting. (Note that +1 is added at c0 for twos complement.) b3 b2 b1 b0 ADD / SUBTRACT
a3
a2
a1
a0 c0
Full adder
Full adder
Full adder
Full adder
c4 s3 s2 s1 s0
1999 M. Murdocca and V. Heuring
3-11
Chapter 3: Arithmetic
3-12
Chapter 3: Arithmetic
-0 111
Subtracting numbers
-1 110
010 2
101 -2 100 -3
011
Adding numbers
1999 M. Murdocca and V. Heuring
3-13
Chapter 3: Arithmetic
(+5.5)10 (1.0)10
(+4.5)10
1999 M. Murdocca and V. Heuring
3-14
Chapter 3: Arithmetic
Multiplication Example
Multiplication of two 4-bit unsigned binary integers produces an 8-bit result.
1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 0 1 1 1 0 1 0 1 0
(13)10 (11)10
Multiplicand M Multiplier Q
1 0 0 0 1 1 1 1
Multiplication of two 4-bit signed binary integers produces only a 7-bit result (each operand reduces to a sign bit and a 3-bit magnitude for each operand, producing a sign-bit and a 6-bit result).
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
3-15
Chapter 3: Arithmetic
A Serial Multiplier
Multiplicand (M) m3 m2 m1 m0 4 4Bit Adder 4 Add Shift and Add Control Logic q0
Shift Right
a3 a2 a1 a0 A Register 4
q3 q2 q1 q0 Multiplier (Q)
3-16
Chapter 3: Arithmetic
Product
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
3-17
Chapter 3: Arithmetic
11
0 0 1 0 R1 0111 11 01
3-18
Chapter 3: Arithmetic
Serial Divider
Divisor (M) 0 m3 m2 m1 m0 5 5Bit Adder 5 Shift and Add / Add / Sub Sub Control Logic Shift Left q0
a4 a3 a2 a1 a0 a4 5 A Register
q3 q2 q1 q0 Dividend (Q)
3-19
Chapter 3: Arithmetic
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1
1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
Remainder
Principles of Computer Architecture by M. Murdocca and V. Heuring
3-20
Chapter 3: Arithmetic
1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1
(1)10 (+1)10
(1)10
3-21
Chapter 3: Arithmetic
Carry-Lookahead Addition
3-22
Chapter 3: Arithmetic
G3
P3 G2
P2 G1
P1 G0
Maximum gate delay for the carry generation is only 3. The full adders introduce two more gate delays. Worst case path is 5 gate delays.
c0 0
c4 Full adder
c3
c2
c1
Full adder
Full adder
Full adder
s3
s2
s1
s0
1999 M. Murdocca and V. Heuring
3-23
Chapter 3: Arithmetic
3-24
Chapter 3: Arithmetic
3-25
Chapter 3: Arithmetic
0 1 0 1 0 1 0 0 1 1 1 0 0 +1 0 0 1 0
(21)10 (14)10
(294)10 Product
1999 M. Murdocca and V. Heuring
3-26
Chapter 3: Arithmetic
Add (14 1)10 1 0 0 0 (14 2)10 0 0 (14 4)10 0 0 (14 8)10 0 0 (14 16)10 0 0 (14 32)10 1 0 (294)10 Product
1999 M. Murdocca and V. Heuring
3-27
Chapter 3: Arithmetic
3-28
Chapter 3: Arithmetic
3-29
0 0 mw ... PP 0,w q0 PP 0,2 0 0 m2
Multiplicand 0 0
Chapter 3: Arithmetic
m1 0 0 m0
q0
PP 0,1
q0
PP 0,0 p0
q0
PP 1,w
. . . qw PPw,2
. . . qw PPw,1
. . . qw PPw,0 pw qw
PPw,w
0 ... PP w+1,w FA p 2w-1 aj bj PP w+1,2 FA pw+3 Carry-in Full adder Carry-out m out
Principles of Computer Architecture by M. Murdocca and V. Heuring
PP w+1,1 FA mi pw+2
PP w+1,0 FA pw+1
qj mi
Product
sum
3-30
Chapter 3: Arithmetic
f(x)
x x i+1
The division operation a/b is computed as a 1/b. Newtons iteration provides a fast method of computing 1/b.
1999 M. Murdocca and V. Heuring
3-31
Chapter 3: Arithmetic
Residue Arithmetic
Implements carryless arithmetic (thus fast!), but comparisons are difficult without converting to a weighted position code. Representation of the first twenty decimal integers in the residue number system for the given moduli:
Decimal 0 1 2 3 4 5 6 7 8 9 Residue 5794 0000 1111 2222 3333 4440 0551 1662 2073 3180 4201 Decimal 10 11 12 13 14 15 16 17 18 19 Residue 5794 0312 1423 2530 3641 4052 0163 1270 2381 3402 4513
1999 M. Murdocca and V. Heuring
3-32
Chapter 3: Arithmetic
3-33
Chapter 3: Arithmetic
3-34
Chapter 3: Arithmetic
CLA3 4
CLA2 4 s8 s11
GG2
c16
In the GCLL section, GG and GP signals are generated in 3 gate delays; carry signals are generated in 2 more gate delays, resulting in 5 gate delays to generate the carry out of each GCLA group and 10 gates delays on the worst case path (which is s15 not c16).
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
3-35
Chapter 3: Arithmetic
3-36
Chapter 3: Arithmetic
Carries (+255)10
(+63)10
(+318)10
3-37
Chapter 3: Arithmetic
1 0000 1001
0000
Discard carry
1999 M. Murdocca and V. Heuring
3-38
Chapter 3: Arithmetic
Positive numbers
Negative numbers
3-39
Chapter 3: Arithmetic
Full adder c4
Full adder
Full adder
Full adder
Full adder
Full adder
Full adder
Full adder
s3
Principles of Computer Architecture by M. Murdocca and V. Heuring
s2
s1
s0
3-40
Chapter 3: Arithmetic
3-41
Chapter 3: Arithmetic
3-42
Chapter 3: Arithmetic
Note that the representation is still in excess 3 binary form, with a two digit excess 50 exponent. To add two numbers in this representation, as for a base 2 floating point representation, we start by adjusting the exponent and fraction of the smaller operand until the exponents of both operands are the same. After adjusting the smaller fraction, we convert either or both operands from signed magnitude to tens complement according to whether we are adding or subtracting, and whether the operands are positive or negative, and then perform the addition or subtraction operation.
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-1
4-2
Contenidos de Captulo
4.1Componentes de Hardware de la Arquitectura del Set de Instrucciones 4.2 ARC, Una Computadora RISC 4.3 Pseudo Operaciones 4.4 Ejemplos de Programas en Languaje Ensamblador 4.5 Accediendo a Datos en MemoriaModos de Direccionamiento 4.6 Enlaces a Subrutinas y Punteros 4.7 Entreada y Salida en Lenguaje Ensamblador
4-3
4-4
Memoria
System Bus
4-5
4-6
Big-Endian
LSB 0
31 MSB
Little-Endian
LSB 0
x+1
x+2
x+3
x+3
x+2
x+1
4-7
4-8
Registros
Unidad Control
ALU
Seccin de Control
4-9
El Ciclo Fetch-Ejecucin
Los pasos que sigue una unidad de control para ejecutar un programa son: (1) Buscar de la memoria la siguiente instruccin a ejecutar. (2) Decodificar el opcode (cdigo de operacin). (3) Leer operando(s) desde la memoria principal, si hubiera alguno. (4) Ejecutar la instruccin y almacenar resultados. (5) Ir al paso 1. Esto se conoce como el ciclo fetch-ejecucin.
4-10
Conjunto de Registros
Al Bus de Direcciones
ALU
El datapath de ARC est formado por una coleccin de registros conocidos el archivo de registros y la unidad aritmetico lgica (ALU).
Principios de Arquitectura de Computadoras por M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-11
Memoria
ld st sethi andcc
Lgicas
Aritmeticas
Control
4-12
Comentario
lab_1:
addcc
4-13
%r0 [= 0] %r1 %r2 %r3 %r4 %r5 %r6 %r7 %r8 %r9 %r10 %psr
Registro 11 Registro 12 Registro 13 Registro14 Registro 15 Registro 16 Registro 17 Registro 18 Registro 19 Registro 20 Registro 21
%r11 %r12 %r13 %r14 [%sp] %r15 [link] %r16 %r17 %r18 %r19 %r20 %r21
Registro 22 Registro 23 Registro 24 Registro 25 Registro 26 Registro 27 Registro 28 Registro 29 Registro 30 Registro 31
%r22 %r23 %r24 %r25 %r26 %r27 %r28 %r29 %r30 %r31
PC 32 bits
%pc
4-14
0 0 0 0 0
rd cond
op2 op2
imm22 disp22
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0 1
disp30 i
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Formatos Aritmticos
1 0 1 0
rd rd
op3 op3
rs1 rs1
0 0 0 0 0 0 0 0 0 1 simm13
rs2
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
1 1 Formatos de Memoria 1 1
rd rd
op3 op3
rs1 rs1
0 0 0 0 0 0 0 0 0 1 simm13
rs2
op 00 01 10 11
op2
Inst.
op3 (op=10) 010000 010001 010010 010110 100110 111000 addcc andcc orcc orncc srl jmpl
cond salto 0001 0101 0110 0111 1000 be bcs bneg bvs ba
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
PSR
n z v c
1999 M. Murdocca and V. Heuring
4-15
Signed Integer Byte Signed Integer Halfword Signed Integer Word Signed Integer Double s
7 6
Signed Formats
s
15 14 0
s
31 30 0
s
63 62 32
31
32
31
exponent
23 22
fraction
0
s
63 62
exponent
52 51
fraction
32
fraction
31 0
s
127 126
exponent
112 113
fraction
96
fraction
95 64
fraction
63 32
fraction
31 0
4-16
Pseudo-Operaciones ARC
Pseudo-Op
.equ .begin .end .org .dwb .global .extern .macro
Uso
X .equ #10
Significado
Asignar a X el valor (10) 16 .begin Comienzo de traduccin .end Fin de traducccin .org 2048 Cambiar contador de posicion a 2048 .dwb 25 Reservar un bloque de 25 palabras .global Y Y se usa en otro modulo .extern Z Z est definido en otro modulo .macro M a, b, ... Definir macro M con parametros
.endmacro .if <cond> .endif
formales: a, b, ... Fin de definicin de Macro Ensamblar si <cond> es cierta Fin estructura condicional
Las pseudo-ops son instrucciones del assembler. No son parte de la ISA (Instruction Set Architecture).
Principios de Arquitectura de Computadoras por M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-17
4-18
! Uso de los Registr os : ! ! ! ! .begin .org 2048 a_start .equ 3000 %r1 %r2 %r3 %r4 %r5
loop:
ld [length], %r1 ! %r1 l ong. del arr eglo a ld [address],%r2 ! %r2 direccin de a andcc %r3, %r0, %r3 ! %r3 0 andcc %r1, %r1, %r0 ! Test # re stantes element o s be done ! Fin alizar cuando length=0 addcc %r1, -4, %r1 ! Decrement ar l ongitud arreglo addcc %r1, %r2, %r4 ! Direccin prximo element o ld %r4, %r5 ! %r5 Memor ia [%r4] addcc %r3, %r5, %r3 ! Sum ar n uevo element o en r3 ba loop ! Repe t ir l azo .
jmpl
%r15 + 4, %r0 ! Re orno a rutina de llamada 20 a_start a_start 25 10 33 5 7 ! 5 numer o s (20 bytes) e n a ! Inicio del arr eglo a
.org a:
.end
4-19
Esto es, multiplicar B por C y guardar el resultado en A. ( mult y add son operaciones genricas; no son instrucciones ARC.) Sumar D con A y guardar el resultado en la direccin A. El tamao del programa es 72 = 14 bytes. El trfico de memoria es 14 + 2(23) = 26 bytes.
Principios de Arquitectura de Computadoras por M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-20
4-21
store A La instruccin load carga B en el acumulador, mult multiplica C por el acumulador y guarda el resultado en el mismo acumulador y add hace la suma correspondiente. La instruccin store guarda el acumulador en A. El tamao de programa es ahora: (2+1)4 12 bytes, y el trfico de memoria es 12 + 42 20 bytes.
Principios de Arquitectura de Computadoras por M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-22
Modos de Direccionamientos
Cuatro modos de calcular la direccin de un valor en memoria: (1) Un valor constante conocido al momento del ensamble, (2) los contenidos de un registro, (3) la suma de dos registros, (4) suma de un registro y una constante. La tabla d nombres a estos y a otros modos de direccionamientos.
Principios de Arquitectura de Computadoras por M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-23
! Rutina Invocante . . . ld ld call st . . . 53 10 0 [x], %r1 [y], %r2 add_1 %r3, [z]
x: y: z:
4-24
4-25
! Rutina Invocante . . . %sp .equ addcc st addcc st call ld addcc . . . %r14 %sp, -4, %sp %r1, %sp %sp, -4, %sp %r2, %sp add_3 %sp, %r3 %sp, 4, %sp
! Rutina Invocada ! Los argumentos estan en la pila ! %sp[0] %sp[0] + %sp[4] %sp .equ add_3: ld addcc ld addcc st jmpl %r14 %sp, %r8 %sp, 4, %sp %sp, %r9 %r8, %r9, %r10 %r10, %sp %r15 + 4, %r0
4-26
00 main() 01 { 02 int w, z; 03 w = func_1(1,2); 04 z = func_2(10); 05 } 06 int 07 int 08 { 09 10 11 12 13 } 14 int 15 int 16 { 17 18 19 20 21 } func_1(x,y) x, y; int i, j; i = x * x; j = i + y; return(j);
/* /* /* /*
func_2(a) a;
4-27
0 0
Free area
Free area
Free area
%r15 2 1
Stack 232 4
Stack
(b) (c) El llamado a rutina empuja Despues del Call la rutina los argumentos en la pila, invocada guarda el PC de la rutina antes de llamar a func_1. invocante (%r15)en la pila. (Linea 03 del programa.) (Line 06 del programa.) 0 0
Area Libre
(a-f) comportamiento %sp de la Pila durante la ejecucin del programa en C mostrado con 232 4 anterioridad.
j i %r15 2 1
%sp
Pila 232 4
Pila
(d) (e) Se reserva espacio en la pila para Los valores de Retorno de func_1, variables locales i func_1 se ubican en la y j. (Line 09 del pila, justo antes del retorno. programa.) (Line 12 del programa.)
(f) La rutina invocante "extrae" desde la pila los valores de retorno de func_1 (Line 03 del programa.)
4-28
Pila
Pila
(g) (h) Se crea un marco de pila para Se crea un marco de pila para la func_2 como resultado la func_1 como resultado del llamado a funcin de la del llamado a funcin de la linea 04 del programa. linea 19 del programa. 0
232 4
0 (g-k) Comportamiento de la Pila durante la ejecucin del programa en C mostrado con %sp anterioridad 232 4
Area Libre
Area Libre
115
Pila
4-29
Direccin
Contenido 32 bits
Reservado para rutinas de arranque y rutinas grficas Memoria de video ad. #1 Memoria de video ad. #2
222
Memoria de trabajo
Tope de la pila
Puntero de Pila(SP)
Pila de Sistema
223 4
Fondo de la pila
Espacio de I/O
224 1
1999 M. Murdocca and V. Heuring
4-30
Detector
4-31
No
Diagrama que ilustra la estructura de control de un programa que verifica una pantalla sensible al tacto.
5-1
5-5
El Proceso de Ensamblado
* El proceso de transformar un programa en lenguaje ensamblador en un programa en lenguaje de mquina se conoce como proceso de ensamblado
-- Provee expresiones nemnicas en el lenguaje de programacin para todas las instrucciones del lenguaje de mquina y modos de direccionamientos y traduce sentencias vlidas al lenguaje absoluto.
-- Permitir el uso de rtulos simblicos para representar direcciones y constantes
-- Incluir un mecanismo que permita la definicin de variables en un programa escrito en lenguaje simblico y el uso de las mismas en otro programa ensamblado por separado. -- Proveer la expansin de macro rutinas (se definen una sola vez).
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
5-6
Ejemplo de ensamblado
Exploraremos como el proceso de ensamblado genera un programa ARC a travs del proceso de "Ensamblado a Mano".
! Este programa suma dos nmeros .begin .org 2048 ld [x], ld [y], addcc %r1, st %r3, jmpl %r15 15 9 0 .end
main:
! ! ! ! !
Carga x en %r1 Carga y en %r2 %r3 %r1 + %r2 Almacena %r3 en z Retorno
x: y: z:
5-7
op SETHI Format
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0 0 0 0 0
rd cond
op2 op2
imm22 disp22
Branch Format
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
CALL format
0 1
disp30 i
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Arithmetic Formats
1 0 1 0
rd rd
op3 op3
rs1 rs1
0 0 0 0 0 0 0 0 0 1 simm13
rs2
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
1 1 1 1
rd rd
op3 op3
rs1 rs1
0 0 0 0 0 0 0 0 0 1 simm13
rs2
Memory Formats
op 00 01 10 11
op2
Inst.
op3 (op=10) 010000 010001 010010 010110 100110 111000 addcc andcc orcc orncc srl jmpl
cond branch 0001 0101 0110 0111 1000 be bcs bneg bvs ba
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
PSR
n z v c
5-8
Cdigo Ensamblado
ld [x], %r1 ld [y], %r2 st %r3, [z] jmpl %r15+4, %r0 15 9 0 1100 0010 0000 0000 0010 1000 0001 0100 1100 0100 0000 0000 0010 1000 0001 1000 1100 0110 0010 0000 0010 1000 0001 1100 1000 0001 1100 0011 1110 0000 0000 0100 0000 0000 0000 0000 0000 0000 0000 1111 0000 0000 0000 0000 0000 0000 0000 1001 0000 0000 0000 0000 0000 0000 0000 0000
addcc %r1,%r2,%r3 1000 0110 1000 0000 0100 0000 0000 0010
5-9
Referencia Previa
Un ejemplo de Referencia Previa
sub_r:
5-10
! Este programa suma tantos numeros como indica " LENGTH " ! Uso del Registro : %r1 L ongitud del arreglo a ! %r2 Direccin de inicio del arreglo a ! %r3 La suma Parcial ! %r4 P untero al arreglo a ! %r5 contiene un elemento de a .begin ! comienzo de traduccin .org 2048 ! comienzo de program a en 2048 a_start .equ 3000 ! Direccin del arreglo a ld [length], %r1 ! %r1 l ong. del arreglo a ld [address],%r2 ! %r2 direccin de a andcc %r3, %r0, %r3 ! %r3 0 andcc %r1, %r1, %r0 ! Ver # elementos restantes be done ! Fin aliza cuando length=0 addcc %r1, -4, %r1 ! Decrement ar tamao arreglo addcc %r1, %r2, %r4 ! Direccin prximo elemento ld %r4, %r5 !%r5 direccin Memor ia [%r4] addcc %r3, %r5, %r3 ! Sum ar n uevo element o en r3 ba done: length: address: .org a: jmpl loop ! Repe S tir l azo .
Creando una
Tabla de Smbolos
Smbolo a_start length (a)
Smbolo a_start length address loop done a (b) Valor 3000 2092 2096 2060 2088 3000
Valor 3000
loop:
(20
(a)
.end
! Fin de traduccin
5-11
Programa Ensamblado
Contador de posicin
Instruccin
Cdigo Objeto
2048 2052 2056 2060 2064 2068 2072 2076 2080 2084 2088 2092 2096 3000 3004 3008 3012 3016
.begin .org 2048 a_start .equ 3000 ld [length],%r1 ld [address],%r2 andcc %r3,%r0,%r3 loop: andcc %r1,%r1,%r0 be done addcc %r1,-4,%r1 addcc %r1,%r2,%r4 ld %r4,%r5 ba loop addcc %r3,%r5,%r3 done: jmpl %r15+4,%r0 length: 20 address: a_start .org a_start a: 25 -10 33 -5 7 .end
11000010 00000000 00101000 00101100 11000100 00000000 00101000 00110000 10000110 10001000 11000000 00000000 10000000 10001000 01000000 00000001 00000010 10000000 00000000 00000110 10000010 10000000 01111111 11111100 10001000 10000000 01000000 00000010 11001010 00000001 00000000 00000000 00010000 10111111 11111111 11111011 10000110 10000000 11000000 00000101 10000001 11000011 11100000 00000100 00000000 00000000 00000000 00010100 00000000 00000000 00001011 10111000 00000000 00000000 00000000 00011001 11111111 11111111 11111111 11110110 00000000 00000000 00000000 00100001 11111111 11111111 11111111 11111011 00000000 00000000 00000000 00000111
6-1
6-2
4-9
El Ciclo Fetch-Ejecucin
Los pasos que sigue una unidad de control para ejecutar un programa son: (1) Buscar de la memoria la siguiente instruccin a ejecutar. (2) Decodificar el opcode (cdigo de operacin). (3) Leer operando(s) desde la memoria principal, si hubiera alguno. (4) Ejecutar la instruccin y almacenar resultados. (5) Ir al paso 1. Esto se conoce como el ciclo fetch-ejecucin.
6-4
Seccin de Control
BUS DE SISTEMA
Principles of Computer Architecture by M. Murdocca and V. Heuring
1999 M. Murdocca and V. Heuring
4-11
Memoria
ld st sethi andcc
Lgicas
Aritmeticas
Control
4-14
0 0 0 0 0
rd cond
op2 op2
imm22 disp22
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0 1
disp30 i
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Formatos Aritmticos
1 0 1 0
rd rd
op3 op3
rs1 rs1
0 0 0 0 0 0 0 0 0 1 simm13
rs2
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
1 1 Formatos de Memoria 1 1
rd rd
op3 op3
rs1 rs1
0 0 0 0 0 0 0 0 0 1 simm13
rs2
op 00 01 10 11
op2
Inst.
op3 (op=10) 010000 010001 010010 010110 100110 111000 addcc andcc orcc orncc srl jmpl
cond salto 0001 0101 0110 0111 1000 be bcs bneg bvs ba
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
PSR
n z v c
1999 M. Murdocca and V. Heuring
6-7
C bus
0 1 2 3
A bus %r0 %r1 %r2 %r3 %r4 %r5 %r6 %r7 %r8 %r9
B bus
A Decoder
a37
C 1 Decoder
c37
37
4 5 6 7 8
38
b0
b37
B Decoder
CLOCK UNIT
10 %r10
Datapath ARC
32 64-to-32 MUX C Bus MUX
32
. . .
30 %r30 31 %r31
%pc
%ir
32
24
32
32
To Control Unit
F0 F1 ALU F 2 F3
6-8
6-14
Seccin de Datos (Datapath)
To A Decoder 6 A MUX
Select
Microarquitectura de ARC
To C Decoder 6 C MUX
Select
Area de trabajo
MIR C field 0, rd
To B Decoder 6 B MUX
%ir rd rs2
%i r rs1 ops
41
A A M U X B B M U X C C M U RW XDR ALU COND
C bus
IR[13]
CLOCK UNIT
A bus
32
B bus
2
IR[30,31,19-24]
32
32 1
F0 F1 ALU F 2 F3
3 4 4 %psr
4 n, z , v , c
Set Condition Codes
Acknowledge (ACK)
6-15
Formato de Microcdigo
A M U X B M U X C M U RW X D R ALU COND
JUMP ADDR
6-16
6-17
op3 0 0 op2
6-19
Address
0000: 0001: 00// 1152: 00// 1280: 1281: 1282: 1283: 0//0 1600: 1601: 1602: 1603: 00// 1604: 1605: 1606: 1607: 00// 1608: 1609: 1610: 1611: 00// 1624: 1625: 1626: 1627: 00// 1688: 1689: 1690: 1691: 00// 1760: 1761:
Operation Statements
R[ir] AND(R[pc],R[pc]); READ; DECODE; / sethi R[rd] LSHIFT10(ir); GOTO 2047; / call R[15] AND(R[pc],R[pc]); R[temp0] ADD(R[ir],R[ir]); R[temp0] ADD(R[temp0],R[temp0]); R[pc] ADD(R[pc],R[temp0]); GOTO 0; / addcc IF R[IR[13]] THEN GOTO 1602; R[rd] ADDCC(R[rs1],R[rs2]); GOTO 2047; R[temp0] SEXT13(R[ir]); R[rd] ADDCC(R[rs1],R[temp0]); GOTO 2047; / andcc IF R[IR[13]] THEN GOTO 1606; R[rd] ANDCC(R[rs1],R[rs2]); GOTO 2047; R[temp0] SIMM13(R[ir]); R[rd] ANDCC(R[rs1],R[temp0]); GOTO 2047; / orcc IF R[IR[13]] THEN GOTO 1610; R[rd] ORCC(R[rs1],R[rs2]); GOTO 2047; R[temp0] SIMM13(R[ir]); R[rd] ORCC(R[rs1],R[temp0]); GOTO 2047; / orncc IF R[IR[13]] THEN GOTO 1626; R[rd] NORCC(R[rs1],R[rs2]); GOTO 2047; R[temp0] SIMM13(R[ir]); R[rd] NORCC(R[rs1],R[temp0]); GOTO 2047; / srl IF R[IR[13]] THEN GOTO 1690; R[rd] SRL(R[rs1],R[rs2]); GOTO 2047; R[temp0] SIMM13(R[ir]); R[rd] SRL(R[rs1],R[temp0]); GOTO 2047; / jmpl IF R[IR[13]] THEN GOTO 1762; R[pc] ADD(R[rs1],R[rs2]); GOTO 0;
/ Read an ARC instruction from main memory / 256-way jump according to opcode / Copy imm22 field to target register / Save %pc in %r15 / Shift disp30 field left / Shift again / Jump to subroutine
/ Is second source operand immediate? / Perform ADDCC on register sources / Get sign extended simm13 field / Perform ADDCC on register/simm13 / sources / Is second source operand immediate? / Perform ANDCC on register sources / Get simm13 field / Perform ANDCC on register/simm13 / sources / Is second source operand immediate? / Perform ORCC on register sources / Get simm13 field / Perform ORCC on register/simm13 sources
/ Is second source operand immediate? / Perform ORNCC on register sources / Get simm13 field / Perform NORCC on register/simm13 / sources / Is second source operand immediate? / Perform SRL on register sources / Get simm13 field / Perform SRL on register/simm13 sources
6-20
1762: R[temp0] SEXT13(R[ir]); / Get sign extended simm13 field 1763: R[pc] ADD(R[rs1],R[temp0]); Chapter / Perform on register/simm13 sources 6: ADD Datapath and Control GOTO 0; 00// / ld 1792: R[temp0] ADD(R[rs1],R[rs2]); / Compute source address IF R[IR[13]] THEN GOTO 1794; 1793: R[rd] AND(R[temp0],R[temp0]); / Place source address on A bus READ; GOTO 2047; 1794: R[temp0] SEXT13(R[ir]); / Get simm13 field for source address 1795: R[temp0] ADD(R[rs1],R[temp0]); / Compute source address GOTO 1793; 00// / st 1808: R[temp0] ADD(R[rs1],R[rs2]); / Compute destination address IF R[IR[13]] THEN GOTO 1810; 1809: R[ir] RSHIFT5(R[ir]); GOTO 40; / Move rd field into position of rs2 field / by shifting to the right by 25 bits. 40: R[ir] RSHIFT5(R[ir]); 41: R[ir] RSHIFT5(R[ir]); 42: R[ir] RSHIFT5(R[ir]); 43: R[ir] RSHIFT5(R[ir]); 44: R[0] AND(R[temp0], R[rs2]); / Place destination address on A bus and WRITE; GOTO 2047; / place operand on B bus 1810: R[temp0] SEXT13(R[ir]); / Get simm13 field for destination address 1811: R[temp0] ADD(R[rs1],R[temp0]); / Compute destination address GOTO 1809; 00// / Branch instructions: ba, be, bcs, bvs, bneg 1088: GOTO 2; / Decoding tree for branches 2: R[temp0] LSHIFT10(R[ir]); / Sign extend the 22 LSBs of %temp0 3: R[temp0] RSHIFT5(R[temp0]); / by shifting left 10 bits, then right 10 4: R[temp0] RSHIFT5(R[temp0]); / bits. RSHIFT5 does sign extension. 5: R[ir] RSHIFT5(R[ir]); / Move COND field to IR[13] by 6: R[ir] RSHIFT5(R[ir]); / applying RSHIFT5 three times. (The 7: R[ir] RSHIFT5(R[ir]); / sign extension is inconsequential.) 8: IF R[IR[13]] THEN GOTO 12; / Is it ba? R[ir] ADD(R[ir],R[ir]); 9: IF R[IR[13]] THEN GOTO 13; / Is it not be? R[ir] ADD(R[ir],R[ir]); 10: IF Z THEN GOTO 12; / Execute be R[ir] ADD(R[ir],R[ir]); 11: GOTO 2047; / Branch for be not taken 12: R[pc] ADD(R[pc],R[temp0]); / Branch is taken GOTO 0; 13: IF R[IR[13]] THEN GOTO 16; / Is it bcs? R[ir] ADD(R[ir],R[ir]); 14: IF C THEN GOTO 12; / Execute bcs 15: GOTO 2047; / Branch for bcs not taken 16: IF R[IR[13]] THEN GOTO 19; / Is it bvs? 17: IF N THEN GOTO 12; / Execute bneg 18: GOTO 2047; / Branch for bneg not taken 19: IF V THEN GOTO 12; / Execute bvs 20: GOTO 2047; / Branch for bvs not taken 1999 M. Murdocca and V. Heuring 2047: R[pc] INCPC(R[pc]); GOTO 0; / Increment %pc and start over
6-22
Microstore Address A
A M U X
B M U X
0 1 1152 1280 1281 1282 1283 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1624 1625 1626 1627 1688 1689 1690 1691 1760 1761 1762 1763 1792
10000001000000100101010010100000000000000 00000000000000000000000010111100000000000 10010100000000000000100101011011111111111 10000001000000001111000010100000000000000 10010101001010100001000100000000000000000 10000101000010100001000100000000000000000 10000001000010100000000100011000000000000 00000000000000000000000010110111001000010 00000010000001000000100001111011111111111 10010100000000100001000110000000000000000 00000011000010000000100001111011111111111 00000000000000000000000010110111001000110 00000010000001000000100000011011111111111 10010100000000100001000101100000000000000 00000011000010000000100000011011111111111 00000000000000000000000010110111001001010 00000010000001000000100000111011111111111 10010100000000100001000101100000000000000 00000011000010000000100000111011111111111 00000000000000000000000010110111001011010 00000010000001000000100001011011111111111 10010100000000100001000101100000000000000 00000011000010000000100001011011111111111 00000000000000000000000010100011010011010 00000010000001000000100010011011111111111 10010100000000100001000101100000000000000 00000011000010000000100010011011111111111 00000000000000000000000010110111011100010 00000010000001100000000100011000000000000 10010100000000100001000110000000000000000 00000011000010100000000100011000000000000 00000010000001100001000100010111100000010
1999 M. Murdocca and V. Heuring
6-23
A
A M U X
B M U X
1793 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1794 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1795 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1808 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 0 1 0 0 1 0 1809 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 0 1 0 0 0 40 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 43 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1810 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1811 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1088 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 2 10010100000000100001000101000000000000000 3 10000100000000100001000111100000000000000 4 10000100000000100001000111100000000000000 5 10010100000000100101000111100000000000000 6 10010100000000100101000111100000000000000 7 10010100000000100101000111100000000000000 8 10010101001000100101000100010100000001100 9 10010101001000100101000100010100000001101 10 1 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 12 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 13 1 0 0 1 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 0 1 1 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 0 1 1 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 2047 1000000000000010000000011 10 1 1 M. 00 0 0 0 0 0and 0 0V. 00 0 Principles of Computer Architecture by M. Murdocca and V. Heuring 1999 Murdocca Heuring
6-27
Eplogo
Principles of Computer Architecture by M. Murdocca and V. Heuring
6-28
Z[1]
D Q 0 CLK
D Q 1
D Q 2
D Q 3
6-29
MODULE: ARC_CONTROL_UNIT. Chapter 6: Datapath and Control INPUTS: OUTPUTS: C, N, V, Z. ! Fijadas por la ALU MEMORY: R[16][32], pc[32], ir[32], temp0[32], temp1[32], temp2[32], temp3[32]. 0: ir AND(pc, pc); Read 1; ! Bsqueda de la Instruccin ! Decodificar el campo op 1: GOTO {2 CONDITIONED ON ir[31]ir[30], ! formato Branch/sethi: op=00 4 CONDITIONED ON ir[31]ir[30], ! formato Call: op=01 8 CONDITIONED ON ir[31]ir[30], ! formato Aritmetico : op=10 10 CONDITIONED ON ir[31]ir[30]}. ! formato de Memoria: op=11 ! Decodficar campo op2 2: GOTO 19 CONDITIONED ON ir[24]. ! si es formato de salto ir a 19 3: R[rd] ir[imm22]; ! sethi GOTO 20. 4: R[15] AND(pc, pc). ! call:Guardar pc en registro 15 5: temp0 ADD(ir, ir). ! desplazar campo disp30 a izq. 6: temp0 ADD(ir, ir). ! desplazar nuevamente 7: pc ADD(pc, temp0); GOTO 0. ! Saltar a subrutina ! Colocar el segundo operando origen en temp0 para el formato Aritmetico 8: temp0 { SEXT13(ir) CONDITIONED ON ir[13]NOR(ir[19:22]), ! addcc R[rs2] CONDITIONED ON ir[13]NOR(ir[19:22]), ! addcc SIMM13(ir) CONDITIONED ON ir[13]OR(ir[19:22]), ! Remaining R[rs2] CONDITIONED ON ir[13]OR(ir[19:22])}. ! Instrucciones Aritmticas ! Decodificar el campo op3 para el formato Aritmetico 9: R[rd] { ADDCC(R[rs1], temp0) CONDITIONED ON XNOR(IR[19:24], 010000), ! addcc ANDCC(R[rs1], temp0) CONDITIONED ON XNOR(IR[19:24], 010001), ! andcc ORCC(R[rs1], temp0) CONDITIONED ON XNOR(IR[19:24], 010010), ! orcc NORCC(R[rs1], temp0) CONDITIONED ON XNOR(IR[19:24], 010110), ! orncc SRL(R[rs1], temp0) CONDITIONED ON XNOR(IR[19:24], 100110), ! srl ADD(R[rs1], temp0) CONDITIONED ON XNOR(IR[19:24], 111000)}; ! jmpl GOTO 20. ! cargar en temp0 el segundo operando fuente si es formato de Memoria 10: temp0 {SEXT13(ir) CONDITIONED ON ir[13], R[rs2] CONDITIONED ON ir[13]}. 11: temp0 ADD(R[rs1], temp0). ! Decodificar el campo op3 field para el formato de Memoria GOTO {12 CONDITIONED ON ir[21], ! ld 13 CONDITIONED ON ir[21]}. ! st 12: R[rd] AND(temp0, temp0); Read 1; GOTO 20. 13: ir RSHIFT5(ir).
6-30
ir RSHIFT5(ir). ir RSHIFT5(ir). ir RSHIFT5(ir). ir RSHIFT5(ir). r0 AND(temp0, R[rs2]); Write 1; GOTO 20. pc { ! Instrucciones de salto (Branch) ADD(pc, temp0) CONDITIONED ON ir[28] + ir[28]ir[27]Z + ir[28]ir[27]ir[26]C + ir[28]ir[27]ir[26]ir[25]N + ir[28]ir[27]ir[26]ir[25]V, INCPC(pc) CONDITIONED ON ir[28]ir[27]Z + ir[28]ir[27]ir[26]C + ir[28]ir[27]ir[26]ir[25]N + ir[28]ir[27]ir[26]ir[25]V}; GOTO 0. 20: pc INCPC(pc); GOTO 0. END SEQUENCE. END ARC_CONTROL_UNIT.
6-31
Circuito HDL-ARC
La seccin de control cableada de ARC: generacin de seales de control.
CS0 D Q 0 CLK
CS4 D Q 4 D Q 5 D Q 6
CS8
CS13 D Q 12 CS12 D Q 13 D Q 14
CS14 D Q 15 CS15
CS16 D Q 16 D Q 17
CS17 D Q 18 CS18 D Q 19
CS19
CS20 D Q 20
6-32
Seccin de control cableado de ARC: Seales desde la seccin de datos de la unidad de control a la trayectoria de datos.
IR[20] IR[21] IR[28] Z IR[27] IR[28] IR[27] IR[26] C IR[28] IR[27] IR[26] IR[25] N IR[28] IR[27] IR[26] IR[25] C
IR[23] IR[24]
IR[19] IR[22]
CS15 CS14 CS16 CS18 Write CS17 CS7 CS0 CS4 BMUX CS19 CS 20
CS13
A[2]
A[5]
IR[20]
C[2] CS9 CS3 CS12 CS9 AMUX B[0] Read B[1] C[0] B[2] C[3] B[3] C[4] B[4] CMUX C[1]
CS13
CS15 CS14
CS2 CS12 CS4 CS1 CS3 CS10 ALU[2] CS14 CS13 CS15
CS9
C[5]
B[5]