31 lines
533 B
Coq
31 lines
533 B
Coq
|
module adder(SUM, COUT, A, B, CIN);
|
||
|
input A, B, CIN;
|
||
|
output SUM, COUT;
|
||
|
|
||
|
wire x;
|
||
|
|
||
|
|
||
|
xor x0(x, A, B);
|
||
|
xor x1(SUM, x, CIN);
|
||
|
|
||
|
assign COUT=x? CIN: B;
|
||
|
|
||
|
endmodule
|
||
|
|
||
|
module part3(SW, LEDR);
|
||
|
input [8:0] SW;
|
||
|
output [4:0] LEDR;
|
||
|
|
||
|
|
||
|
wire C0,C1,C2,C3;
|
||
|
wire [3:0] S;
|
||
|
|
||
|
adder A0(S[0], C0, SW[0], SW[4], SW[8]);
|
||
|
adder A1(S[1], C1, SW[1], SW[5], C0);
|
||
|
adder A2(S[2], C2, SW[2], SW[6], C1);
|
||
|
adder A3(S[3], C3, SW[3], SW[7], C2);
|
||
|
|
||
|
assign LEDR = {C3, S};
|
||
|
|
||
|
endmodule
|