I have a few outputs map to different commands (CMD_A CMD_B…) using always@(*) and would like to display the state names (instead of the number) as the testbench runs.
That’s a slightly better explanation. You have a state variable and you want to map certain integer values back to a string name to print. There is a couple of different things you could do.
Instead of using parameters, you can use an enumerated type:
typedef enum {CMD_A, CMD_B, ...} command_t;
command_t state;
...
state = CMD_A;
$display("state is %s", state.name); // prints: state is CMD_A
By default, CMD_A has the value 0, CMD_B has the value 1. You can assign other encodings.
You can also define an associative array whose sole purpose is mapping values to strings.
string MAP[int] = '{default:"UNKNOWN", 0:"CMD_A", 1:"CMD_B"};
int state;
...
state = CMD_A;
$display("state is %s", MAP[state]); // prints: state is CMD_A