《基于MIPS的流水线处理器设计.docx》由会员分享,可在线阅读,更多相关《基于MIPS的流水线处理器设计.docx(6页珍藏版)》请在第一文库网上搜索。
1、/readtwoportscombinationa11y/writethirdportonrisingedgeofc1ock/register0hardwiredto0a1ways(posedgee1k)beginif(!rst_n)begin/initiatetheinitia1va1uetozeroatresetrf0=32,b0;rf1=32,b0;rf2=32,b0;rf3=32,b0;rf4=32,b0;rf5=32,b0;rf6=32,b0;rf7=32,b0;rf8=32,b0;rf9=32,b0;rf10=32,b0;rf11=32,b0;rf12=32,b0;rf13=32,
2、b0;rf14二32,b0;rf15=32,b0;rf16=32,b;rf17=32,b0;rf18=32,b0;rf19=32,b0;rf20=32,b0;rf21=32,b0;rf22=32,b0;rf23=32,b0;rf24=32,b0;rf25=32,b0;rf26=32,b0;rf27=32,b0;rf28二32,b0;rf29=32,b;rf30=32,b0;rf31end=32,b0;e1seif(we3)rfwa3=wd3;endassignrd1=(ra1!=O)?rfra1:0;assignrd2=(ra2!=O)?rfra2:0;endmodu1e4 .算数逻辑单元ah
3、imodu1ea1u(/inputa,b,a1ucontro1,/outputa1uresu1t,zero);input2:0a1ucontro1;input31:0a;input31:0b;outputzero;output31:0a1uresu1t;reg31:0a1uresu1t;regzero;a1ways(aorbora1ucontro1)begincase(a1ucontro1)3,b000:a1uresu1t=a&b;3,b001:a1uresu1t=ab;3,b010:a1uresu1t=a+b;3,bO:a1uresu1t=a+b;3,b100:3,b101:a1uresu1
4、t=a-b;a1uresu1t=0;3,b110:a1uresu1t=a-b;3,b111:a1uresu1t=(ab)?1:0defau1t:a1uresu1t=325bx;endcaseif(a1uresu1t=O)zero=1;e1sezero=0;endendmodu1e5 .数据存储器dmemmodu1edmem(e1k,/rst_n,/inputA4,WD,WE,/outputRD4);inputc1k;/rst_n;input4:0A4;input31:0WD;inputWE;output31:0RD4;/(*ram_init_fi1e=dmem.mif*)reg31:0ram31:0;initia1beginSreadmemh(zzF:/Tests/the1ast/mcu_pipe1inedmem.dat,ram)endassignRD4=ramA4;a1ways(posedgee1k)begin/if(!rst_n)/begin/ramO=32,hOOOOOO;/ram1=32,h00000022;/ram2=32,h00000033;/ram3=32,h00000444;/ram4=32,h;/end/e1seif(WE)ramA4=WD;endendmodu1e