|
- module hc82( //74HC82/74LS82 二位带进位输入与输出的全加器 加法器 VCC:Pin4 GND:Pin7 未使用Pin:6,8,9,11
- input C0, //进位输入 Pin5
- input A1, //被加数低位 Pin2
- input A2, //被加数高位 Pin14
- input B1, //加数低位 Pin3
- input B2, //加数高位 Pin13
- output S1, //和低位 Pin1
- output S2, //和高位 Pin12
- output C2 //进位输出 Pin10
- );
- assign {C2,S2,S1} = {A2,A1} + {B2,B1} + C0;
- endmodule
- module main(
- input clk, //时钟输入
- output reg led //低电平(计算正确) 点亮
- );
- wire [1:0] A = 2'd3;
- wire [1:0] B = 2'd3;
- wire [2:0] S;
- hc82 U1(
- .C0(1'b1),
- .A1(A[0]),
- .A2(A[1]),
- .B1(B[0]),
- .B2(B[1]),
- .S1(S[0]),
- .S2(S[1]),
- .C2(S[2])
- );
- always @(posedge clk) begin
- led <= !(S == 7);
- end
- endmodule
复制代码 |
|