module substractor4 #(parameter BITWIDTH = 4) (A, B, Ci, S, Co); // Input and Output Declarations input [BITWIDTH-1:0] A; // A is an input of size BITWIDTH input [BITWIDTH-1:0] B; // B is an input of size BITWIDTH input Ci; // Carry-in (used for borrow) output [BITWIDTH-1:0] S; // S is an output of size BITWIDTH output Co; // Carry-out (borrow-out) // Internal Wire Declaration wire [BITWIDTH:0] Diff; // Difference wire (one extra bit for borrow) // Assign Statements for Subtraction assign Diff = A - B - Ci; // Calculate the difference assign S = Diff[BITWIDTH-1:0]; // Assign the lower BITWIDTH bits to S assign Co = Diff[BITWIDTH]; // Assign the borrow-out endmodule