DIGITAL DESIGN · FPGA
Parameterized FSM-controlled calculator in Verilog with Booth multiplication and iterative division.
Constraint
Add, subtract, multiply, and divide 11-bit signed numbers on an FPGA using one shared datapath and a controller, with correct sign and overflow handling.
Decision
A finite-state machine drives a shared 11-bit adder/subtractor; multiplication uses a sequential Booth algorithm and division iterates on operand magnitudes.
Evidence
Verified arithmetic, state transitions, and corner cases (overflow, divide-by-zero) in ModelSim, then ran on DE2-115 switches, keys, HEX displays, and LEDs.
Numbers are entered in signed-magnitude on board switches and results are shown in two's complement on 7-segment displays. Width is a parameter (W = 11 by default), so the datapath must scale.
module FourFuncCalc
#(parameter W = 11) // Default bit width
(
input Clock,
input Clear, // C button
input Equals, // = button
input Add, Subtract,
input Multiply, Divide,
input [W-1:0] Number, // signed-magnitude on SW[W-1:0]
output signed [W-1:0] Result, // two's complement
output Overflow
);
localparam WW = 2 * W; // Booth product width
localparam BoothIter = $clog2(W); // Booth counter width