32位加法器
时间:10-02
整理:3721RD
点击:
各位高手,我在编写verilog代码时,编译通过了,但是仿真的时候说测试文件加载错误,我实在找不到原因了,请各位赐教,不胜感激:'(
module adder_32bits1_1(input[31:0] a,input[31:0] b,input ci,output[31:0] s,output co);
wire[6:0] c;
adder_4bits f1(a[3:0],b[3:0],ci,s[3:0],c[0]);
adder_4bits f2(a[7:4],b[7:4],c[0],s[7:4],c[1]);
adder_4bits f3(a[11:8],b[11:8],c[1],s[11:8],c[2]);
adder_4bits f4(a[15:12],b[15:12],c[2],s[15:12],c[3]);
adder_4bits f5(a[19:16],b[19:16],c[3],s[19:16],c[4]);
adder_4bits f6(a[23:20],b[23:20],c[4],s[23:20],c[5]);
adder_4bits f7(a[27:24],b[27:24],c[5],s[27:24],c[6]);
adder_4bits f8(a[31:28],b[31:28],c[6],s[31:28],co);
endmodule
module adder_4bits(input[3:0] a,input[3:0] b,input ci,output[3:0] s,output co);
wire[3:0] g;
wire[3:0] p;
wire[3:1] CI;
wire[3:0] n;
wire[3:0] sa,c;
and a1(g[0],a[0],b[0]);
or o1(p[0],a[0],b[0]);
not n1(n[0],g[0]);
and sa1(sa[0],p[0],n[0]);
xor x1(s[0],sa[0],ci);
and c1(c[0],p[0],ci);
or cr1(CI[1],c[0],g[0]);
and a2(g[1],a[1],b[1]);
or o2(p[1],a[1],b[1]);
not n2(n[1],g[1]);
and sa2(sa[1],p[1],n[1]);
xor x2(s[1],sa[1],CI[1]);
and c2(c[1],p[1],CI[1]);
or cr2(CI[2],c[1],g[1]);
and a3(g[2],a[2],b[2]);
or o3(p[2],a[2],b[2]);
not n3(n[2],g[2]);
and sa3(sa[2],p[2],n[2]);
xor x3(s[2],sa[2],CI[2]);
and c3(c[2],p[2],CI[2]);
or cr3(CI[3],c[2],g[2]);
and a4(g[3],a[3],b[3]);
or o4(p[3],a[3],b[3]);
not n4(n[3],g[3]);
and sa4(sa[3],p[3],n[3]);
xor x4(s[3],sa[3],CI[3]);
and c4(c[3],p[3],CI[3]);
or cr4(co,c[3],g[3]);
endmodule
帮你顶顶,水平有限,还处在看懂代码的阶段
栏目分类
射频专业培训教程推荐