module fullAdder(a, b, carryIn, carryOut, sum);
output carryOut, sum;
input a, b, carryIn;
wire w1, w2, w3, w4;
and G1(w1, a, carryIn);
and G2(w2, b, carryIn);
and G3(w3, a, b);
or G4(carryOut, w1, w2, w3);
xor G5(w4, a, b);
xor G6(sum, w4, carryIn);
endmodule
`timescale 1ns / 1ps
module oneBitALU(result, carryOut, a, b, carryIn, opCode);
output reg result;
output reg carryOut;
input a, b, carryIn;
input [3:0] opCode;
wire w1, w2, w3, w4, sum;
fullAdder add(a, b, carryIn, carryOut, result);
fullAdder sub(a, ~b, 1, carryOut, result);
always@ (opCode, a, b)
begin
case(opCode)
4'b0000: assign result = a&b;
4'b0001: assign result = a|b;
//4'b0010:
//4'b0110:
4'b1100: assign result = ~a&~b;
endcase
end
endmodule
I'm trying to assign the sum value of the fullAdder
module to the result value of the oneBitALU
module. I'm pretty new to Verilog, so any help would be appreciated. Lines 19 and 20 of the oneBitALU
module are where I would assign the value.