Presentation is loading. Please wait.

Presentation is loading. Please wait.

Finite State Machines מבוסס על הרצאות של יורם זינגר, האוניברסיטה העברית י"ם יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב.

Similar presentations


Presentation on theme: "Finite State Machines מבוסס על הרצאות של יורם זינגר, האוניברסיטה העברית י"ם יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב."— Presentation transcript:

1 Finite State Machines מבוסס על הרצאות של יורם זינגר, האוניברסיטה העברית י"ם יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב

2 האוטומט פולט 1 אחרי ש " ראה " לפחות 3 1 - ים מאז ה - 0 האחרון. פלט מצוייר במצבים Moore FSM 00/0 01/0 11/0 10/1 0 0 0 1 1 1 0 1 =I קלט ( כמקודם ) =O פלט Finite State Machine (FSM)

3 00 01 10 1 האוטומט פולט 1 אחרי ש " ראה " לפחות 3 1 - ים מאז ה - 0 האחרון. פלט מצוייר על הקשתות Mealy FSM 0/00/0 0/00/0 0/00/0 1/01/0 1/01/0 1/11/1 0/00/0 1/11/1 קלט ( כמקודם ) פלט

4 טבלת המצבים –Moore AtAt BtBt I=0I=1 A t+1 B t+1 A t+1 B t+1 OtOt 0000010 0100110 1100100 1000101 הפלט תלוי ב – A & B 00/0 01/0 11/0 10/1 0 0 0 1 1 1 0 1

5 טבלת המצבים - Mealy AtAt BtBt X=0X=1 X=0X=1 A t+1 B t+1 A t+1 B t+1 OtOt OtOt 00000100 01001000 10001100 11001101 הפלט תלוי ב - X

6 טבלת המצבים – Moore AtAt BtBt I=0I=1 A t+1 B t+1 A t+1 B t+1 OtOt 0000010 0100110 1100100 1000101 0 00/0 01/0 11/0 10/1 0 0 1 1 1 0 1 10110100A t+1 0 1 AB I 10110100B t+1 0 1 AB

7 דוגמא - Moore כניסה אחת ויציאה אחת 2FF מסוג Data  4 מצבים. A B D DQ Q’ Q A t+1 = A*I + B * I= I(A+B) I B t+1 = A*I O = A*B O

8 דוגמא – Mealy כניסה אחת ויציאה אחת היציאה תלויה ב - Q A, Q B ו - X. 2FF מסוג Data  4 מצבים. A B X Out D DQ Q’ Q

9 Moore Vs. Mealy פלט : Moore – פונקציה של המצב לבד Mealy – פונקציה של המצב והקלט אוטומט : Moore – הפלט " רשום " על המצב Mealy – הפלט " רשום " על הקשת ( מעבר ) שיקולים : Moore – לא תלוי ב " יציבות " הקלט ( מספיק שיהיה קבוע T s + T h ) אך ידרשו FFs נוספים אם דרושה תלות היציאה בקלט. Mealy – פשוט לממוש אם יש תלות של היציאה בקלט אך נדרשת יציבות. Moore שקול ל – Mealy ( ולהפך )

10 נוהל עיצוב 1. הגדר במילים את פעולת המעגל. 2. בנה את טבלת המצבים ( אוטומט ) 3. צמצם / מצא ייצוג קטן של אוטומט המצבים. 4. קבע משתנים אשר ייצגו את המצבים ( בצורה וקטורית ). קבע את מספר הדלגלגים והתאם אות לכל דלגלג. 5. בחר בסוג הדלגלג להשתמש בו. 6. קבל טבלאות העירור והיציאות של המעגל מטבלת המצבים. 7. חשב את פונקציות היציאה של המעגל ואת פונקציות הכניסה של FF ( בעזרת מפות קרנו או כל שיטה אחרת ) 8. צייר הדיאגרמה הלוגית. *

11 דוגמת תכנון מזרח מרכזמערב " שמאלה " "ימינה" " שמאלה " " ימינה "" שמאלה " " תקין " " תקוע " I Robot

12 אוטומט המצבים – תיאור סמלי : מרכז מערבמזרח תקין / שמאל תקין / ימין תקין / שמאל תקין / ימין תקוע / ימין תקוע / שמאל

13 אוטומט המצבים : " ימין ": 0 " שמאל ": 1 תקין : 0 תקוע : 1 00 0110 מזרח מערב מרכז 1/0 0/0 1/0 0/0 0/1 1/1 BA קלט פלט 3 מצבים  נזדקק ל – 2FF  2FF יכולים " לזכור " 4 מצבים.  מצב שלא משתמשים בו (" 11") המצב הנוכחי קלט X המצב הבא פלט Y A BAB 000100 001010 010000 011011 100101 101000

14 המצב הנוכחי קלט X המצב הבא פלט Y A BAB 000100 001010 010000 011011 100101 101000 טבלת המצבים + מעברים :

15 פונקציות יציאה + מצב הבא : מימוש עבור D-FF 1 1  BtBt XtXt AtAt 11  BtBt XtXt AtAt 1 1  BtBt XtXt AtAt A(t+1) = B’X’ = (B+X)’ B(t+1) = A’X Y(t) = AX’ + BX

16 דיאגרמה לוגית : A B Q Q’ D C Q D C X B’X’ A’X y BX AX’ מימוש עבור DFF ( שעון מושמט )

17 How many state bits will we need? Preview: Graphical Specification of FSM

18 Finite State Machine for Control 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 0 1 1 1

19 Execution Cycle Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction Obtain instruction from program storage Determine required actions and instruction size Locate and obtain operand data Compute result value or status Deposit results in storage for later use Determine successor instruction

20 The control signals decoder We 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.

21 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 8 ALU 6 AdrCmp 2 Store 5 Decode 1 WB 4 lw+sw R-type beq j swlw IR31IR30IR29IR28IR27IR26 opcode S3S2S1S0 current state S3S2S1S0 next state X0XXXXX0000001 00010110000000 X X1 0X XXX XXX X 0010 0010 0011 0101 10XXXXX0010010 R-type lw sw lw+sw

22 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

23 Exceptions handling Exception typeException 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

24 Handling exceptions

25

26 Fetch Jump WBR Load Branch ALU AdrCmp Store Decode WB 1 5 28 6 9 0 74 3 lw+sw R-type be q j swsw lw SavePC 10 IRET 1 JumpInt 11 Handling interrupts:

27 PLA Implementation If I picked a horizontal or vertical line could you explain it?

28 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 2 m 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 mn 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 0 1 1 1

29 How many inputs are there? 6 bits for opcode, 4 bits for state = 10 address lines (i.e., 2 10 = 1024 different addresses) How many outputs are there? 16 datapath-control outputs, 4 state bits = 20 outputs ROM is 2 10 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

30 Where are We Going?? מבנה מחשבים  Arithmetic Single/multicycle Datapaths IFetchDcdExecMemWB IFetchDcdExecMemWB IFetchDcdExecMemWB IFetchDcdExecMemWB PipeliningMemory Systems I/O

31 Break up the table into two parts — 4 state bits tell you the 16 outputs, 2 4 x 16 bits of ROM — 10 bits tell you the 4 next state bits, 2 10 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

32 Microprogramming What are the “microinstructions” ?

33 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

34 Details

35 Microinstruction format

36 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

37 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

38 “Macro and micro - instruction” Interpretation Main Memory execution unit control memory CPU ADD SUB AND 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 is mapped into one of these

39 The Big Picture


Download ppt "Finite State Machines מבוסס על הרצאות של יורם זינגר, האוניברסיטה העברית י"ם יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב."

Similar presentations


Ads by Google