Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
430 B
2
Indexable
Never
module ddc(a,b,select,out,overflow);

input[3:0] a,b;
input select;
output[3:0] out;
output overflow;
reg[3:0] out;
reg overflow;


always @(a or b or select)begin
	if(select==1)begin
		out = a+b;
		if(a+b>15)begin
			overflow = 1;
		end
		else begin
			overflow = 0;
		end
	end
	else begin
		out = a-b;
		if(b>a)begin
			overflow = 1;
		end
		else begin
			overflow = 0;
		end
	end
end

endmodule