Báo Cáo Single Cycle Mips

download Báo Cáo Single Cycle Mips

of 37

Transcript of Báo Cáo Single Cycle Mips

  • 7/24/2019 Bo Co Single Cycle Mips

    1/37

    I HC QUC GIA TP.H CH MINHTRNG I HC CNG NGH THNG TIN

    --------------------------------

    BO CO N KTMT

    ti: Thit k Alu V Control theo kin trcMip !" #it

    $V %&'n( )*n : T+, N(u.n Minh +/n

    +V th0c hi1n : V2 3c Ti

    M++V : 456"5!7!

    Thnh ph8 %9 Ch Minh ; N

  • 7/24/2019 Bo Co Single Cycle Mips

    2/37

    MCLC

    M>c l>c,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"

    4 ?@u cu thit k,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,!" Tn( uDn E =ip,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,!

    ",4 $i'i thi1u,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,!

    "," Kin trc tFp l1nh MGH,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,!

    ",! CIc Jnh )Ln( l1nh c/ #n tron( MGH,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,!R

    1 YUCUTHIT

    Thit k =at #a +i(le Ccle MGH !"#it th0c hi1n cIc ch3c n

  • 7/24/2019 Bo Co Single Cycle Mips

    4/37

    Kin trc tFp l1nh MGH YG+AZ J&sc phIt trin tm kin trc tFp l1nh MGHG Jn kin trcMGHV, Vo cu8i nhn( n

  • 7/24/2019 Bo Co Single Cycle Mips

    5/37

    CIc l1nh )>n( cIc tr&vn( Du:

    T0234 %5 678 9 34:;?=@ R#it dIc Jnh =` l1nh0B 6#it dIc Jnh thDnh (hi n(u9n08 6#it dIc Jnh thDnh (hi tL= Yn(u9n}JchZ hoyc

    ){n( J chx rD cIc h= tron( phL= EiUg$GMM cSD opco)e

    0@ 6#it dIc Jnh thDnh (hi JchI@7 4:7

    CIc l1nh nLp] (hi YWoD)] tore GntructionZ l cIc l1nh )i chun ) li1u (iD #a nh' EcIc thDnh (hi, Chn( J l cIc l1nh c Jnh )Ln( kiu i==e)iDte YG-tpeZ] )o J ph&/n( th3cJInh JD chx )u nhwt J&sc h trs l lw thDnh (hi c/ can( 4R#it i==e)iDte,

    BDo (9= cIc l1nh: W] +]

    .1.! CJ? K3: B5 :? O K=47?

    Th0c hi1n cIc phbp tnh 8 hPc] lo(ic] )ch chun tr@n cIc (iI tr cSD cIc thDnh (hi,

    CIc l1nh n #Do (9= l1nh c Jnh )Ln( Ue(iter YU-tpeZ E Jnh )Ln( kiu G==e)iDteYG-tpeZ,

    CIc l1nh U-tpe: A))] +u#] +WT] An)] Or] dor] Nor],,, CIc l1nh G-tpe: A))G] +u#G] An)G] OrG] dorG]

  • 7/24/2019 Bo Co Single Cycle Mips

    6/37

    .1. CJ? K3: 3: O 0S 3:J3:

    CIc l1nh nh E rQ nhInh Yfu=p Dn) BrDnch GntructionZ l cIc l1nh thD Ji )|n( ki=oIt cSD =at ch&/n( trnh, W1nh nh lu^n J&sc l= Jn =at trDn(] )Ln( JD chx tu1t J8i #i=at #i@n )ch JD chx "R-#it] E'i cIc #it cDo cSD con tr_ ch&/n( trnh Ykiu f-tpeZ hoyc JD chx

    thDnh (hi Y)Ln( U-tpeZ, CIc l1nh rQ nhInh c #{ 4R-#it li@n uDn Jn con tr_ ch&/n( trnhY)Ln( G-tpeZ,

    BDo (9= cIc l1nh: f] fU] BNg]

    !," C)CTHNHPHNCAMIP%

    .!.1 P0=40

  • 7/24/2019 Bo Co Single Cycle Mips

    7/37

    lap gia tri ra $ang gia tri %ao

    endmodule

    module &'_regs(&'_out, &'_in, rst, clk);

    output *+!&'_out;

    input *+!&'_in;input rst,clk;

    D_FF $it!(&'_out!, &'_in!, rst, clk, *-$*);

    D_FF $it*(&'_out*, &'_in*, rst, clk, *-$*);

    D_FF $it.(&'_out., &'_in., rst, clk, *-$*);

    /

    D_FF $it*(&'_out*, &'_in*, rst, clk,*-$*);

    endmodule

    .!.! I3B80?87=3 M=0

    Ba nh' l1nh l n/i l&u (i cIc l1nh cSD ch&/n( trnh] =i l1nh c =at JD chx ri@n(, Banh' l1nh c ch3c n

  • 7/24/2019 Bo Co Single Cycle Mips

    8/37

    always @(Addr_in)$egin temp*+.4 0nst_1em (Addr_in); temp.+*5 0nst_1em (Addr_in6*); temp*7+8 0nst_1em (Addr_in6.); temp2+!

    0nst_1em (Addr_in6);endendmodule

  • 7/24/2019 Bo Co Single Cycle Mips

    9/37

    .!. R47B80 V7K

    MGH+ h trs !" thDnh (hi JInh 8 tm 5 - !4] =i thDnh (hi c kch th&'c l !" #it, Tron(J] \ thDnh (hi th&vn( J&sc )>n( J th0c hi1n cIc phbp tnh J&sc JInh 8 4R - "!,

    %5 TW3 9 34:;c Y(lo#Dl pointerZX!a p Con tr_ +tDck X p Con tr_ rD=eX1 rD D chx tr E

    N( Eo UeD) re(iter4] UeD) re(iter ": Ic Jnh JD chx cSD thDnh (hi = =u8n JPc )li1u,

    N( rD UeD) )DtD4] UeD) )DtD": ch3D nai )un( cSD thDnh (hi = UeD) re(iter4]UeD)re(iter" chx Jn,

    Khi tn hi1u Ue(rite 4 uI trnh (hi ) li1u Eo Ue(iter ile Q J&sc th0c hi1n] n(

    Eo rite re(iter ){n( J Ic Jnh JD chx = chn( tD =u8n (hi ) li1u Eo] rite )DtD ch3D(iI tr ='i J (hi Eo Ue(iter ile, [ li1u ='i Q J&sc (hi Eo khi c tn hi1u clock,

    module 9egister_File(9ead_Data*, 9ead_Data., :rite_Data,:rite_Addr, 9eg_:rite, clk, 9ead_Addr*, 9ead_Addr.);

    input 4+! 9ead_Addr*; 9ead_Addr.;input 4+! :rite_Addr;input *+! :rite_Data;input 9eg_:rite;

  • 7/24/2019 Bo Co Single Cycle Mips

    10/37

    input clk;output *+! 9ead_Data*, 9ead_Data.;

    "" 9egister File+ . 9egister, moi 9egister . $itreg *+! 9egs_File *+!;

    integer i;initial$eginfor(i !; i .; i i6*)$egin 9egs_Filei !;end

    end

    "" :ritealways @(posedge clk) $eginif (9eg_:rite) $egin

    9egs_File:rite_Addr :rite_Data;end

    end

    ""9eadassign 9ead_Data* 9egs_File9ead_Addr*;assign 9ead_Data. 9egs_File9ead_Addr.;

    endmodule

    .!.\ ALU bA08:87?Z L=47? U378c

    Ba 8 hPc E lo(ic l n/i th0c hi1n cIc phbp toIn 8 hPc E lo(ic tron( kin trc MGH, 8iE'i cIc l1nh thuac nh= l1nh toIn hPc E lo(ic] kh8i AWX J&sc )>n( J th0c hi1n cIc phbptnh, CIc l1nh nLp] (hi )>n( kh8i J tnh toIn JD chx #a nh', W1nh BNg )>n( kh8i n Jo Inh, W1nh f]fU kh^n( )>n( kh8i n,

    ALU C=380=K V3?87=3 Md 81E A[[ A B11E +XB A ; B11 AN[ A B111 OU A B111 dOU A B

    1111 NOU YA BZ11EE +WT +i(n +i(ne)YAZ i(ne)YBZ11EE1 +WT Xni(n A B

    Cwu tLo MGH AWX (9=:

    %Di n( Eo !"#it: BuA] BuB Mat n( rD !"#it: Output

  • 7/24/2019 Bo Co Single Cycle Mips

    11/37

    CIc cv n( rD: ero] oEerloq] cDrrout] ne(DtiEe Cv ero: J&sc et khi kt u #zn( 5 Cv oEerloq: J&sc et khi rD trn khi th0c hi1n cIc phbp can( trm cIc 8 c )wu Cv cDrrout: J&sc et khi c nh' tm M+B Cv ne(DtiEe: J&sc et khi kt u =

    .!.\.1 T:7e8 fe 6g ?g34h 80i !678

    .!.\.1.1 T:7e8 fe 6g ?g34 !678j

    T:7e8 fe 6g ?g34 1678j

    I3>8 /8>8A B Cin +u= Cout 5 5 5 5 5 4 4 5

    4 5 4 5 4 4 5 41 5 5 4 51 5 4 5 41 4 5 5 41 4 4 4 4

    Bn( chn tr

    +Du khi t8i thiu hD] tD J&sc ph&/n( trnh trLn( thIi:

    +u= A or B or Cin Cout AB CinYABZ

    module Add_*$it(or ?or_! (temp*,A,=);`And and_! (temp.,A,=);

    `And and_* (temp,temp*,'in);`>or

  • 7/24/2019 Bo Co Single Cycle Mips

    12/37

    Ba can( !" #it J&sc thit k #zn( cIch )>n( !" #a 4#it:

    module Add(n( =at #a can( !"#it J th0c hi1n c phbp can( E phbp trm, Vi1ccn ch j chx l l0D chPn (iI tr input tLi #u B E Cin Do cho ph{ hsp E'i tmn( phbp toIn, TD )>n( =at n( Eo +elect J l0D chPn phbp tnh, V'i +elect 5 th0c hi1n phbp toIn can( En(&sc lLi,

    B +elect Belect5 5 55 4 44 5 44 4 5

    W0D chPn Belect

    +elect Cin5 54 4W0D chPn Cin

    Bn( chn tr tr@n cho tD thw r h/n Ei1c l0D chPn (iI tr cSD B E Cin J th0c hi1n phbptoIn YE'i Belect l (iI tr B J&sc l0D chPnZ, Tm J c th Ic Jnh J&sc ph&/n( trnh trLn(thIi cSD Belect ED Cin nh& Du:

    Belect B or +elect

  • 7/24/2019 Bo Co Single Cycle Mips

    13/37

    Cin +elect

    module Add E 4 #a dor !"#it )>n( !" #a dor 4#it, TD th0c hi1n t&/n( t0 E'i cIc #a An)] Or] Nor,

    module >or_.$it(>or_.,A, =);

    output *+! >or_4;

    input *+! A, =;

    `>or >or!(>or_.!, A!, =!);

    `>or >or*(>or_.*, A*, =*);

    `>or >or.(>or_.., A., =.);

    /

    `>or >or*(>or_.*, A*, =*);

    ndmodule

    + )>n( n( Eo +elect "#it J l0D chPn kt u cSD #a lo(ic t&/n( 3n( E'i cIc phbp lo(ic+elect Hhbp lo(ic

    55 An)54 Or 45 dor 44 Nor

    module Bogic(Bogic_result, A,=,

  • 7/24/2019 Bo Co Single Cycle Mips

    14/37

    r. Bogic_r (r_9esult,A,=);

    Cor. Bogic_Cor(Cor_9esult,A,=);

    >or. Bogic_>or(>or_9esult,A,=);

    always@()

    $egin

    case (or_9esult;

    .-$**+ Bogic_result Cor_9esult;

    endcase

    endendmodule

    .!.\. :57 ALU

    module ABE(ABE_result,ero, %erflow, 'out,Cegati%e,A,=,Funct);

    output reg *+!ABE_result;

    output ero, %erflow, 'out, Cegati%e;

    input *+!A,=;

    input 7+! Funct;

    wire *+! Add_

  • 7/24/2019 Bo Co Single Cycle Mips

    15/37

    ABE_result Bogic_result;

    end else if (Funct7+ -$*!*) $egin

    ABE_result ?=@

    V3?87=3 ALU V3?87=3

    Lk 455544 455555%k 454544 455555-Nl 555454 455545

    m/RI 554445 455445AN+I 554455 455455/RI 554454 455454

    A++I 554555 455555AN+ 555555 455455 455455/R 555555 455454 455454

    N/R 555555 455444 455444m/R 555555 455445 455445A++ 555555 455555 455555%U- 555555 455545 455545%LT 555555 4545 4545

    Bn( tn hi1u Jiu khin AWX

    module ABE_'trl(ABE_Funct,pcode, funct_in);

    output reg 7+!ABE_Funct;

    input 7+!pcode;

    input 7+!funct_in;"" 'onstants

  • 7/24/2019 Bo Co Single Cycle Mips

    16/37

    localparam ABE_DCG_'A9 5-$!!!!!!;

    localparam 9_GK& 5-d!;

    localparam ADD0 5-$!!*!!!;

    localparam ADD_FEC' 5-$*!!!!!;

    localparam

  • 7/24/2019 Bo Co Single Cycle Mips

    17/37

    $egin

    ABE_Funct FACD0;

    end

    90+

    $egin

    ABE_Funct F90;end

    >90+

    $egin

    ABE_Funct F>90;

    end

    endcaseend

    end

    endmodule

    .!._ +

  • 7/24/2019 Bo Co Single Cycle Mips

    18/37

    $uf 3*!! $uf!(9ead_Data!, temp!),

    $uf*(9ead_Data*, temp*),

    $uf.(9ead_Data., temp.),

    /

    $uf*(9ead_Data*, temp*);

    always @(posedge clk)

    if(:rite_n)

    $egin

    Data_1emAddr :rite_Data*+!;

    end

    always @(Addr or Data_1emAddr)

    if(9ead_n)

    $egin temp Data_1emAddr;

    end

    endmodule

    .!.` C=380=K U378

    Control Xnit nhFn tn hi1u Ju Eo l R#it opco)e tron( =` l1nh, [0D Eo (iI tr cSD R#itopco)e n] Control Xnit Q tLo rD cIc tn hi1u Jiu khin J Jiu khin cIc kh8i khIc tron(MGH,

    CIc tn hi1u Jiu khin:

    Ue([t: chPn thDnh (hi Jch cho Ue(iter ile Ue([t 5 J8i E'i l1nh loLi G] rt l thDnh (hi Jch Ue([t 5 J8i E'i l1nh loLi U] r) l thDnh (hi Jch

    fu=p: Cho phbp th0c hi1n l1nh nh fu=p BrDnch: Cho phbp th0c hi1n l1nh rQ nhInh BNg Me=UeD): Cho phbp JPc ) li1u tm #a nh' Me=rite: Cho phbp (hi ) li1u Eo #a nh' AWX+rc: ChPn n( Eo th3 " cho #a AWX AWX+rc 5: n( Eo l (iI tr cSD thDnh (hi rt AWX+rc 4: n( Eo l (iI tr G==e)iDte J` J&sc = ran( thnh !"#it

    Ue(rite: Cho phbp (hi ) li1u Eo thDnh (hi Jch Me=toUe(: ChPn (iI tr J (hi Eo Ue(iter ile, Me=toUe( 5: (hi ) li1u tm kt u AWX Eo Ue(iter ile Me=toUe( 4: (hi ) li1u tm #a nh' Eo Ue(iter ile

    +i(nero: Ic Jnh ph&/n( th3c = ran( #it +i(nero 5: M ran( )wu

  • 7/24/2019 Bo Co Single Cycle Mips

    19/37

    +i(nero 4: M ran( kh^n( AWXopco)e: dIc Jnh phbp toIn cn th0c hi1n

    W1nh

    Opco)e OutputUe([t

    fu=p BrDnch Me=UeD)

    Me=rite

    AWX+rc

    Ue(rite

    Me=toUe(

    +i(nero

    AWXopco)e

    Utpe

    555555 4 5 5 5 5 5 4 5 555555

    Wq 455544 5 5 5 4 5 4 4 4 5 455544+q 454544 d 5 5 5 4 4 5 d 5 454544

    BNg 555454 d 5 4 5 5 5 5 5 555454f 555545 4 5 5 5 5 dorG 554445 5 5 5 5 5 4 4 5 4 554445A))G

    554555 5 5 5 5 5 4 4 5 4 554555

    An)G

    554455 5 5 5 5 5 4 4 5 4 554455

    OrG 554454 5 5 5 5 5 4 4 5 4 554454

    .!.] CJ? 8:3: >:n3 f:J?

    .!.].1 oR C=380=KKt hsp (iI tr cSD tn hi1u Jiu khin AWX opco)e tm Control Xnit E R #it unction (ii

    =` tm l1nh J tLo rD tn hi1u fUctrl Jiu khin th0c hi1n l1nh fu=p Ue(iter,D chx l1nh fu=p Ue(iter chnh l ) li1u l&u tron( thDnh (hi U,

    module L9_control(L9_ctr, Funct, ABE_pcode);

    output reg L9_ctr;

    input 7+!Funct;input 7+!ABE_pcode;

    wire **+!temp;

    assign temp MABE_pcode,FunctN;

    always@(temp)

    $egin

    case(temp)

    *.-$!!!!!!!!*!!!+ L9_ctr *-$*;

  • 7/24/2019 Bo Co Single Cycle Mips

    20/37

    default+ L9_ctr *-$!;

    endcase

    end

    endmodule

  • 7/24/2019 Bo Co Single Cycle Mips

    21/37

    .!.].! lE83@0[{n( J = ran( 4R#it G==e)iDte

    [ li1u Eo 4R #it Q J&sc = ran( thnh !" #it, T{ thuac Eo tn hi1u Jiu khin+i(nero tm Control Xnit = ) li1u Eo Q J&sc = ran( E'i cIc (iI tr 5 hoyc E'i #it th3 4R

    cSD ) li1u Eo,

    .!.]. %:7F8 KF8 ![{n( J nhn )ch ) li1u Dn( trIi " #it,

    .!.].\ MUmBa chPn k@nh ){n( J l0D chPn =at n( Eo tron( nhiu n( Eo,

  • 7/24/2019 Bo Co Single Cycle Mips

    22/37

    !,! +ATAPATHCAMIP% CPUTn( uIt Ei1c th0c thi l1nh #Do (9= cIc #&'c Du:

    Ww l1nh

    $ii =` l1nh Th0c hi1n l1nh

    CIc l1nh khIc nhDu c chun( cIc #&'c lw l1nh E (ii =` l1nh, Chn( tD )>n( thDnh(hi HC Ych3D JD chx cSD cu l1nh hi1n thvi Z J lw l1nh tm Gntruction =e=or E Du J tn(] =>c Jch cSD cu l1nhl th0c hi1n nhi1= E> (,

    CIc #&'c tip theo cSD uI trnh th0c thi l1nh ph> thuac Eo cIc cwu trc cSD tmn( l1nh,Chn( tD Q e= bt cIc khu^n )Ln( l1nh J thit k cIc )DtDpDth cho tmn( l1nh Do cho ph{hsp,

    ..1 +

  • 7/24/2019 Bo Co Single Cycle Mips

    23/37

    A[[G] AN[G] OUG] dOUG :W1nh n thuac )Ln( G- tpe :

    W1nh n th0c hi1n phbp toIn dOU (iD =at (iI tr J&sc ch3D tron( thDnh (hiY thDnh (hin c JD chx ch3D tron( tr&vn( r Z E'i =at (iI tr hzn(, $iI tr hzn( n ch3D tron( cu l1nh l4R#it nh&n( n Q J&sc = ran( thnh (iI tr !" #it, Kt u cSD phbp toIn Q J&sc l&u EothDnh (hi tron( Ue(iter ile] thDnh (hi n c JD chx nz= tron( tr&vn( rt,

  • 7/24/2019 Bo Co Single Cycle Mips

    24/37

    ..! +n( J tnh tn((iD oet J` J&sc = ran( E'i (iI tr ch3 tron( thDnh (hi = #De re(iter chx Jn, Ktu cSD phbp tnh n J&sc e= l JD chx cSD E tr nh' tron( [DtD =e=or, $iI tr tron(thDnh (hi c JD chi nz= tron( tr&vn( r Q J&sc (hi Eo E tr nh' n,

  • 7/24/2019 Bo Co Single Cycle Mips

    25/37

    .. +

  • 7/24/2019 Bo Co Single Cycle Mips

    26/37

    fU:W1nh n c khu^n l1nhnh& Du :

    op YR#itZ

    r Y6 #itZ

    5 Y46#itZ

    \

    HC Ue(r

  • 7/24/2019 Bo Co Single Cycle Mips

    27/37

    ..\ +

  • 7/24/2019 Bo Co Single Cycle Mips

    28/37

    !ire -ot3ero;

    //Khoi 4nstruction Memory

    !ire "#$%&'4nstruction;

    !ire "5%&' 6pcode, 7unct;

    !ire "%&' 1s, 1t, 1d;

    !ire "$5%&'4mm$8;assign 6pcode 9 4nstruction"#$%:8';

    assign 1s 9 4nstruction":5%:$';

    assign 1t 9 4nstruction":&%$8';

    assign 1d 9 4nstruction"$5%$$';

    assign 7unct 9 4nstruction"5%&';

    assign 4mm$8 9 4nstruction"$5%&';//Khoi Control nit

    !ire 1egst, 2t

    !ire "#$%&' 0umpShi>tin, 0umpShi>tout, B-.Shi>tin,

    B-.Shi>tout;

    /***************Mips****

    ***********/

    /*rogram Counter*/

    Cregs rogramCounter(@Cout(Cout),

    @Cin(Cin),

    @rst(reset),

    @clk(clk)

    );

    //ia chi lenh tiep theo

    2dd 2ddC(@Sum(C),

  • 7/24/2019 Bo Co Single Cycle Mips

    29/37

    @6er>lo!(),

    @Cout(),

    @2(A:D&,#D$&&E),

    @B(Cout),

    @Cin($D&)

    ); //C 9 C F

    /*4nstruction Memory*/

    4nstructionMemory 4nstMem(@4nstout(4nstruction),

    @2ddrin(Cout)

    );

    /*Control nit*/

    Controlnit Ctrl(@1egst(1egst),

    @2

  • 7/24/2019 Bo Co Single Cycle Mips

    30/37

    );

    /*2

  • 7/24/2019 Bo Co Single Cycle Mips

    31/37

    @Cout(),

    @2(C),

    @B(B-.Shi>tout),

    @Cin($D&)

    );

    G-ot notB-.(-ot3ero, 3ero);G2nd andB-.(B-.ctr, Branch, -ot3ero);

    Mu?:to$#:Dit Mu?B-.(@Mu?out(CB-.),

    @Mu?in&(C),

    @Mu?in$(B-.2ddr),

    @Select(B-.ctr) );

    /*0ump Control*/

    assign 0umpShi>tin 9 A8D&,4nstruction":5%&'E;

    Shi>tt: 0umpShi>t(@Shi>tout(0umpShi>tout), @Shi>tin(0umpShi>tin)

    );

    assign 0ump2ddr 9 AC"#$%:H',0umpShi>tout":I%&'E;

    Mu?:to$#:Dit Mu?0ump(@Mu?out(C0ump),

    @Mu?in&(CB-.),

    @Mu?in$(0ump2ddr),

    @Select(0ump)

    );

    /*0ump 1egister Control*/

    assign 0r2ddr 9 1eg1eadata$;

    01control 01ctrunit(@01ctr(01ctr), @7unct(7unct),

    @2

  • 7/24/2019 Bo Co Single Cycle Mips

    32/37

    \ MPHqNG

    ,4 THWN%MH%N$TD =^ ph_n( Ei1c th0c thi cIc l1nh Du J ki= trD hoLt Jan( cSD kin trc MGH J` thit

    k:24 J&, J$, &?7&7

    614 J&, J:, &?7&7&

    2 J$, J:, J#

    SB J:, J$, JB-. J&, J$, &?5

    S= &?&,J5, &?&

    S= &?&,J8, &?

    S= &?&,JI, &?5

    S= &?&,JH, &?$:

    01 J$52- J#, J, J5

    61 J#, J, J8

    61 J#, J, JI

    -61 J#, J, JH

    24 J&, J$5,&?&

    0 &?5

  • 7/24/2019 Bo Co Single Cycle Mips

    33/37

    _! 55555555 54455455 54555555 55455444_` 55455555 55554444 55555555 54555555` 55554555 55555555 55555555 55555454`\ 45554455 55554554 55555555 55555555`^ 45554455 55554545 55555555 55555455

    ]! 45554455 55554544 55555555 55554555]` 45554455 55554455 55555555 55554455

    ,! Tg+TBgNC%module t$_cpu;

    reg clk;

    reg rst;

  • 7/24/2019 Bo Co Single Cycle Mips

    34/37

    DEeor= th0c thi cIc l1nh tLi JD chx 5] ] \] 4"] 4R

    DEeor= th0c thi cIc l1nh tLi JD chx 5] ] \] 6"

  • 7/24/2019 Bo Co Single Cycle Mips

    35/37

    DEeor= th0c thi cIc l1nh tLi JD chx 6R] R5] "5] "

    DEeor= th0c thi cIc l1nh tLi JD chx "\] !"] !R] R

  • 7/24/2019 Bo Co Single Cycle Mips

    36/37

    DEeor= th0c thi cIc l1nh tLi JD chx R\] "]R

  • 7/24/2019 Bo Co Single Cycle Mips

    37/37

    _ TILIUTHAMH/

    6,4 %AU[AUg}+OTAUgGNTgUACg] T%GU[g[GTGONYT%gMOU$AN

    KAXMANN+gUGg+GNCOMHXTgUAUC%GTgCTXUgAN[[g+G$NZ - [AVG[A,HATTgU+ON] fO%NW, %gNNg++?

    6," %TTH+:}}gN,GKGHg[GA,OU$}GKG}MGH+GN+TUXCTGON+gT

    6,! MGH+GNTUXCTGON+gT; C%AUWg+HUGCg

    6, $GOTUN%VgUGWO$; T%+, WMCK%G

    https://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_sethttps://en.wikipedia.org/wiki/MIPS_instruction_set