Verilog $signed(), what is this

verilog

I am just getting started with verilog. I was looking at some example code for a floating multiply someone wrote and I came across this…

if ($signed(b_e == -1023) && (b_m == 0)) begin
            z[63] <= 1;
            z[62:52] <= 2047;
            z[51] <= 1;
            z[50:0] <= 0;
            state <= put_z;
          end

I am just wondering what the $signed is. I tried googling it but I just got a bunch of results about signed math (not about this function). I thought functions that begin with a $ were only for test-bench code. What does this function do? Also is there a place where I can get a list of the verilog functions?

Best Answer

There are a number of Verilog system functions can be used for synthesis as well as testbenches. Most of the synthesizable function perform some kind of arithmetic or logical conversion. SystemVerilog has replaced most of the $functions with casts or built-in methods.

In this example, the use of $signed makes no sense to me as the result of a comparison is always a 1-but unsigned value, and this result will be and'ed with another 1-bit expression. So the $signed is not doing anything. Casting a value to signed only makes sense if the value need to be extended to a larger width, or in a relational operation.

You can find the list of functions in the Language Reference Manual (LRM).

Related Topic