Ripple Carry Adder Module in VHDL and Verilog
5 stars based on
38 reviews
Modular arithmetic and 2's complement representation Most computers choose a particular word length measured in bits for representing integers and provide hardware that performs various arithmetic operations on word-size operands.
The current generation of processors have word lengths of 32 bits; restricting the size of the operands and the result 2 bit ripple carry adder verilog code for hex a single word means that the arithmetic operations are actually performing arithmetic modulo 2 Almost all computers use a 2's complement representation for integers since the 2's complement addition operation is the same for both positive and negative numbers.
In 2's complement notation, one negates a number by forming the 1's 2 bit ripple carry adder verilog code for hex i. By convention, we write 2's complement integers with the most-significant bit MSB on the left and the least-significant bit LSB on the right. Also by convention, if the MSB is 1, the number is negative; otherwise it's non-negative. How many different values can be encoded in a bit word? Each bit can be either "0" or "1", so there are 2 32 possible values which can be encoded in a bit word.
Please use a bit 2's complement representation to answer the following questions. What are the representations for zero the most positive 2 bit ripple carry adder verilog code for hex that can be represented the most negative integer that can be represented What are the decimal values for the most positive and most negative integers?
Since writing a string of 32 bits gets tedious, it's often convenient to use hexadecimal notation where a single digit in the range or A-F is used to represent groups of 4 bits using the following encoding: Calculate the following using 6-bit 2's complement arithmetic which is just a fancy way of saying to do ordinary addition in base 2 keeping only 6 bits of your answer. Show your work using binary base 2 notation. Remember that subtraction can be performed by negating the second operand and then adding it to the first operand.
The addition caused the most significant bit to become 1, resulting in an "overflow" where the sign of the result differs from the signs of the operands. 2 bit ripple carry adder verilog code for hex first blush "Complement and add 1" doesn't seem to an obvious way to negate a two's complement number. Recall that in a N-bit sign-magnitude representation, the most significant bit is the sign 0 for positive, 1 for negative and the remaining N-1 bits are the magnitude.
What range of numbers can be represented with an N-bit sign-magnitude number? With an N-bit two's-complement number? For sign-magnitude the range is - 2 N-1 -1 to 2 N-1 For two's complement the range is -2 N-1 to 2 N-1 Create a Verilog module that converts an N-bit sign-magnitude input into an N-bit two's complement output. Carry-select adder In thinking about the propagation delay of a ripple-carry adder, we see that the higher-order bits are "waiting" for their carry-ins to propagate up from the lower-order bits.
Suppose we split off the high-order bits and create two separate adders: Then when the correct carry-in was available from the low-order bits, it could be used to select which high-order sum to use. The diagram below shows this strategy applied to an 8-bit adder: Compare 2 bit ripple carry adder verilog code for hex latency of the 8-bit carry-select adder show above to a regular 8-bit ripple-carry adder.
For the low-order 4 bits, the latency is the same for both implementations: But with the carry-select adder, the remaining latency is the propagation delay of the 4-bit 2: If we consider an N-bit adder, the latencies are: The logic shown for C 8 seems a bit odd. Explain why both implementations are equivalent and suggest why the logic shown above might be prefered. Using this fact we can do a little Boolean algebra: Pipelining is particular form of retiming where the goal is to increase the throughput number of results per second of a circuit.
Consider the circuit diagram below; the solid rectangles represent registers, the square are blocks of combinational logic: Each combinational block in the diagram is annotated with it's propagation delay in ns.
For this problem assume that the registers are "ideal", i. What are the latency and throughput of the circuit above? Latency is how long it takes for a value in 2 bit ripple carry adder verilog code for hex input register to be processed and the result appear at the output register. Throughput is the number of results per second.
Pipeline the circuit above for maximum throughput. Pipelining adds additional registers to a circuit; we'll do this by adding additional registers at the output and then use the retiming transformation to move them between the combinational blocks. What are the latency and throughput of your resulting circuit?
To maximize the throughput, we need to get the "30" block into it's own pipeline stage. So we'll draw the retiming contours like so: Note there is an alternative way we could have drawn the contours to reach the goal of isolating the "30" block; it might be that other implementation considerations would help pick which alternative was more attracive. Similarly, we could have instead added registers at the input and used retiming to move them into the circuit. The contours above lead to the following piplelined circuit diagram: A good check to see if the retiming is correct is to verify that there are the same number of registers on every path from the input s to the output s.
The latency has increased to 3 clock cycles, or 90ns. In general increasing the throughput through pipelining always leads to an increase in latency. Fortunately latency is not an issue for many digital processing circuits -- eg, microprocessors -- where we care more about how many results we get per second much more than how long it takes to process an individual result.