Pregunta

How to write a code for bitwise operation in verilog for input in decimal format... I am just a starter on Verilog

01:begin
    A.Receive(a);
    B.Receive(b);
    z=a&b;
    Z.Send(z);
end

The above code is in SystemVerilog but it is still the same. a and b are decimal inputs. Is this the right way of writing like this..

¿Fue útil?

Solución

A bitwise operator works in bit by bit fashion, therefore it's binary by definition. You can however always use the decimal (hexadecimal,octal) number format to enter values in verilog. For instance:

wire [ 4: 0] a = 5'd11;
wire [ 4: 0] b = 5'b11010;
wire [ 4: 0] c = a & b;
// will result in c being 10 decimal, or 01010 binary as:
// (01011(base:2) & 11010(base:2) = 01010(base:2) = 10(base:10)

In truth there is no operator in Verilog that would distinguish between number systems, in the end everything is binary.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top