Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

bit, byte and int: shortint

SystemVerilog Data Types

Runnable example from the SystemVerilog bit, byte and int tutorial (shortint)

Open in IDE
testbench.sv
module tb;
   shortint            m_var_s;      // By default signed, and can represent positive and negative numbers
  
  initial begin
  
    #10 m_var_s  = 0;             // assign 0
    #20 m_var_s  = 2**15 - 1;     // assign 32767
    #30 m_var_s  = 2**15;         // assign 32768 (wraps to -32768, signed 16-bit)
    #40 m_var_s  = 2**16 - 1;     // assign 65535 (wraps to -1, signed 16-bit)
  end
  
  initial
    $monitor("[%0t] m_var_s = 'd%0d  (0x%0h)", $time, m_var_s, m_var_s);
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.