Full Adder and 4-Bit Adder Module
Full Adder and 4-Bit Adder Module
Booth's Multiplier utilizes state transitions and arithmetic operations embedded within a Finite State Machine (FSM) to perform multiplication. Starting from the IDLE state upon receiving the `start` signal, it initializes the multiplicand (`X`) and sets up initial conditions. The module processes the multiplication by entering the START state, where the core operations depend on a `temp` variable representing bits of the multiplicand and multiplier. Based on the value of `temp`, arithmetic operations such as addition or subtraction of the multiplier (`Y`) onto the upper bits of the working product register (`Z`) are executed. The `Z` register undergoes arithmetic right shifts in every iteration. The FSM transitions back to IDLE when all bits are processed, ensuring `Z` contains the final product while maintaining flow control using the `valid` signal to indicate completion of multiplication .
The `temp` variable in Booth's Multiplier is pivotal in guiding the iterative steps of multiplication, serving as a decision-maker for arithmetic operations within each cycle. It is derived by concatenating bits from the multiplicand (`X`) and controls whether to perform addition, subtraction, or no operation on the multiplied value residing in the upper bits of `Z`. Specific patterns in `temp` determine whether `Y` (multiplier) should be added to or subtracted from `Z` to accommodate the two's complement representation shifts. It enables efficient processing by dynamically adjusting operations per bit conditions, thus optimizing multiplication steps based on Booth's algorithm .
The asynchronous reset in digital designs like Booth's Multiplier is critically important as it ensures that all internal registers and states are initialized to known default values regardless of the clock state. This feature is vital for system reliability and predictable behavior upon power-up or when returning to a default state after a fault. It effectively sets the product register (`Z`) to zero, resets the `valid` signal, state registers, and counters, making the design robust against unwanted initialization states and ensuring a clean start from a specific, controlled condition .
The 4-bit Parallel Adder uses a sequence of Full Adders to handle each bit of the 4-bit inputs `a` and `b`, including the carry-in `cin`. Internal wires carry intermediate carry-out values between Full Adders to ensure cumulative addition. The first Full Adder computes the least significant bit (`fa0`) and its carry-out is passed as the carry-in for the next bit, and this process continues for the entire bit-width. The structure ensures each bit addition considers the carry from the previous bit, and these Full Adders are connected in a cascading configuration, leading to accurate result in terms of both sum and carry-out .
The combinational logic block in Booth's Multiplier defines the next state and output values by evaluating the current state (`pres_state`) and the `temp` variable, representing multiplicand's bit-pairs. During the `START` state, depending on `temp` values, it decides whether to add, subtract, or maintain `Y` in the computation based on Booth's criteria. This logic then updates the working product (`next_Z`) and shifts it right for the next stage. It concurrently checks completion of the operations through `count` and routes to either continue in `START` or return to `IDLE`. It ensures computation progresses correctly step-by-step, enabling correct state transitions and output validity without clock dependence, using logical conditions derived from state-machine operational rules .
The testbench plays a crucial role in verifying the functionality of the 4-bit Parallel Adder by simulating different scenarios and observing the adder's behavior. It defines inputs for two test cases, simulating different values of 4-bit numbers `a` and `b`, with different `cin` values. The first test case uses `a=4'b0111`, `b=4'b0100`, and `cin=1'b0`, observing outputs after a delay. The second test case uses `a=4'b1011`, `b=4'b0110`, and `cin=1'b1`. The `$monitor` command logs the input-output relationship in real-time during simulation, providing insights into adder's operations, ensuring the design is functionally correct under varied input conditions .
In the Parallel Adder Module, input registers (`a` and `b`) define storage locations for the 4-bit binary numbers being added and serve as static inputs for the operation. These registers store values that do not change during the adder operation and are crucial in providing initial data. Conversely, internal wires serve as temporary conduits for carrying intermediate results, specifically the carry bits between successive Full Adders. They dynamically transfer information, enabling continuous bitwise operations. While input registers capture and hold input signals, internal wires ensure sequential logic handling, reflecting their contrasting functions: storage vs. real-time communication .
The arithmetic right shift mechanism is crucial in Booth's Algorithm, especially after every arithmetic operation like addition or subtraction. It ensures correct sign extension for the intermediate product in `Z`, essential when working with signed numbers. This operation maintains the most significant bit's value across shifts, preserving the numerical sign integrity essential for signed representations. Such right shifts, applied consistently, effectively divide the intermediate result by two while preserving its sign indication, facilitating correct future additions or subtractions during next state operations, ultimately ensuring that the final result is correctly scaled according to Booth’s method .
The testbench manages timing between operations in verifying digital module designs by using time delays after each operation to simulate the passage of time within a digital clock cycle. In the case of a parallel adder testbench, after setting inputs, it waits a specified duration (`#10`) allowing the circuit's propagation delays to stabilize before checking the outputs. This delay ensures that the changes in inputs have enough time to propagate through the combinational logic of the adder and that the output responses accurately represent the circuit's functionality under the specified timing constraints .
The Full Adder Module computes the sum and carry for single-bit addition using XOR operations for the sum and a combination of AND and OR operations for the carry. The sum is calculated as the XOR of inputs `a`, `b`, and `cin` (carry-in), expressed as `sum = a ^ b ^ cin`. The carry-out is derived from the logical expression `carry = (a & b) | (b & cin) | (cin & a)` which ensures that a carry-out only occurs if at least two of the three inputs are true .