module nand_1();
logic a,b;
logic y;
initial
begin
a=0;
b=0;
y= a&~b;
$display(“y=%b”,y);
end
endmodule
after run
y=0 ?
this is like
module nand_1();
logic a,b;
logic y,y1;
initial
begin
a=0;
b=0;
y= a&~b;
y1=a&b;
//y= ~(a&~b);
$display(“y=%b,y1=%b”,y,y1);
end
endmodule
after run
y=0,y1=0
both are same but using different operators &, &~
as per NAND logic , if both inputs are 0, the output will be 1
please help me
In reply to suresh M:
You have the characters reversed. ~& is a nand.
In reply to dave_59:
module nand_1();
logic a,b;
logic y;
initial
begin
a=0;
b=0;
y= ~&b;//y=b ~& b;
$display(“y=%b”,y);
end
endmodule
result:
y=1
This is like y=b ~& b;
for y= a~& b;
after run
Invalid use of unary operator ‘~&’
“testbench.sv”, 10: token is ‘;’
y= a~&b;
^
In reply to suresh M:
Dear suresh,
~ is a bitwise operator, it requires one operand.
~& b is the same as ~b no matter the value of b (N.B: if b is one bit wide)
The tool translates your expression y = b ~& b; as y = b (~&b); which has no sense.
In reply to suresh M:
If you are trying to write the RTL equivalent for
nand ( y, a, b);
that would be
y = !(a && b);
// or
y = !a || !b;
In reply to dave_59:
then what is the use &~ and &~
if I use
a=0;b=0;
y=a&~b;
result is y=0
but when
a=1;
b=0;
y = a&~b;
result is y=1
otherway if I use
y=a~&b;
after run
Invalid use of unary operator ‘~&’
“testbench.sv”, 10: token is ‘;’
y= a~&b;
In reply to vico:
I understood that ~& is unary operator like either ~b or ~&b , both are giving complement of b.
but my doubt is when we use &~ operator
example
a=0;
b=0;
y=a&~b;
what is y and how?
In reply to vico:
I understood that ~& is unary operator like either ~b or ~&b , both are giving complement of b.
but my doubt is when we use &~ operator
example
a=0;
b=0;
y=a&~b;
what is y and how?
In reply to suresh M:
There is no single &~ operator. As Vico mentioned above
y = a&~b;
is interpreted as two distinct operators
y = a & ~b ;
If you wrote
int v = 5*-3;
v would be -15. There is no *- operator.