Home / Learn Verilog / Strings in Verilog

Strings in Verilog

Strings are byte vectors, used for messages.

In shortStrings are byte vectors, used for messages.

What's actually going on

"Hi" = 0x48 0x69H1i0
"Hi" = 0x48 0x69

What it is

A string literal in quotes is stored as ASCII bytes in a reg wide enough.

Why it matters

Used for labels in testbenches and $display.

Mechanically speaking

Use %s to print.

Shows up in

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Strings as regsVerilog: edit and run

Each character uses 8 bits.

Check yourself

1. Each ASCII char uses...