首页 > 代码库 > 4??,16?? ???? ?? ??(????)
4??,16?? ???? ?? ??(????)
Q: ???? ??? ??
1. half-adder
module half_adder (S, C, x, y);
output S, C;
input x, y;
xor (S, x, y);
and (C, x, y);
endmodule
2. full-adder
module full_adder (S, C, x, y, z);
output S, C;
input x, y, z;
wire S1, D1, D2;
half_adder HA1 (S1, D1, x, y);
half_adder HA2 (S, D2, S1, z);
or G1 (C, D2, D1);
endmodule
3. 4bit ripple carry adder
module ripple_carry_4_bit_adder (output [3:0] S, output C4, input [3:0] A, B, input C0);
wire C1, C2, C3;
full_adder FA0 (S[0], C1, A[0], B[0], C0),
FA1 (S[1], C2, A[1], B[1], C1),
FA2 (S[2], C3, A[2], B[2], C2),
FA3 (S[3], C4, A[3], B[3], C3);
endmodule
4. 16bit ripple carry adder
module fulla16 (sum, c_out, a, b, c_in);
output [15:0] sum;
output c_out;
input [15:0] a;
input [15:0] b;
input c_in;
wire c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14;
full_adder fa0(sum[0], c0,a[0], b[0], c_in);
full_adder fa1(sum[1], c1,a[1], b[1], c0);
full_adder fa2(sum[2], c2,a[2], b[2], c1);
full_adder fa3(sum[3],c3,a[3], b[3], c2);
full_adder fa4(sum[4],c4,a[4], b[4], c3);
full_adder fa5(sum[5],c5,a[5], b[5], c4);
full_adder fa6(sum[6],c6,a[6], b[6], c5);
full_adder fa7(sum[7],c7,a[7], b[7], c6);
full_adder fa8(sum[8],c8,a[8], b[8], c7);
full_adder fa9(sum[9],c9,a[9], b[9], c8);
full_adder fa10(sum[10],c10,a[10], b[10],c9);
full_adder fa11(sum[11],c11,a[11], b[11], c10);
full_adder fa12(sum[12],c12,a[12], b[12], c11);
full_adder fa13(sum[13],c12,a[13], b[13], c12);
full_adder fa14(sum[14],c12,a[14], b[14], c13);
full_adder fa15(sum[15],c12,a[15], b[15], c14);
endmodule
16bit adder simulation results
4bit adder simulation results
Answers:
?? ?? ??? ???.
???? ??? ?? ?? ?? test bench? ??? ??.
??? ??? 4bit ripple carry adder ??? ?? ????? ????
????? ??? ???.
???? ?? ??? ??? ????? ? ? ??? ?? ????.
4??,16?? ???? ?? ??(????)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。