Forum Discussion
Altera_Forum
Honored Contributor
9 years agoString operation
I have a string
signal rx_uart_buf : string (0 to 127);
Now I want to test every char value
when ST_PARSE_COM =>
if (idx < RX_BUF_SIZE) then
case character'pos(rx_uart_buf(idx)) i...
Altera_Forum
Honored Contributor
9 years ago --- Quote Start --- In what context? Strings are not suitable for synthesis, so I assume this is simulation only code? Also, strings can only have a positive range, so cannot start at 0 - it must start at 1 or above? Why bother coverting the char to an integer? why not just use the chars directly?
if (idx < RX_BUF_SIZE) then
case rx_uart_buf(idx) is
when NUL => ParseState <= ST_PARSE_IDLE;
when ' ' => ParseState <= ST_PARSE_ARG1;
end case;
idx := idx + 1;
end if;
--- Quote End --- I see. Thank you. So it doesn't work in real life? I was planning to accumulate chars from terminal to rx_uart_buf and then parse the string.