flip flop מבוסס על הרצאות של יורם זינגר, האוניברסיטה העברית...
TRANSCRIPT
Flip Flop
מבוסס על הרצאות של
יורם זינגר, האוניברסיטה העברית י"ם
יהודה אפק, יוסי מטיאס אוניברסיטת תל אביב
Sequential Logicמערכות זיכרון –
שינוי עד כה טיפלנו במערכות צירופיות שהינן חסרות "זיכרון" או מצב. •בערכי היציאה. )לאחר השהייה(בערכי הכניסה גורר שינוי "מיידי"
מכילים זיכרון המשמש (Controllers) כל מחשב וכן בקרים מתוכנתים •לשמירת נתונים ולביצוע תוכניות.
(, Bubble memory וזיכרון בועות )SDRAM,ROM פרט למבנים כמו • של יחידות לוגיות.(feedback)"הזיכרון" מושג ע"י שימוש במשוב
Combinatorial Circuit
מעגל צירופי
Outputיציאות
Inputכניסות
Storage/Memיחידה זיכרון
Synchronous Sequential Circuits
פעולת המערכת מתבצעת ב"פיקודו" של שעון וערכי המערכת נקבעים מערכי הכניסה בנקודות זמן מסוימות שהינן תלויות שעון
מצב המערכת תלוי בשעון.
Asynchronous Sequential Circuits
של שינוי הכניסות, מצב המערכת בסדרפעולות המערכת תלויות יכול להשתנות בכל רגע.
"יציב"
"מהיר"
CombinatorialCircuit
MemoryClock Pulses
זכרון
1
2 Q’
Q0
1
1
0
זכרון
1
2
0
0 Q’
Q0
1
1
0
1 == קלט1 פלט קלט פלט0
L A T C H
1
2
S R – L a t c h
Reset
Set
R
S Q’
Q
1
O 11
00
0
0
L A T C H
1
2
S R – L a t c h
Reset
Set
R
S Q’
Q1
01 1
00
00
0
L A T C H
1
2
S R – L a t c h
Reset
Set
R
S Q’
Q
0)0( 0
1)0(
0 )1(
)1(
מקודם
מקודם
Set נניח שניתנה פקודת • S=1, R=0( ועתה אנו "מורידים" את הכניסות S=0, R=0.).Set "זוכרים" את פקודת ה-Q’, Q ערכי היציאה •.Reset באותו אופן יזכרו את ה - •
L A T C H
1
2
S R – L a t c h
Reset
Set
R
S Q’
Q
• R=1, S=1’ תלוי Q ו Q( הערך של S=0, R=0" )0 כאשר הערכים יורדים ל – "•
RACE Condition באיזה קו ישתנה ראשון
המצב הבא נקרא לא מוגדר.•
0
0
0
01
1
דיאגרמת זמנים:Q
S
R
"1""0""1""0""1""0"
טבלת אמת – מצבים:SRQQ’
0101
0001
1010
0010
1100
• Latch.איננו פונקציה בוליאנית האחרונה.Reset או Set ערכי היציאה תלויים בפעולת •( ערך היציאה נשמר קבוע כל זמן שיש 0,0 עבור כניסות )•
מתח.
Reset State
Set State
Undefined )מצב אסור(
SR Latch with NAND
SRQ’Q
0110
1110
1001
1101
0011
Set State
Reset State
Undefined
Set Command
Reset Command
10
10
R
S Q’
Q1
0 1
0
SR Latch with NAND
SRQ’Q
0110
1110
1001
1101
0011
Set State
Reset State
Undefined
Set Command
Reset Command
10
10
R
S Q’
Q1
0 1
0
SR Latch:מבוקר שעון
Clock Pulse
CSRNext Q
0No change
110Q = 1
101Q = 0
111Undef
100No change
S
R
CP
Q
R
S Q’
Q
CP
10
0
0
1
R
S
D )data( LatchD
Q’
QCP
Q = 1 )Set(Q = 0 )Reset(No changeNext State of Q
1 11 00 C D
• Latch D.הינו יחידה שאוגרת / "זוכרת" ביט יחיד
נמנעים ממצב לא מוגדר.•
(.Registers אבן בניין בסיסית של אוגרים )•
D'
1
1
0 11
00 1 1
0
D Latch!! אינו מספיק
Combinatorial Circuit
מעגל צירופי
Outputיציאות
Inputכניסות
D
Q’
QCP
מחזור שעון ארוך והמעגל יחליף את מצבו מספר פעמים !!!!
Flip - Flops מתייצב יכול ליצור בעיותLatchהזמן שלוקח עד שהמוצא של •
כאשר מחברים שתי יחידות זיכרון.המוצא אינו צריך להיות תלוי בתזמון וצריך להימנע "ממצבים •
(.JKמתהפכים" )פתרון צריך לדאוג שהמוצא יהיה יציב לפרק זמן מובטח. •
Flip-Flop פתרון מבוסס על Latch:
בצורה שתבטיח שהפלט יהיה מבודד Latchשימוש בשני •מהכניסות המשתנות:
Master-Slave Flip-Flop
Master – Slave Flip - Flop
אינו פעיל והינו זוכר את היציאות )S )slave פעיל M( masterכאשר ) • היה סביל.M מהשלב ש – Mשל
C
S
Y
Q
אין השפעה!
S
R
C
Q
Q’
ת ר
בג S
R
C
Q
Q’
ד ב
ע
SM
S
R
C
Q
Q’
Y
Y’
Master – Slave Flip - Flop
מהשלב ש – M אינו פעיל והינו זוכר את היציאות של S פעיל Mכאשר •M.היה סביל
C
S
Y
Q
אין השפעה!
1
0 10 01
1נשאר
נעשה פעיל
01S
R
C
Q
Q’
ת ר
בג S
R
C
Q
Q’
ד ב
ע
SM
S
R
C
Q
Q’
Y
Y’
D Flip Flop!! כן מספיק
Combinatorial Circuit
מעגל צירופי
Inputכניסות
S
RC
Q
Q’
ר ב
ג ת
S
RC
Q
Q’
ב ע
ד
SMS
R
C
Q
Q’
Y
Y’
:SR Latch"עידון" של •
JK Latch
אין שינוי מצב כמקודם.CP=0 כאשר • :K = 0 , J = 1 כאשר •
.K=0 לא משפיע היות ו – 1 לתוך שער Qא( המשוב מ – . Q=1 Q’=0 0,0 הינם 3 ב( כניסות לשער
.Q’=1 Q=0 נקבל K=1, J=0 כאשר • ?K=1, J=1 כאשר •
K
J Q’
QCP
3
4
1
2
0
11
11 1
0 )"חדש"( 1
)"חדש"( 0
1)ישן(
10)חדש(
)ישן(
Q=0 K=0 J=1 a
:SR Latch"עידון" של •
JK Latch
K
J Q’
QCP
3
4
1
2
אין שינוי מצב כמקודם.CP=0 כאשר • :K = 0 , J = 1 כאשר •
.K=0 לא משפיע היות ו – 1 לתוך שער Qא( המשוב מ – . Q=1 Q’=0 0,0 הינם 3 ב( כניסות לשער
.Q’=1 Q=0 נקבל K=1, J=0 כאשר • ?K=1, J=1 כאשר •
1
00 0
0 0 )"ישן"(
1 )ישן(
1
Q=0 K=1 J=0 b
0
0 0
1
)ישן(
)ישן(1
0
המצב "נשמר"
Reset או :SR Latch"עידון" של •
JK Latch
K
J Q’
QCP
3
4
1
2
אין שינוי מצב כמקודם.CP=0 כאשר • :K = 0 , J = 1 כאשר •
.K=0 לא משפיע היות ו – 1 לתוך שער Qא( המשוב מ – . Q=1 Q’=0 0,0 הינם 3 ב( כניסות לשער
.Q’=1 Q=0 נקבל K=1, J=0 כאשר • ?K=1, J=1 כאשר •
מתהפך.Q מצב יתהפך עוד ועוד.Q לאורך זמן מצב J=K=C=1 אם
.מעברים חוזרים ונשנים
1
0 0
0 0
1 1)0(
)1(
K=1 J=1 c
:SR Latch"עידון" של •
JK Latch
K
J Q’
QCP
3
4
1
2
אין שינוי מצב כמקודם.CP=0 כאשר • :K = 0 , J = 1 כאשר •
.K=0 לא משפיע היות ו – 1 לתוך שער Qא( המשוב מ – . Q=1 Q’=0 0,0 הינם 3 ב( כניסות לשער
.Q’=1 Q=0 נקבל K=1, J=0 כאשר • ?K=1, J=1 כאשר •
:JKטבלת אמת עבור Q)t(JKQ)t+1(
00000010010101111001101011011110
דיאגרמת זמנים:J
K
CP
Q
Q הלוך ושוב כל זמן ש – 1 ל –0 יתהפך בין cp=1
T )trigger( Latch
למקור אחד:JK-Latch ב J,K מתקבל ע"י חיבור •
T = 0 J = K = 0אין שינוי במצב
T = 1 J = K = 1היפוך מצב
הינו "קצר"T = 1היפוך זה יחיד אם משך הזמן בו
QtTQt+1
000
011
101
110
QtDQt+1
000
011
100
111
JK Flip-Flop:
הינה קבועה.Q היציאה J = K = 1 כאשר •
התהפך(.Y יהפוך מצב )Master עם עליית השעון ה •
• Q" ו – 1 ישאר קבוע כל זמן שהשעון הינו "Y ישאר קבוע לאחר עליית השעון.
ישתנה.Q ו – D Latch יוכנס ל – Y עם ירידת השעון הערך של •
S
R
CQ
SRLatch
D
C
DLatch
SlaveMasterJ
K
C
Q
Q’
Y1
Y0
01
01
0
1
1
10
10
10
0 1
0
)0(
)1(
Q
Q’
T )trigger( Flip-Flop
S
RC
QSRLatch
D
C
DLatch
SlaveMasterQ
Q’
QY
Q’T
D
C
DLatch
D
C
DLatch
SlaveMasterQ
YD
Q)t+1( D)t(
D )data( Flip-Flop
Q)t( Q’)t+1(
Q)t( Q)t(
T=1
T=0
טבלאות המצבים:
JKQ)t+1(00Q)t(No Change010Reset101Set11Q’)t(Complement
tQ)t(
t+1Q)t(
שינוי של פלט
שינוי של קלט
JKFFSRQ)t+1(00Q)t(No Change010Reset101Set11?Undef.
SRFF
DQ)t+1(00Reset11Set
DFFTQ)t+1(0Q)t(No Change1Q’)t(Complement
TFF
0-ים מאז ה- 1 3 אחרי ש"ראה" לפחות 1האוטומט פולט •האחרון.
Moore FSMפלט מצוייר במצבים •
00/0
01/0
11/0
10/1
0
0
01
1
1
0
1
=I קלט)כמקודם(
=Oפלט
Finite State Machine (FSM)
Finite State Machine (FSM)
00
01
10
11
0-ים מאז ה- 1 3 אחרי ש"ראה" לפחות 1האוטומט פולט •האחרון.
Mealy FSMפלט מצוייר על הקשתות •
0/0
0/0
0/01/0
1/0
1/1
0/0
1/1
קלט )כמקודם(
פלט
Mooreטבלת המצבים –
AtBt
I=0I=1
At+1Bt+1At+1Bt+1Ot
0000010
0100110
1100100
1000101
A & Bהפלט תלוי ב –
00/0
01/0
11/0
10/1
0
0
01
1
10
1
Mealyטבלת המצבים -
AtBt
X=0X=1X=0X=1
At+1Bt+1At+1Bt+1OtOt
00000100
01001000
10001100
11001101
Xהפלט תלוי ב -
Mooreטבלת המצבים –
AtBt
I=0I=1
At+1Bt+1At+1Bt+1Ot
0000010
0100110
1100100
1000101
0
00/0
01/0
11/0
10/1
0
01
1
10
1
At+100011110
0
1
AB
I
Bt+100011110
0
1
AB
Mooreדוגמא -
כניסה אחת ויציאה אחת•
•2FF מסוג Data 4.מצבים
A
B
D
D Q
Q’
Q
Q’
At+1= A*I + B * I= I)A+B(
I
Bt+1= A*I
O = A*B
O
Mealyדוגמא –
כניסה אחת ויציאה אחת•
.Xו- QA, QBהיציאה תלויה ב- •
•2FF מסוג Data 4.מצבים
A
B
X Out
D
D Q
Q’
Q
Q’
Moore Vs. Mealyפלט:
Mooreפונקציה של המצב לבד –
Mealyפונקציה של המצב והקלט –
אוטומט:Mooreהפלט "רשום" על המצב –
Mealy)הפלט "רשום" על הקשת )מעבר –
שיקולים:Moore מספיק שיהיה קבוע( לא תלוי ב"יציבות" הקלט – Ts + Th )
נוספים אם דרושה תלות היציאה בקלט.FFs אך ידרשו
Mealy פשוט לממוש אם יש תלות של היציאה בקלט אך נדרשת – יציבות.
Moore – שקול ל Mealy)ולהפך(
נוהל עיצוב
הגדר במילים את פעולת המעגל.1.
)אוטומט(בנה את טבלת המצבים 2.
צמצם / מצא ייצוג קטן של אוטומט המצבים.3.
קבע משתנים אשר ייצגו את המצבים )בצורה 4.וקטורית(. קבע את מספר הדלגלגים והתאם אות לכל
דלגלג.
בחר בסוג הדלגלג להשתמש בו.5.
קבל טבלאות העירור והיציאות של המעגל מטבלת 6.המצבים.
חשב את פונקציות היציאה של המעגל ואת פונקציות 7. )בעזרת מפות קרנו או כל שיטה FFהכניסה של
אחרת(
צייר הדיאגרמה הלוגית.8.
*
דוגמת תכנון
מערבמרכזמזרח
"ימינה""שמאלה"
"שמאלה""ימינה"
"שמאלה""ימינה" "תקין"
"תקין" "תקין"
"תקין"
"תקוע""תקוע"
IRobot
אוטומט המצבים – תיאור סמלי:
מרכז
מזרחמערב
תקין /
שמאל
תקין /
ין ימיןתק
/
אלשמ
ין תק
/מין
י
ימין/ תקוע
/ תקוע שמאל
אוטומט המצבים:
0: "ימין"1: "שמאל"
0: תקין1: תקוע
00
0110מזרח מערב
מרכז
1/0
0/01/0
0/0
0/1
1/1
BAקלט
פלט
מצבים3• – 2נזדקק לFF2FF "מצבים.4 יכולים "לזכור "( 11מצב שלא משתמשים בו)"
המצב הנוכחי
קלט X
המצב הבא
פלט Y
A
BAB
000100
001010
010000
011011
100101
101000
המצב הנוכחי
קלט X
המצב הבא
פלט Y
A
BAB
000100
001010
010000
011011
100101
101000
טבלת המצבים + מעברים:
פונקציות יציאה + מצב הבא:D-FF מימוש עבור
)3,4(Y)t( )1,3( 1(B)t )0,4(1(A)t
11
Bt
Xt
At
11
Bt
Xt
At
11
Bt
Xt
At
A)t+1( = B’X’ = )B+X(’
B)t+1( = A’X
Y)t( = AX’ + BX
דיאגרמה לוגית:
A
B
Q
Q’
D
C
Q
Q’
D
C
XB’X’
A’X
y
BX
AX’
)שעון מושמט(DFFמימוש עבור
•How many state bits will we need?
Graphical Specification of FSM
PCWritePCSource = 10
ALUSrcA = 1ALUSrcB = 00ALUOp = 01PCWriteCond
PCSource = 01
ALUSrcA =1ALUSrcB = 00ALUOp= 10
RegDst = 1RegWrite
MemtoReg = 0
MemWriteIorD = 1
MemReadIorD = 1
ALUSrcA = 1ALUSrcB = 10ALUOp = 00
RegDst = 0RegWrite
MemtoReg =1
ALUSrcA = 0ALUSrcB = 11ALUOp = 00
MemReadALUSrcA = 0
IorD = 0IRWrite
ALUSrcB = 01ALUOp = 00
PCWritePCSource = 00
Instruction fetchInstruction decode/
register fetch
Jumpcompletion
BranchcompletionExecution
Memory addresscomputation
Memoryaccess
Memoryaccess R-type completion
Write-back step
(Op = 'LW') or (Op = 'SW') (Op = R-type)
(Op
= 'B
EQ')
(Op
= 'J
')
(Op = 'SW
')
(Op
= 'L
W')
4
01
9862
753
Start
Finite State Machine for ControlPCWrite
PCWriteCond
IorD
MemtoReg
PCSource
ALUOp
ALUSrcB
ALUSrcA
RegWrite
RegDst
NS3NS2NS1NS0
Op5
Op4
Op3
Op2
Op1
Op0
S3
S2
S1
S0
State register
IRWrite
MemRead
MemWrite
Instruction registeropcode field
Outputs
Control logic
Inputs
Op5
Op4
Op3
Op2
Op1
Op0
S3
S2
S1
S0
IorD
IRWrite
MemReadMemWrite
PCWritePCWriteCond
MemtoRegPCSource1
ALUOp1
ALUSrcB0ALUSrcARegWriteRegDstNS3NS2NS1NS0
ALUSrcB1ALUOp0
PCSource0
0 0 0 0 0 1 10 0 1 1 1 0 00 1 0 1 1 0 00 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 11 1 0 0 1 1 01 1 1 0 1 1 1
The control signals decoderWe just implement the table of slide 54: Let’s look at ALUSrcA: it is “0” in states 0 and 1 and it is “1” in states 2, 6 and 8. In all other states we don’t care. let’s look at PCWrite: it is “1” in states 0 and 9. In all other states it must be “0”.And so, we’ll fill the table below and build the decoder.
S3 S2 S1 S0 ALUSrcA
state Control signals
0 10 0 0 0
01 00 0 0
0
0 0
10
1 0
X
1 X 0
0
0 00 1 0 1
PCWrite
0
1 0
11
0 0
X
1 X 0
0
All other combinations X
0 01 1
0 11 0 1
1
X
1 00 1 1
PCWriteCond
0
0
0
0
0
0
0
0
0
0
1
0
0
0
fetch
decode
AdrCmp
load
WB
store
ALU
WBR
branch
jump
The state machine “next state calc.” logic
R-type=000000, lw=100011, sw=101011, beq=000100, bne=000101, lui=001111, j=0000010, jal=000011, addi=001000
Fetch
0
Jump
9
WBR
7
Load
3
Branch
8ALU 6
AdrCmp 2
Store
5
Decode
1
WB
4
lw+sw
R-typebeq j
swlw
IR31 IR30 IR29 IR28 IR27 IR26
opcode
S3 S2 S1 S0
current state
S3 S2 S1 S0
next state
X 0X X X X X 0 0 0 0 0 0 1
0 0 0 1 0 1 1 00 0 00 0 0
X
X 1
0X
X X X
X X X
X
0 0 1 0
0 0 1 0
0 0 1 1
0 1 0 1
1 0X X X X X 0 0 1 0 0 1 0
R-type
lw
sw
lw+sw
Interrupt and exception
Type of event From Where ? MIPS terminology
Interrupt External I/O device request
------------------------------------------------------------------------------------
Invoke Operation system Internal Exception
From user program
-------------------------------------------------------------------------------------
Arithmetic Overflow Internal Exception
-------------------------------------------------------------------------------------
Using an undefined
Instruction Internal Exception--------------------------------------------------------------------------------------
Hardware malfunctions Either Exception or interrupt
Exceptions handling
Exception type Exception vector address )in hex(
Undefined instruction c0 00 00 00
Arithmetic Overflow c0 00 00 20
We have 2 ways to handle exceptions:
Cause register or Vectored interrupts
MIPS – Cause register
Handling exceptions
Handling exceptions
Shiftleft 2
Memory
MemData
Writedata
Mux
0
1
Instruction[15– 11]
Mux
0
1
4
Instruction[15– 0]
Signextend
3216
Instruction[25– 21]
Instruction[20– 16]
Instruction[15– 0]
Instructionregister
ALUcontrol
ALUresult
ALUZero
Memorydata
register
A
B
IorD
MemRead
MemWrite
MemtoReg
PCWriteCond
PCWrite
IRWrite
Control
Outputs
Op[5– 0]
Instruction[31-26]
Instruction [5– 0]
Mux
0
2
Jumpaddress [31-0]Instruction [25– 0] 26 28
Shiftleft 2
PC [31-28]
1
Address
EPC
CO 00 00 00 3
Cause
ALUOp
ALUSrcB
ALUSrcA
RegDst
PCSource
RegWrite
EPCWriteIntCauseCauseWrite
1
0
1 Mux
0
3
2
Mux
0
1
Mux
0
1
PC
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
ALUOut
Fetch
Jump
WBR
Load
BranchALU
AdrCmp
Store
Decode
WB
1
5
2 86
9
0
74
3
lw+swR-type be
q
j
sw
lw
SavePC
10
IRET
1
JumpInt
11
Handling interrupts:
PLA Implementation• If I picked a horizontal or vertical line could you explain it?
Op5
Op4
Op3
Op2
Op1
Op0
S3
S2
S1
S0
IorD
IRWrite
MemReadMemWrite
PCWritePCWriteCond
MemtoRegPCSource1
ALUOp1
ALUSrcB0ALUSrcARegWriteRegDstNS3NS2NS1NS0
ALUSrcB1ALUOp0
PCSource0
• ROM = "Read Only Memory"– values of memory locations are fixed ahead of time
• A ROM can be used to implement a truth table– if the address is m-bits, we can address 2m entries in the ROM.– our outputs are the bits of data that the address points to.
m is the "heigth", and n is the "width"
ROM Implementation
m n
0 0 0 0 0 1 10 0 1 1 1 0 00 1 0 1 1 0 00 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 11 1 0 0 1 1 01 1 1 0 1 1 1
• How many inputs are there?6 bits for opcode, 4 bits for state = 10 address lines(i.e., 210 = 1024 different addresses)
• How many outputs are there?16 datapath-control outputs, 4 state bits = 20
outputs
• ROM is 210 x 20 = 20K bits (and a rather unusual size)
• Rather wasteful, since for lots of the entries, the outputs are the same
— i.e., opcode is often ignored
ROM Implementation
• Break up the table into two parts
— 4 state bits tell you the 16 outputs, 24 x 16 bits of ROM
— 10 bits tell you the 4 next state bits, 210 x 4 bits of ROM
— Total: 4.3K bits of ROM
• PLA is much smaller
— can share product terms
— only need entries that produce an active output
— can take into account don't cares
• Size is )#inputs #product-terms( + )#outputs #product-terms(
For this example = )10x17(+)20x17( = 460 PLA cells
• PLA cells usually about the size of a ROM cell )slightly bigger(
ROM vs PLA
MicroprogrammingPCWritePCWriteCondIorD
MemtoRegPCSourceALUOpALUSrcBALUSrcARegWrite
AddrCtl
Outputs
Microcode memory
IRWrite
MemReadMemWrite
RegDst
Control unit
Input
Microprogram counter
Address select logic
Op[
5–
0]
Adder
1
Datapath
Instruction registeropcode field
BWrite
•What are the “microinstructions? ”
State
Op
Adder
1
PLA or ROM
Mux3 2 1 0
Dispatch ROM 1Dispatch ROM 2
0
AddrCtl
Address select logic
Instruction registeropcode field
• A specification methodology– appropriate if hundreds of opcodes, modes, cycles, etc.– signals specified symbolically using microinstructions
• Will two implementations of the same architecture have the same microcode?
• What would a microassembler do?
Microprogramming
LabelALU
control SRC1 SRC2Register control Memory
PCWrite control Sequencing
Fetch Add PC 4 Read PC ALU SeqAdd PC Extshft Read Dispatch 1
Mem1 Add A Extend Dispatch 2LW2 Read ALU Seq
Write MDR FetchSW2 Write ALU FetchRformat1 Func code A B Seq
Write ALU FetchBEQ1 Subt A B ALUOut-cond FetchJUMP1 Jump address Fetch
DetailsDispatch ROM 1 Dispatch ROM 2
Op Opcode name Value Op Opcode name Value000000 R-format 0110 100011 lw 0011000010 jmp 1001 101011 sw 0101000100 beq 1000100011 lw 0010101011 sw 0010
State number Address-control action Value of AddrCtl
0 Use incremented state 31 Use dispatch ROM 1 12 Use dispatch ROM 2 23 Use incremented state 34 Replace state number by 0 05 Replace state number by 0 06 Use incremented state 37 Replace state number by 0 08 Replace state number by 0 09 Replace state number by 0 0
State
Op
Adder
1
PLA or ROM
Mux3 2 1 0
Dispatch ROM 1Dispatch ROM 2
0
AddrCtl
Address select logic
Instruction registeropcode field
Microinstruction formatField name Value Signals active Comment
Add ALUOp = 00 Cause the ALU to add.ALU control Subt ALUOp = 01 Cause the ALU to subtract; this implements the compare for
branches.Func code ALUOp = 10 Use the instruction's function code to determine ALU control.
SRC1 PC ALUSrcA = 0 Use the PC as the first ALU input.A ALUSrcA = 1 Register A is the first ALU input.B ALUSrcB = 00 Register B is the second ALU input.
SRC2 4 ALUSrcB = 01 Use 4 as the second ALU input.Extend ALUSrcB = 10 Use output of the sign extension unit as the second ALU input.Extshft ALUSrcB = 11 Use the output of the shift-by-two unit as the second ALU input.Read Read two registers using the rs and rt fields of the IR as the register
numbers and putting the data into registers A and B.Write ALU RegWrite, Write a register using the rd field of the IR as the register number and
Register RegDst = 1, the contents of the ALUOut as the data.control MemtoReg = 0
Write MDR RegWrite, Write a register using the rt field of the IR as the register number andRegDst = 0, the contents of the MDR as the data.MemtoReg = 1
Read PC MemRead, Read memory using the PC as address; write result into IR (and lorD = 0 the MDR).
Memory Read ALU MemRead, Read memory using the ALUOut as address; write result into MDR.lorD = 1
Write ALU MemWrite, Write memory using the ALUOut as address, contents of B as thelorD = 1 data.
ALU PCSource = 00 Write the output of the ALU into the PC.PCWrite
PC write control ALUOut-cond PCSource = 01, If the Zero output of the ALU is active, write the PC with the contentsPCWriteCond of the register ALUOut.
jump address PCSource = 10, Write the PC with the jump address from the instruction.PCWrite
Seq AddrCtl = 11 Choose the next microinstruction sequentially.Sequencing Fetch AddrCtl = 00 Go to the first microinstruction to begin a new instruction.
Dispatch 1 AddrCtl = 01 Dispatch using the ROM 1.Dispatch 2 AddrCtl = 10 Dispatch using the ROM 2.
• No encoding:– 1 bit for each datapath operation
– faster, requires more memory )logic(
– used for Vax 780 — an astonishing 400K of memory!
• Lots of encoding:– send the microinstructions through logic to get control signals
– uses less memory, slower
• Historical context of CISC:– Too much logic to put on a single chip with everything else
– Use a ROM )or even RAM( to hold the microcode
– It’s easy to add new instructions
Maximally vs. Minimally Encoded
Microcode: Trade-offs• Distinction between specification and implementation is sometimes blurred
• Specification Advantages:
– Easy to design and write
– Design architecture and microcode in parallel
• Implementation )off-chip ROM( Advantages
– Easy to change since values are in memory
– Can emulate other architectures
– Can make use of internal registers
• Implementation Disadvantages, SLOWER now that:
– Control is implemented on same chip as processor
– ROM is no longer faster than RAM
– No need to go back and make changes
“Macro and micro - instruction” Interpretation
MainMemory
executionunit
controlmemory
CPU
ADDSUBAND
DATA
.
.
.
User program plus Data
this can change!
AND microsequence
e.g., Fetch Calc Operand Addr Fetch Operand(s) Calculate Save Answer(s)
one of these ismapped into oneof these
The Big Picture
Initialrepresentation
Finite statediagram
Microprogram
Sequencingcontrol
Explicit nextstate function
Microprogram counter+ dispatch ROMS
Logicrepresentation
Logicequations
Truthtables
Implementationtechnique
Programmablelogic array
Read onlymemory
דלגלגים מדורבני קצה:Edge Triggered Flip-Flops
השעון ומתייצב אח"כ.שינוי המצב מתבצע עם שינוי•
דופק ושעון חיובי
קצה חיוביקצה שלילי
דופק ושעון שלילי
קצה שליליקצה חיובי
Ts-Setup Time
Th-Holdup Time
CP
D TnTs
Ts+Tnיציב
כניסות ישירות:Direct Inputs
איננו מוגדר Flip Flops כאשר המתח במעגל ספרתי "עולה" המצב של •לכן יש לבצע אתחול.
אתחול מבוצע ע"י כניסות ישירות אשר קובעות ישירות את המצב •(Preset.)
J
K
Q
Q’
preset / clear
CP
PreSetCPJKQQ’001100no change1010111010111flip state
מעגלים סדרתיים – תזמון:
J
KCP
QA
J
KB OutQ
Q’
CP
Q’
MSJFFMSJFFדוגמא:YBYA
Out)t(D)t-2( 2JKF
F
CP
YA
QA
YBQB