UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Newbie cerkes
Newbie
115 Views
Registered: ‎07-13-2019

String and byte concatenation problem

I am having problems in string and byte concatenation. If string parameters are mixed with a byte in a concatenation, then, in the concatenation output, MSB bytes OR first characters of string become missing.

 

For example, in a simple testbench, the following string parameters are defined. I would like to place a number after file name.

    
    string output_path;
    parameter string OUTPUT_DIR = "output/";
    parameter string FILE_PREFIX = "img";
    byte file_number = 0;
    parameter string FILE_EXT = ".pgm";
    
   initial begin
        file_number = 1;
        file_number = file_number + 48;
        output_path = {OUTPUT_DIR, FILE_PREFIX, file_number, FILE_EXT};
        $display(output_path);
   end   

 

The "display" command outputs:

"utput/img1.pgm"

The first character which is "o" is missing...

0 Kudos
1 Reply
Moderator
Moderator
47 Views
Registered: ‎04-24-2013

Re: String and byte concatenation problem

Hi @cerkes ,

Strings are only really useful as constants because you have to set the length of them before you use them and they need padding:

signal my_string : string(1 to 6);

my_string <= "Hello"; --this is too short
my_string <= "Hello "; --fits

You can only use strings in test benches, not for synthesizable designs.

Best Regards
Aidan

 

------------------------------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if this answered your question
Give Kudos to a post which you think is helpful and may help other users
------------------------------------------------------------------------------------------------------------------
0 Kudos