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: byte

SystemVerilog Data Types

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

Open in IDE
testbench.sv
module tb;
   byte           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**7 - 1; 	// assign 127
    #30 m_var_s  = 2**7;        // assign 128
    #40 m_var_s  = 2**8 - 1;    // assign 255
  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.