all about vlsi DV
Inbuilt functions in verilog
​
Verilog built-in functions, along with an example for each:
-
$clog2:
-
Description: Returns the minimum number of bits required to represent the logarithm base 2 of the input value.
-
Example: parameter WIDTH = $clog2(8); // WIDTH will be 3
-
-
$signed:
-
Description: Converts an expression to a signed value.
-
Example: reg [7:0] unsigned_value = 8'b10101010; reg signed [7:0] signed_value = $signed(unsigned_value);
-
-
$unsigned:
-
Description: Converts an expression to an unsigned value.
-
Example: reg signed [7:0] signed_value = -8; reg [7:0] unsigned_value = $unsigned(signed_value);
-
-
$random:
-
Description: Returns a random 32-bit value.
-
Example: reg [31:0] random_value = $random;
-
-
$display:
-
Description: Displays the specified string or values during simulation.
-
Example: $display("Value = %d", value);
-
-
$monitor:
-
Description: Monitors the specified variables and displays their values whenever they change.
-
Example: $monitor("Value changed: %d", value);
-
-
$time:
-
Description: Returns the current simulation time in simulation cycles.
-
Example: $display("Current time: %0t", $time);
-
-
$stime:
-
Description: Returns the simulation time as a string.
-
Example: $display("Simulation started at: %s", $stime);
-
-
$finish:
-
Description: Stops the simulation and ends the simulation run.
-
Example: if (condition) $finish;
-
-
$cast:
-
Description: Converts an expression to the specified data type.
-
Example: reg [7:0] data = $cast(reg [3:0], 5);`
-