Jump to content
  • 0

Printing strings in Waveforms


scorbetta

Question

Hello all,

I'm writing my own protocol scripts (Decoder + Value to Text) and I would like to plot a string on the waveform. How can I do that?
My Value2Text function looks as follows:

function Value2Text(flag, value){
    switch(flag) {
    	case 0:
			return "X"; // Don't care, unknown or invalid
    	case 2:
			return "b" + value.toString(2); // Binary value
    	case 10:
			return value; // Decimal value
    	case 16:
			return "0x" + value.toString(16).toUpperCase(); // Hex value
	    default:
			return ??; // String
  }
}

I'm missing how to manage the default case, where I would like to pass a string. An example in the decoder:

rgValue[sample] = "Read";
rgFlag[sample] = 5;

Thanks

S

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @scorbetta

The rgValue and rgFlag expects 32bit unsigned values.
You should store the 'read' as an ID, for instance flag value 1 to represent 'read', 2 to represent 'write'...

function Value2Text(flag, value){
  switch(flag){
    case 0: return "nop";
    case 1: return "RD b"+value.toString(2);
    case 2: return "WR h"+value.toString(16);
    default: return "DAT "+value;
  }
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...