The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 16th, 2024, 4:46pm
Pages: 1
Send Topic Print
string variables in VerilogA (Read 10494 times)
makelo
Community Member
***
Offline



Posts: 34
Hillsboro, OR
string variables in VerilogA
Apr 27th, 2007, 10:56am
 
I want to improve the VerilogA file that I use to write data to a text file.  The current version works but does not allow me to change the file name during execution of the program.  I tried using the the STRCAT function to concatenate a two strings but that does not work.

Here is what I currently have that works.

`include "disciplines.vams"
`include "constants.vams"

module sink_IQ(vi,vq);
   electrical vi,vq;
   parameter string file_name = "dat1_out.tbl";
   parameter real T_step = 1e-9;
   integer file_ptr, hdrPrinted;

   analog begin
       @( initial_step ) begin
          file_ptr=$fopen(file_name);
       end

       @(timer(0,T_step)) begin
         $fwrite(file_ptr, "%e %e %e\n", $abstime, V(vi), V(vq));
       end

       @ (final_step) begin
         $fclose(file_ptr);
       end
   end
endmodule


I would like to add a line like
    file_name = strcat(file_name,suffix);
within the code to allow me to change the file name. Is there another way to do this?

Thanks,
Makelo
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: string variables in VerilogA
Reply #1 - Apr 30th, 2007, 4:13am
 
I see in this thread: http://www.designers-guide.org/Forum/YaBB.pl?num=1177697346
you've tried passing the parameter and had trouble.

The AMS committee is presently considering extensions to the language to support the sorts of things you want to do, but I'm not aware of any simulator that allows you to do it now (sometimes, extensions are "donated" by a company that already supports the new feature).
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
chetan
New Member
*
Offline



Posts: 5

Re: string variables in VerilogA
Reply #2 - May 30th, 2007, 11:49am
 
The concatenation operator addresses your need.

Example:

`include "constants.h"
`include "discipline.h"

module add_str( in1, in2 );

input in1, in2;
electrical in1;
electrical in2 ;

parameter string filename = "foo" ;
parameter string file_ext = ".bar" ;
string concatenated ;

string var1 ;
string var2 ;
string concat_var ;

analog
       begin
          V(in1,in2) <+ I(in1,in2) ;
          concatenated = { filename, file_ext};        
          $strobe("concat from params:%s ", concatenated ) ;

          var1 = "car" ;
          var2 = ".shar" ;
          concat_var = {var1, var2} ;
          $strobe("concat from vars:%s ", concat_var ) ;
       end
endmodule

Back to top
 
 


View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: string variables in VerilogA
Reply #3 - May 31st, 2007, 3:44am
 
chetan -
Unfortunately, string variables are not part of the Verilog-AMS LRM:
string concatenated;

is not legal Verlog-AMS.

Also, having recently read the SystemVerilog LRM section on strings, it talks about assigning string literals or string types to string variables; is a concatenation of string types a self-determined expression of string type?
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.