کامپیوتر و IT و اینترنتعلوم مهندسی

داده های چند مرحله ای

صفحه 1:
00 Department of Computer and IT Engineering University of Kurdistan O1PC cktapads (Dut-Ovrle) By: Dr. Alireza Abdollahpouri

صفحه 2:
® Dulac DIPG provessor 0 University of Kurdistan

صفحه 3:
مومت مر( ) اعم |_| ات ‎tea Ter‏ اش eek ‘saved ۳ ‏ععاسو9‎ Sudes Oracles Codes ove ۳ ۳۹ [tro] ‏سردي‎ 4 09 University of Kurdistan

صفحه 4:
نگرش هه سرد < هر دستور به تعدادی مرحله کوچکتر تقسیم شده و هر یک از این مراحل در یک کلاک اجرا ميشوند. بدین ترتیب برای اجرای هر دستور به تعدادی کلاک کوچک تر نیاز خواهیم داشت. = مراحل طوری انتخاب میشوند که کار انجام گرفته در آنها متعادل باشد. < در هر مرحله فقط از یکی از بلوک های سخت افزاری اصلی استفاده ميشود. < هر دستور تعداد متفاوتى كلاك لازم دارد. < فقط به يك حافظه نياز دارد. البته در هر سيكل فقط ميتوان يكبار به حافظه دسترسى داشت. > فقط به یک 0007/(),(() نیاز دارد. البته در هر سیکل بیش از یکبار از () نمیتوان استفاده نمود. ‎University of kurdistan‏ 9

صفحه 5:
"2 در این معماری مقادیری که در سیکلهای بعدی دستور مورد نیاز هستند در رجیسترهائی ذخیره ميشوند. در نتیجه باید اجزای زیر به معماری افزوده شوند: MOOR — Oewory Oata Reyister AR — Iestruction Reyister ®LOvu — COLO ovutpul reqister®, @ — rewPie read data reyisters: 09 University of kurdistan

صفحه 6:
یو له زر ی سم اسر سس لحجاصا مت ول عمط و جا وله ‎entra‏ سا توا مت بخ ‎LO, wth cukipexers to select he proper rants.‏ ‎Oe cre PBLOGro® se he Prot BLO kpu be he PO or a rector.‏ @ > تست ما نج 00 له سا لت 60۵۷۵ مین میدق خ (دجسجمه هط و بت (۵60) با سس ما ۵ و و ‎(Por efPevive akiesses), ord‏ مه سوه ‎(Por brck torcet).‏ مس لاه اوه او ‎(PLO to perPor ol of he vevessary Puce.‏ وه عم ۳ % ‎Ortkrtc openings oa too revister operands.‏ = ‎eorewecicn he PO.‏ = ‎Orxeputens efPevive oddresoes Por by wend sw.‏ = ‎(PO + @) Por brakes.‏ 7 تاه اه ,سوه بط y of Kurdistan

صفحه 7:
0 ‏مس‎ ‎University of Kurdistan

صفحه 8:
لمع ودب ده بمب( > Gieiody, we coo yet by wit coe uciPied wewory, whirk wil ‏وتا مت لس ود‎ cod dota. (a Priecetva urchitevture) Dhis wewory is used fo both the tostruciiva Petck ond dota wees stages, ood ‏موه له له ها‎ Prow eter! > tke PO reyster (hea we're Petcktog oo iestrurtiva), or > tke PLO vuput (Por the ePRevive address oP a hw or sw). Oe odd canter O-- wun, lor, to decide whether the wewory ts beta acvessed Por ‏و‎ or Por dota. Vv ۲۷ 3 09 University of kurdistan

صفحه 9:
>| 9 گر ۱ lq 5 ia ) a Cit tt a 9 (5 1ر1 0 ‏مه‎ ‎University of kurdistan

صفحه 10:
‎reyster>‏ رس تا ‏| ‏0ك ‎> Phe testructon word Petched ‏ات وملمحاصل حصلا ججدامسصاصل 1 موه وا‎ the reypter write ia ote ©. ‏م۳ خ‎ 0 rest Por ‏وا و مرن ی مت‎ © ts ceeded ce the wwewory uxklress Por ku or sw ti ote P. > Dkese culputs wil have ty be stored fo intermediate neqisters Por Puture use. Oberwise they would probably be lost by the cent cock oye. > Phe tetrunion read ki stage Vis saved fa Ietruntioa reypier. > Reqpter Pe vupus Prow ‏مج‎ © or swed ta reypters O ond )3 ke ®LO ouput wil be sired ao recister PLDOu. Quy data Petched Brow wewory i ste P is kept tothe Dewory data ‏ات‎ bv oiled DOR. ‎ww ‎9 University of kurdistan ‎ ‎vv ‎

صفحه 11:
a Ore ene University of kurdistan @

صفحه 12:
مسیر داده چند سیکله مسیر داده چند سیکله سه تفاوت عمده با مسیرداده تک سیکله دارد: ۱- حافظه برنامه و داده ادغام شده است ۲- تعدادی رجیستر برای ذخیره داده های میانی اضافه شده است ۳- واحد () وظیفه مدارات جمع کننده (برای مقصد پرش و محاسبه آدرس بعدی) را نیز انجام میدهد 09 University of kurdistan

صفحه 13:
Qulicycle Datazals wi Ovatrot

صفحه 14:
Qudioycle porto! wait he cuir vit is respoosble Por product ‏اه با اه له‎ - ack ‏وماس ماص‎ requires 0 sequeure oP code sige, yeuercied over cattle > vbock pyle. > Dhis iophes thot we ceed a state crack. > Dke ‏مرول‎ coord sigue wll be puputs oP the stor wachice. > OPPered ‏تمه‎ equine dPPercu sequewes oP steps. > Die kophes the testrunioa word tg oc fopul to the tate ‏نمی‎ > Phe cea state depeus upp the exo ketruction betery exerted. > OR er we Prick exevutay ‏,واه عون‎ we'l have to reped the poling process aqua io execute the ‏.كصاصصاكها مجه‎ 9 University of kurdistan

صفحه 15:
واحد کنترل عبش 0 ]| این .۱ سوه متا میاه TS Orie Rey وه | || 1 ‎one‏ ‏> در معماری تحا() سیگنالهای کنترل را نمیتوان فقط از روی بیت های دستورالعمل بدست آورد. 2 از اینرو از یک ماشین (696) برای طراحی واحد کنترل استفاده میشود. 2 تعدادی ۲ محدود برای پردازنده فرض میشود که در ۲۹ 20۲ ذخیره میشوند. ‎state ۶‏ بسعدواز رویت۱9< فسعلی‌یمقادیر وریدیتسمیین‌میشوند 9 09 University of kurdistan

صفحه 16:
ام ‎whee Pox ace‏ لوف ‎Nook be‏ نج ما اطعا مود تاه تا بط موی 60 ول 0

صفحه 17:
Groge ): ‏یه‎ > Gtoge ( fackides tue uniivas whick use tue separdie Pucantiocd vais! the wewory od the BLO. > etch the testruntion Pow wewory ued store ۱۱ TR. AR = Dew[PO] > Ose the OLO ty twrewedt the PO by ۰ © + وم د وم 0 09 University of kurdistan

صفحه 18:
۱ PC tamrewedt 4 HH pe <« 16 HUE 1 11 2 Oreo 9 University of kurdistan

صفحه 19:
عجه امه ) م66 > Aceinwtiva Pork: WR = Dew[PO] Greed Onke Descriptio DewkRead | | Read Prow wewory oD OD | Ose PO oe the wewory read address: ARO rite a Owe wewory couleuts to lesiruntioa reyster > docrewed he PO: PO = PO + & مه عون | اس امه 09۸ ‎PLOGrAD | 00 | Ose PO ow the‏ ‎PLOGHB | Od | Ose covert P oe he secved BLO persed‏ @LOOp | COD | PerPorw ackdion PCOrte | | Chere PO PCOowr | ۵ | Opckte PO Prow ike PLO ouput 2] 99277 thot ol coairot sirnis aol tated are kopicty set 9 09 University of kurdistan

صفحه 20:
RegWrite = 1 atusres ‏أمسا ون د‎ “Regbst = 5-5 7 eee Instruction fetch = and PC increment Register fetch and| ‘Auusrea = )\ Branch = branch computatiof Op = BEQ /ALUSrcB = 00 ford = 0 ‘ALUOp = 110 op = R-type/ ALUSrcA = 2 ات ‎awusrea = 0 | ALUSrcA = 0‏ { [atusres = 01> atusrea = 11 atvop=010/ atop = 010 Source = crite = ‘crite = Zer "cSource = Memory write Effective address, SSnputation OP = SW|MemWrite = 2 ‘ALUSrcA = 1 ALUSrcB = 10 op = Lwiswh atuop = = 7 how ee MemRead = 1| ‏يوت سس سي‎ = ‏ی‎ RegDst = 0 eo University of kurdistan

صفحه 21:
و ۱ 2 Dh oon be trocehted toto a ote table; here ane the ‏ابید الا‎ ‘Ox (Ome one) Ours | tow | One Orr | (Or) | ‏هك | مه سه‎ 20 | tr | Ore | Ore | ‏مه | سه | جه امه | هد‎ | Or | ‏مم | مه‎ ‏هه | مه إنوةاحهتإا عه اسم | امه‎ © | © | OF | Cor tor (xi Ow 0 ‏هه هأه|» | هو‎ | ۰ Ge Peck ] 006 | ‏مه‎ ‏مه | مه | و | ه | در | | مه | هه و‎ x anewk |G [ere | ‏مه | مه | بل و‎ lolx] x | ‏مه | مه | ه | ه‎ x ‏عسمه | اهنا | مم يمه‎ ‏أههةاه اهاه| »ع |ء««اأاه|اهأه|<*«اه إعد»)| مه‎ x > exer kopkewed ht he hard uny (harhured costa), > Represedt he curred oka win Phy-Plpy or a reste. > Pend exnrtioce Por the cet ote ux (costco ok) pups Is teri ‏یی بان‎ ote ‏لعي‎ ‎rant (kerwetoa ward). ‏رهب مج نوخ‎ uy. ? Orte the whole ovciral stycuks toto a wewory, lke a ROO. ‏خز‎ Dito would be cuck ewster, soar you doo't have to derive equaticcy. 60

صفحه 22:
0" در کنترل به صورت ۳۳۰ سل() اطلاعات کنترلی در حافظه ای موسوم به حافظه کنترلی ذخیره میگردد! 2 000011

صفحه 23:
Dispatch ‏هم ات‎ | MicroPC | SOR 1 Microprogram Dispatch 0 1 ‘aldose memory oF PLA table 2 ble [ona Microinstruction register ae, 1۱/۱/۷۲ 5-58 Control signals to data path ‏ام‎ 09 University of kurdistan ‏ه68‎

صفحه 24:
Microprogram containing 10 microinstructions ao ‏سوق‎ 000 Lobel | ceuret | ‏6صقت | لصت‎ | veuret | Oewery | ‏اساستت_‎ | Gequeusioy [Getcha ‏م‎ le. ‏ال‎ 7 om ۳۹ 0 [eros ‏اداع تس عدت‎ ‏ها ا‎ [ges ‏عع عدت‎ © Loo lead GL [eae [sae ۸ ۹ lene One EO ۹ ‏ساسع عست | السحكها‎ |© |e ‏تا‎ ‎Ore GO. late ‏سح اه‎ lo lo 00/۵ [etch (0 ‏ریا‎ adres [tele Dispatch Table 1 Dispatch Table 2 00000 bet 3 ee 09 University of kurdistan

صفحه 25:
حافظه کنترلی (کنترل به روش ریزبرنامه) 1600 [00000 00 1601 oft 1602 1001010 1603 ]0 0000 oft 1604 0 0 ۱0 0 0۵ 0 0۱60 ۵ 006 010101010 1 0 111011110010 ۱۵۵ ۵0۵0 0/110 0 00 0 0110/0/0 01111111 1 ۵ ۵ ۵۵ 1۱0/0۱۵/1 1 0 010 0 010 00000000 000 0 0000900 10 0 0 100001 0000 0 ۵ 0 00 0/00 0 ۵ 00 010/0 0 00 ۵۱ 1۳ lolo 0.0 0 20 0 00/0/0 1 0 1/1 0 11 1001 1 6 0 1624 0 0 1625 0 0 11 1111 11 1100101 0/1 1 1 11 1 های پیچیده تر حافظه کنترلی ممکن است شامل خانه های تکر eo University of kurdistan

صفحه 26:
حافظه کنترلی دو سطحی (استفاده از نانو حافظه اگر در یک سیستم نیاز باشد که تعداد بسیار زیادی سیگنال کنترلی تولید شود و نیز تعداد سیگنالهای کنترلی مجزا محدود و تعداد کمی باشند. به جای قرار دادن تمامی این سیگنالها در حافظه میکری فقط سیگنالهای مستقل را در یک حافظه تحت عنوان حافظه نانو قرار داده و در حافظه میکرو آدرس این سیگنالها( کلمات) کنترلی را مشخص میکنیم. در این حالت. ما دیگر تعداد زياد و تکراری کلمات کنترلی را در حافظه میکرو نداریم و به جای آن آدرسهای تکراری که حافظه کمت », اشغال سکنند ,| داد سم Control address register a 14 bits ‏مه یتشم‎ 120 + ‏سح‎ Control memory Micro- ‘Nanoprogram memory | 2048x8 ‏سید | له‎ 8 Microinstruction (8 bts) Nanomemory address Nanomemory ‏ا‎ 260 مثال 1 مثال 2 09 University of kurdistan ea

صفحه 27:
حافظه کنترلی دو سطحی (استفاده از نانو مثال: فرض كنيد که در یک سیستم تعداد ۳۰۰ کلمه کنترلی را داریم. از این ۳۰۰ تا تعداد 7۰ کلمه مستقل هستند(۲:۰ تا تکراری هستند). اگر طول کلمات کنترلی ۱۵۰ بیت باشد(تعداد سیگنالهای کنترلی ۱۵۰ باشد) خواهیم داشت: ۱- در حالت معمول و بدون استفاده از حافظه نانو. حجم حافظه میکرو برابر ۱۵۰::۳۰۰ است. ۲- در صورت استفاده از حافظه نانو . حجم این حافظه برابر ۱۵۰۸۰ است. زیرا در این حافظه فقط قرار است که کلمات کنترلی مستقل و غیر تکراری قرار گيرند. در حالت دوم. حافظه میکرو فقط باید آدرس ۳۰۰ تا کلمه کنترلی مورد نیاز را از حافظه نانو مشخص نماید. برای مشخص کردن (آدرس دهی) ۰" کلمه کنترلی. به 7 پیت احتیاج داریم. چون سیستم به ۳۰۰ سیگنال کنترلی نیاز دارد. پس در اين حالت حجم حافظه میکرو برابر است باد ۳ میزان صرفه جویی: ‏ (50*90 + 600*9) < ‎bits OPCOO‏ 3 Nan University of kurdistan

صفحه 28:
eo حافظه کنترلی دو سطحی (استفاده از نانو حافظه) یک پردازنده دارای ۱۷۵ سیگنال کنترلی و ۲۵۰ ریزدستور است. اگر۲۰۰ ریزدستور متفاوت در اين پردازنده وجود داشته باشد, حجم کل حافظه واحد کنترل در صورت استفاده از حافظه نانو چقدر است؟ الف- ۲۸۰۰۰بیت یود هنت ‎t‏ ۰ ابیت 32 ۰ ابیت 09 University of kurdistan

صفحه 29:
Guowapy 02 @ sieeve CPO hes tw word dsadvoctres. Whe oyole thee te heted by the worst cose hitewy. > requires wore horde too cevessury. © srticvole provessor splis icstruntiog execuliza fio severd skies. 2 ‏و وه بو و موه زاس ی‎ required. 7 Bock ‏وه‎ & retively stop, sv the clock opole thee is redued. > Cvontcodl vats cot be reused ‏مضو ال مم‎ oye. * Oe wd severd ‏ول امه سل نا لو‎ De two extra adders wed poe wewory ‏لصو وت‎ > Onttiglexers were toserted sv the (BLO ced wewery ooo be used Por dPP erect ‏و شوه اوه و موس‎ > Dew reypters ore ceeded ty store tterw edie remubs. eo y of Kurdistan

صفحه 30:

Department of Computer and IT Engineering University of Kurdistan MIPS datapath (Multi-Cycle) By: Dr. Alireza Abdollahpouri A Multi-cycle MIPS processor Any instruction set can be implemented in many different ways MIPS ISA Single Cycle Short CPI Long CCT Multi-Cycle Long CPI Short CCT Pipelined Short CPI Short CCT 2 A Multicycle Implementation Cl ock Time needed Time allot t ed Inst r 1 Inst r 2 Inst r 3 Inst r 4 Cl ock Time needed Time allot t ed 3cycl e s 5cycl e s 3cycl e s 4cycl e s Inst r 1 Inst r 2 Inst r 3 Inst r 4 Time saved Single-cycle versus multicycle instruction execution. 3 نگرش Multicycle Datapath ‏ ‏ ‏ ‏ ‏ ‏ 4 هر دستور به تعدادی مرحله کوچکتر تقسیم شده و هر یک از این مراحل در یک کالک اجرا میشوند .بدین ترتیب برای اجرای هر دستور به تعدادی کالک کوچک تر نیاز خواهیم داشت. مراحل طوری انتخاب میشوند که کار انجام گرفته در آنها متعادل باشد. در هر مرحله فقط از یکی از بلوک های سخت افزاری اصلی استفاده میشود. هر دستور تعداد متفاوتی کالک الزم دارد. فقط به یک حافظه نیاز دارد .البته در هر سیکل فقط میتوان یکبار به حافظه دسترسی داشت. فقط به یک ALU/adderنیاز دارد .البته در هر سیکل بیش از یکبار از ALUنمیتوان استفاده نمود. Write Data ALU ALUout Read Addr 1 Register Read Read Addr 2Data 1 File Write Addr Read Data 2 Write Data A Address Read Data (Instr. or Data) B IR Memory MDR PC Multicycle Datapath نگرش در این معماری مقادیری که در سیکلهای بعدی دستور مورد نیاز هستند در : در نتیجه باید اجزای زیر به معماری افزوده شوند.رجیسترهائی ذخیره میشوند MDR – Memory Data Register IR – Instruction Register ALUout – ALU output registerA, B – regfile read data registers 5 Our new adder setup     We can eliminate both extra adders in a multicycle datapath, and instead use just one ALU, with multiplexers to select the proper inputs. A 2-to-1 mux ALUSrcA sets the first ALU input to be the PC or a register. A 4-to-1 mux ALUSrcB selects the second ALU input from among: — the register file (for arithmetic operations), — a constant 4 (to increment the PC), — a sign-extended constant (for effective addresses), and — a sign-extended and shifted constant (for branch targets). This permits a single ALU to perform all of the necessary functions. — Arithmetic operations on two register operands. — Incrementing the PC. — Computing effective addresses for lw and sw. — Adding a sign-extended, shifted offset to (PC + 4) for branches. 6 The multicycle adder setup highlighted PCWrite PC ALUSrcA IorD MemRead RegDst 0 M u x 1 0 RegWrite M u x Address Read register 1 Memory Write data Mem Data MemWrite 0 M u x 1 Read data 1 Read register 2 Write register Write data 1 Zero Result Read data 2 0 4 1 2 Registers ALUOp 3 ALUSrcB 0 M u x ALU Sign extend Shift left 2 1 MemToReg 7 Eliminating a memory  Similarly, we can get by with one unified memory, which will store both program instructions and data. (a Princeton architecture)  This memory is used in both the instruction fetch and data access stages, and the address could come from either:  the PC register (when we’re fetching an instruction), or  the ALU output (for the effective address of a lw or sw).  We add another 2-to-1 mux, IorD, to decide whether the memory is being accessed for instructions or for data. 8 The new memory setup highlighted PCWrite PC ALUSrcA IorD MemRead RegDst 0 M u x 1 0 RegWrite M u x Address Read register 1 Memory Write data Mem Data MemWrite 0 M u x 1 Read data 1 Read register 2 Write register Write data 1 Zero Result Read data 2 0 4 1 2 Registers ALUOp 3 ALUSrcB 0 M u x ALU Sign extend Shift left 2 1 MemToReg 9 Intermediate registers   Sometimes we need the output of a functional unit in a later clock cycle during the execution of one instruction.  The instruction word fetched in stage 1 determines the destination of the register write in stage 5.  The ALU result for an address computation in stage 3 is needed as the memory address for lw or sw in stage 4. These outputs will have to be stored in intermediate registers for future use. Otherwise they would probably be lost by the next clock cycle.  The instruction read in stage 1 is saved in Instruction register.  Register file outputs from stage 2 are saved in registers A and B.  The ALU output will be stored in a register ALUOut.  Any data fetched from memory in stage 4 is kept in the Memory data register, also called MDR. 10 The final multicycle datapath PCWrite PC ALUSrcA IorD 0 RegDst 0 M u x 1 RegWrite MemRead Read register 1 Address Memory Write data Mem Data MemWrite IRWrite 0 [31-26] [25-21] [20-16] [15-11] [15-0] Instruction register Memory data register M u x 1 Read data 1 Read register 2 Write register Write data A Read data 2 B 4 1 Registers 0 ALU Zero Result 0 1 2 ALU Out M u x 1 PCSource ALUOp 3 ALUSrcB 0 M u x M u x Sign extend Shift left 2 1 MemToReg 11 مسیر داده چند سیکله مسیر داده چند سیکله سه تفاوت عمده با مسیرداده تک سیکله دارد: -1حافظه برنامه و داده ادغام شده است -2تعدادی رجیستر برای ذخیره داده های میانی اضافه شده است -3واحد ALUوظیفه مدارات جمع کننده (برای مقصد پرش و محاسبه آدرس بعدی) را نیز انجام میدهد 12 Multicycle Datapath with Control PCW ri t eCon d PCW ri t e IorD PCSource Out pu t s ALUOp AL USrcB MemRe ad MemW ri t e Co nt rol Me mt o Reg IRW ri t e ALUSrcA Re gW ri t e Op [5– 0] RegDst 0 26 Inst ruct io n [25– 0] PC 0 M u x 1 Inst ruct i o n [31-26] Ad d re ss Me mory MemDat a Writ e data Inst ru ct i on [25– 21] Re a d reg i st er 1 Inst ru ct i on [20– 16] Re a d Re a d reg i st er 2 da t a 1 Re gi st e rs W rit e Re a d reg i st er da t a 2 Inst ru ct i on [15– 0] Inst ru ct io n re g ist e r Inst ruct io n [15– 0] Me mo ry data re g ist e r 0 M Inst ru ct io n u x [15– 11] 1 0 M u x 1 B 4 W rit e dat a 16 Sig n ext e nd 32 Shi ft le ft 2 M 1 u x 2 PC [31-28] 0 M u x 1 A Shi ft l eft 2 28 Jump ad dre ss [31-0] Zero ALU ALU resul t ALUOu t 0 1 M u 2x 3 ALU cont ro l Inst ru ct io n [5– 0] 13 Multicycle control unit     The control unit is responsible for producing all of the control signals. Each instruction requires a sequence of control signals, generated over multiple clock cycles.  This implies that we need a state machine.  The datapath control signals will be outputs of the state machine. Different instructions require different sequences of steps.  This implies the instruction word is an input to the state machine.  The next state depends upon the exact instruction being executed. After we finish executing one instruction, we’ll have to repeat the entire process again to execute the next instruction. 14 Datapath ‏Control points ... واحد کنترل Multicycle ‏Combinational ‏control logic ... ‏Next State ‏State Reg ... ‏Inst ‏Opcode در معماری Multicycleسیگنالهای کنترل را نمیتوان فقط از روی بیت های دستورالعمل بدست آورد. از اینرو از یک ماشین FSMبرای طراحی واحد کنترل استفاده میشود. تعدادی stateمحدود برای پردازنده فرض میشود که در state regذخیره میشوند. state بعدی از روی stateفعلی ومقادیر ورودی تعیین میشوند. 15 Finite-state machine for the control unit Op = R-type Instruction fetch and PC increment Register fetch and branch computation Op = BEQ ? ? ? R-type execution ? R-type writeback Branch completion ? Memory write Effective address Op = SW computation Op = LW/SW ? ? Op = LW ? Memory read  Each bubble is a state – Holds the control signals for a single cycle – Note: All instructions do the same things during the first two cycles ? Register write Stage 1: Instruction Fetch  Stage 1 includes two actions which use two separate functional units: the memory and the ALU.  Fetch the instruction from memory and store it in IR. IR = Mem[PC]  Use the ALU to increment the PC by 4. PC = PC + 4 17 Stage 1: Instruction fetch and PC increment PCWrite IR = Mem[PC] PC IorD ALUSrcA RegDst 0 M u x 1 0 RegWrite MemRead Read register 1 Address Memory Write data Mem Data MemWrite IRWrite 0 [31-26] [25-21] [20-16] [15-11] [15-0] Instruction register Memory data register M u x 1 Read data 1 Read register 2 Write register Write data A Read data 2 B 4 0 ALU 1 Zero Result 0 Registers ALU Out M u x 1 PCSource 1 ALUOp 2 3 ALUSrcB 0 M u x M u x Sign extend Shift left 2 PC = PC + 4 1 MemToReg 18 Stage 1 control signals   Instruction fetch: IR = Mem[PC] Signal Value MemRead IorD IRWrite 1 0 1 Read from memory Use PC as the memory read address Save memory contents to instruction register Increment the PC: PC = PC + 4 Signal  Description Value Description ALUSrcA 0 Use PC as the first ALU operand ALUSrcB 01 Use constant 4 as the second ALU operand ALUOp ADD Perform addition PCWrite 1 Change PC PCSourc 0 Update PC from the ALU output e We’ll assume that all control signals not listed are implicitly set to 0. 19 Finite-state machine for the control unit R-type execution Op = R-type ALUSrcA = 1 ALUSrcB = 00 ALUOp = func Instruction fetch and PC increment IorD = 0 MemRead = 1 IRWrite = 1 ALUSrcA = 0 ALUSrcB = 01 ALUOp = 010 PCSource = 0 PCWrite = 1 Register fetch and branch computation Op = BEQ ALUSrcA = 0 ALUSrcB = 11 ALUOp = 010 R-type writeback RegWrite = 1 RegDst = 1 MemToReg = 0 Branch ALUSrcA = 1 completion ALUSrcB = 00 ALUOp = 110 PCWrite = Zero PCSource = 1 Memory write Effective address Op = SW MemWrite = 1 computation IorD = 1 ALUSrcA = 1 ALUSrcB = 10 Op = LW/SW ALUOp = 010 Memory read Op = LW MemRead = 1 IorD = 1 Register write RegWrite = 1 RegDst = 0 MemToReg = 1 20 Implementing the FSM  This can be translated into a state table; here are the first two states. Output (Control signals) Current State Input (Op) Next State PC Write Ior D Mem Read Mem Write IR Write Reg Dst MemT oReg Reg Write ALU Src A ALU Src B ALU Op PC Source Instr Fetch X Reg Fetch 1 0 1 0 1 X X 0 0 01 010 0 Reg Fetch BEQ Branch compl 0 X 0 0 0 X X 0 0 11 010 X Reg Fetch R-type R-type execute 0 X 0 0 0 X X 0 0 11 010 X Reg Fetch LW/ SW Compute eff addr 0 X 0 0 0 X X 0 0 11 010 X   You can implement this the hard way (hardwired control).  Represent the current state using flip-flops or a register.  Find equations for the next state and (control signal) outputs in terms of the current state and input (instruction word). Or you can use the easy way.  Write the whole control signals into a memory, like a ROM.  This would be much easier, since you don’t have to derive equations. 21 Control Unit (micro-program) اطالعاتMicro program در كنترل به صورت كنترلي در حافظه اي موسوم به حافظه كنترلي ذخيره .ميگردد Control Unit CAR CAR: Control Address Register Control memory Control word To DataPath 22 Control Unit (micro-program) CAR 23 Control Unit (micro-program) Microprogram containing 10 microinstructions Lab el Fe t ch Me m1 LW 2 AL U c o n t ro l Ad d Ad d Ad d Re g i s t e r SRC1 SRC2 c o n t ro l PC 4 PC Ext sh ft Re a d A Ext e n d Me m o ry Re a d PC PCW ri t e c o n t ro l ALU Re a d ALU W ri t e MDR SW 2 Rfo rma t 1 W ri t e ALU Fu n c co d e A B W ri t e ALU BEQ1 JUMP1 Su b t A B ALUOu t -co n d Ju mp a d d re ss Dispatch Table 1 Op 000000 000010 000100 100011 101011 Dispatch ROM 1 Opcode name R-format jmp beq lw sw Se q u e n c i n g Se q Di sp a t ch 1 Di sp a t ch 2 Se q Fe t ch Fe t ch Se q Fe t ch Fe t ch Fe t ch Dispatch Table 2 Value Rformat1 JUMP1 BEQ1 Mem1 Mem1 Op 100011 101011 Dispatch ROM 2 Opcode name lw sw Value LW2 SW2 24 حافظه كنترلي (کنترل به روش ریزبرنامه) های پیچیده تر حافظه کنترلی ممکن است شامل خانه های تکرا 25 حافظه كنترلي دو سطحی (استفاده از نانو حافظه) اگر در یک سیستم نیاز باشد که تعداد بسیار زیادی سیگنال کنترلی تولید شود و نیز تعداد سیگنالهای کنترلی مجزا محدود و تعداد کمی باشند ،به جای قرار دادن تمامی این سیگنالها در حافظه میکرو ،فقط سیگنالهای مستقل را در یک حافظه تحت عنوان حافظه نانو قرار داده و در حافظه میکرو آدرس این سیگنالها(کلمات) کنترلی را مشخص میکنیم .در این حالت ،ما دیگر تعداد زیاد و تکراری کلمات کنترلی را در حافظه میکرو نداریم و به جای آن آدرسهای تکراری که حافظه کمتری اشغال میکنند را داریم. . 26 مثال 1 مثال 2 حافظه كنترلي دو سطحی (استفاده از نانو حافظه) مثال :فرض کنید که در یک سیستم تعداد 300کلمه کنترلی را داریم .از این 300تا تعداد 60 کلمه مستقل هستند( 240تا تکراری هستند) .اگر طول کلمات کنترلی 150بیت باشد(تعداد سیگنالهای کنترلی 150باشد) خواهیم داشت: -1در حالت معمول و بدون استفاده از حافظه نانو ،حجم حافظه میکرو برابر 150*300است. -2در صورت استفاده از حافظه نانو ،حجم این حافظه برابر 150*60است .زیرا در این حافظه فقط قرار است که کلمات کنترلی مستقل و غیر تکراری قرار گیرند. در حالت دوم ،حافظه میکرو فقط باید آدرس 300تا کلمه کنترلی مورد نیاز را از حافظه نانو مشخص نماید .برای مشخص کردن (آدرس دهی) 60کلمه کنترلی ،به 6بیت احتیاج داریم. چون سیستم به 300سیگنال کنترلی نیاز دارد ،پس در این حالت حجم حافظه میکرو برابر است .6*300 با: )bits 34200 = (300*6 + 150*60میزان صرفه جویی: (300*150) 27 حافظه كنترلي دو سطحی (استفاده از نانو حافظه) یک پردازنده دارای ۱۷۵سیگنال کنترلی و ۲۵۰ریزدستور است. اگر ۲۰۰ریزدستور متفاوت در این پردازنده وجود داشته باشد‌ ،حجم کل حافظه واحد کنترل در صورت استفاده از حافظه نانو چقدر است؟ الف- ب- ج- د- 28 ۲۸۰۰۰بیت ۳۲۰۰۰بیت ۲۴۰۰۰بیت ۳۷۰۰۰بیت Summary  A single-cycle CPU has two main disadvantages.  The cycle time is limited by the worst case latency.  It requires more hardware than necessary.  A multicycle processor splits instruction execution into several stages.  Instructions only execute as many stages as required.  Each stage is relatively simple, so the clock cycle time is reduced.  Functional units can be reused on different cycles.  We made several modifications to the single-cycle datapath.  The two extra adders and one memory were removed.  Multiplexers were inserted so the ALU and memory can be used for different purposes in different execution stages.  New registers are needed to store intermediate results. 29 Questions 30

51,000 تومان