Professional Documents
Culture Documents
Example
As an example, an 8-bit carry select adder could comprise three 4-bit ripple carry adders: one would calculate the sum and carry for the low
nibble sum (bits 0 to 3), and the other two would calculate the high nibble sum and carry (bits 4 to 7). All adders would calculate in parallel.
We could then use the low nibble carry output as a selector for a multiplexer that would choose the correct results from the high nibble sums
and carries.
Verilog
The following Verilog code shows an 8-bit carry select adder. The code for ripple carry adder, the full adder, and the multiplexer is also shown
for completeness.
module carry_select_adder(S, C, A, B);
output [7:0] S;
// The 8-bit sum.
output
C;
// The 1-bit carry.
input [7:0] A;
// The 8-bit augend.
input [7:0] B;
// The 8-bit addend.
wire [3:0]
wire [3:0]
wire
wire
wire
S0;
S1;
C0;
C1;
Clow;
//
//
//
//
//
pdfcrowd.com
C0; // The carry out bit of fa0, the carry in bit of fa1.
C1; // The carry out bit of fa1, the carry in bit of fa2.
C2; // The carry out bit of fa2, the carry in bit of fa3.
w1;
w2;
w3;
w4;
xor(w1, A, B);
xor(S, Cin, w1);
and(w2, A, B);
and(w3, A, Cin);
and(w4, B, Cin);
or(Cout, w2, w3, w4);
endmodule // full_adder
module multiplexer_2_1(X, A0, A1, S);
parameter WIDTH=16;
// How many bits wide are the lines
output [WIDTH-1:0] X;
input [WIDTH-1:0]
input [WIDTH-1:0]
input
pdfcrowd.com
input
S;
// Selection bit
When given test inputs, the 8-bit carry select adder generated the following waveform:
References
Harrison, John. Handbook of Practical Logic and Automated Reasoning. Cambridge, 2009.
Index
Copyright 2014 Barry Watson. All rights reserved.
pdfcrowd.com