您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 人事档案/员工关系 > carry-skip-adder
//¶þ½øÖÆÌøÔ¾½øλ¼Ó·¨Æ÷modulecarry_skip_adder(x_in,y_in,c_in,sum,c_out);parameterDSIZE=12;parameterS=4;inputc_in;input[DSIZE-1:0]x_in,y_in;output[DSIZE-1:0]sum;reg[DSIZE-1:0]sum;outputc_out;regc_out;integeri,j;reg[DSIZE:0]q;always@(x_inory_inorc_in)beginq[0]=c_in;begincarry_skip_add_cell(x_in[S-1:0],y_in[S-1:0],q[0],q[S:1]);for(j=0;j=S-1;j=j+1)sum[j]=x_in[j]^y_in[j]^q[j];carry_skip_add_cell(x_in[2*S-1:S],y_in[2*S-1:S],q[S],q[2*S:S+1]);for(j=0;j=S-1;j=j+1)sum[S+j]=x_in[S+j]^y_in[S+j]^q[S+j];carry_skip_add_cell(x_in[3*S-1:2*S],y_in[3*S-1:2*S],q[2*S],q[3*S:2*S+1]);for(j=0;j=S-1;j=j+1)sum[2*S+j]=x_in[2*S+j]^y_in[2*S+j]^q[2*S+j];endc_out=q[DSIZE];end//S±ÈÌØ·Ö×é½øλÁ´taskcarry_skip_add_cell;input[S-1:0]x,y;inputcin;output[S:1]cout;regq[S:0],p[S-1:0],g[S-1:0],accumulator,generalized_p;integeri;beginq[0]=cin;for(i=0;i=S-1;i=i+1)beginp[i]=x[i]^y[i];g[i]=y[i];q[i+1]=(p[i])?q[i]:g[i];endaccumulator=p[0];for(i=1;i=S-1;i=i+1)accumulator=accumulator&p[i];generalized_p=accumulator;cout[S]=(generalized_p)?c_in:q[S];for(i=1;i=S-1;i=i+1)cout[i]=q[i];endendtaskendmodule
本文标题:carry-skip-adder
链接地址:https://www.777doc.com/doc-7141483 .html