• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Mixed-Signal Design
  3. Using $sformat in Verilog AMS

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 64
  • Views 8394
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using $sformat in Verilog AMS

Devin Atkin
Devin Atkin over 2 years ago

I feel I may be losing my mind, and I can't find any reference to what I'm doing wrong. I've tried a few different approaches and referred to the language reference. I'm trying to load a series of files one after another to provide test values for an image sensor design. I need to assemble the name of each frame so that I can load it with file operations. I was able to load a single frame and simulate no problems. However, when I start having to assemble the file names I run into issues and I feel like there has to be a simple solution to the problem. 

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

module Video (light[0:4095]);
    parameter integer width = 64;
    parameter integer height = 64;
    parameter real MAX_VALUE = 1e-9;

    //The number of frames available
    parameter integer frame_max = 279;

    //Folder and filename structure of the frames of the video
    parameter string folder_name = "video_csv";
    parameter string file_name_base = "video_framenumber";

    output [0:4095]light;

    string file_name;

    // Current Frame being output
    integer frame_counter = 0;

    electrical [0:4095] light;

    analog
    begin

        @(initial_step)
        begin
                   
            $sformat(file_name, "%s.csv",folder_name);
        end

    end
endmodule
When I run the testbench I end up getting the following error.
Recompiling... reason: file './video_images.vams' is newer than expected.
expected: Tue May 23 16:12:52 2023
actual: Tue May 23 16:39:34 2023
2023/05/23 16:39:57 System is not a supported distribution
2023/05/23 16:39:57 An error occurred. We don't recognize OS
2023/05/23 16:39:57 WARNING This OS does not appear to be a Cadence supported Linux configuration.
2023/05/23 16:39:57 For more info, please run CheckSysConf in <cdsRoot/tools.lnx86/bin/checkSysConf <productId>
file: ./video_images.vams
sprintf(file_name, "%s.csv",folder_name);
|
xmvlog: *E,BADSTMT (./video_images.vams,42|52): statement not allowed inside analog block [6.1(AMSLRM)].
module worklib.Video:vams
errors: 1, warnings: 0
xrun: *E,VLGERR: An error occurred during parsing. Review the log file for errors with the code *E and fix those identified problems to proceed. Exiting with code (status 1).
TOOL: xrun(64) 21.03-s002: Exiting on May 23, 2023 at 16:39:59 MDT (total: 00:00:03)
Any help or even a direction to go with debugging this would be greatly appreciated. 
  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 2 years ago

    The error message you show doesn't correspond to the code you have posted. It's complaining about a line with sprintf (your code doesn't have sprintf anywhere), and also without the dollar. The code compiles without any problem if you use $sformat. 

    However, there's a further issue that the simulator won't find the $sformat system task. It seems that this has not yet been implemented in the analog context - there's a change request, CCR 1540139, asking for this. You might want to contact customer support (submit a case after logging in) and request that a duplicate is filed on your behalf.

    As a workaround, you could set the file name in the digital context:

    `include "constants.vams"
    `include "disciplines.vams"
    
    module Video (light[0:4095]);
        parameter integer width = 64;
        parameter integer height = 64;
        parameter real MAX_VALUE = 1e-9;
    
        //The number of frames available
        parameter integer frame_max = 279;
    
        //Folder and filename structure of the frames of the video
        parameter string folder_name = "video_csv";
        parameter string file_name_base = "video_framenumber";
    
        output [0:4095]light;
    
        string file_name;
    
        // Current Frame being output
        integer frame_counter = 0;
    
        electrical [0:4095] light;
    
        initial begin
                $sformat(file_name, "%s.csv",folder_name);
        end
    
        analog
        begin
    
            @(initial_step)
            begin
    	    $strobe("File is ",file_name);
                       
    //            $sformat(file_name, "%s.csv",folder_name);
            end
    
        end
    endmodule
    

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 2 years ago

    The error message you show doesn't correspond to the code you have posted. It's complaining about a line with sprintf (your code doesn't have sprintf anywhere), and also without the dollar. The code compiles without any problem if you use $sformat. 

    However, there's a further issue that the simulator won't find the $sformat system task. It seems that this has not yet been implemented in the analog context - there's a change request, CCR 1540139, asking for this. You might want to contact customer support (submit a case after logging in) and request that a duplicate is filed on your behalf.

    As a workaround, you could set the file name in the digital context:

    `include "constants.vams"
    `include "disciplines.vams"
    
    module Video (light[0:4095]);
        parameter integer width = 64;
        parameter integer height = 64;
        parameter real MAX_VALUE = 1e-9;
    
        //The number of frames available
        parameter integer frame_max = 279;
    
        //Folder and filename structure of the frames of the video
        parameter string folder_name = "video_csv";
        parameter string file_name_base = "video_framenumber";
    
        output [0:4095]light;
    
        string file_name;
    
        // Current Frame being output
        integer frame_counter = 0;
    
        electrical [0:4095] light;
    
        initial begin
                $sformat(file_name, "%s.csv",folder_name);
        end
    
        analog
        begin
    
            @(initial_step)
            begin
    	    $strobe("File is ",file_name);
                       
    //            $sformat(file_name, "%s.csv",folder_name);
            end
    
        end
    endmodule
    

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Children
  • Devin Atkin
    Devin Atkin over 2 years ago in reply to Andrew Beckett

    Shoot, yeah I copied the wrong version of the error as I was trying different things. Moving that over into the digital should hopefully work for me. 

    Thank you for your help,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information