S
Samuel Winchenbach
Guest
Hello,
I am a student at the University of Maine and I am working on creating
an ALU for a Cadence design project. I am having a bit of trouble
with verilog validation. When added two 4-bit binary numbers that
result in a carry I am getting the incorrect solution. For example:
A = 4'b0000;
B = 4'b0000;
Cin_BAR = 1'b0;
GUESS = (A | ~B) + !Cin_BAR;
GUESS _should_ be equal to 4'b1111 + 1'b1 = 10000.
The code below produces: 00000
Does anyone have any tips on correcting this problem? I believe that
the problem is due to signed/unsigned numbers. Thanks in advance.
// CODE
integer Ax;
reg[4:0] GUESS;
initial
begin
A[3:0] = 4'b0000;
B[3:0] = 4'b0000;
Cin_BAR = 1'b0;
for(Ax=0; Ax <= 15; Ax = Ax + 1)
begin
A = Ax;
#150
GUESS = (A|~B) + !Cn_BAR; // (Ax | 4'b1111) + 1
$display("%b",GUESS); // This displays 00000, should be 10000
end
end
I am a student at the University of Maine and I am working on creating
an ALU for a Cadence design project. I am having a bit of trouble
with verilog validation. When added two 4-bit binary numbers that
result in a carry I am getting the incorrect solution. For example:
A = 4'b0000;
B = 4'b0000;
Cin_BAR = 1'b0;
GUESS = (A | ~B) + !Cin_BAR;
GUESS _should_ be equal to 4'b1111 + 1'b1 = 10000.
The code below produces: 00000
Does anyone have any tips on correcting this problem? I believe that
the problem is due to signed/unsigned numbers. Thanks in advance.
// CODE
integer Ax;
reg[4:0] GUESS;
initial
begin
A[3:0] = 4'b0000;
B[3:0] = 4'b0000;
Cin_BAR = 1'b0;
for(Ax=0; Ax <= 15; Ax = Ax + 1)
begin
A = Ax;
#150
GUESS = (A|~B) + !Cn_BAR; // (Ax | 4'b1111) + 1
$display("%b",GUESS); // This displays 00000, should be 10000
end
end