I'm trying to build ALU.
I built a 4-bit Full Adder and a 4-bit Full Subtractor using Half Adder and Half Subtractor respectively.
module fullAdder4bit(output [3:0] sum, output c_out, input [3:0] a, b, input c_in);
wire [2:0] c;
fullAdder FA1(sum[0], c[0], a[0], b[0], c_in);
----
----
----
----
endmodule
And, similarly, I wrote for Full Subtractor.
Using these, I was trying to build a Division, but I'm not getting exactly how to write Division using the above Full Adder. If anyone knows how to write for Division, let me know.
When the user gives A+B or A-B, it should show the respective output. So I was calling the respective module whenever it is required, like this
module logic(
output [3:0] AdderSum,
output AdderC_out,
input [3:0] AdderO1, AdderO2,
input AdderC_in, AdderClk
);
always@(posedge AdderClk)
begin
fullAdder4bit FAbit (AdderSum[3:0] , AdderC_out , AdderO1[3:0] , AdderO2[3:0] , AdderC_in);
end
endmodule
// 4-bit Full ADDER Syntax
// module fullAdder4bit(output [3:0] sum, output c_out, input [3:0] a, b, input c_in);
But it gave ERROR :
Instantiation is not allowed in sequential area except checker instantiation