• 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. Custom IC Design
  3. Update VerilogA outputs during simulation based on values...

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 125
  • Views 9874
  • 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

Update VerilogA outputs during simulation based on values read from from

slim15
slim15 over 4 years ago

For verification of an analog block, I am trying to set up my testbench such that I can change the output of a verilogA input stimulus during transient simulation. The goal is to read a text file at every rising edge of a clock and use the value to change the behaviour of the analog block. The text file will contain only a single line with a single integer value. The version of Spectre is 20.10.isr3

In Spectre X simulation log, I see the CSV file, PGA_GAIN_DATA, being read at the first crossing event with the message "Reading file: /home/c99485/simulation/sandbox/sandbox/maestro/results/maestro/PGA/netlist/PGA_GAIN_DATA.txt". the output bus of the verilogA was also updated. However, all subsequent crossing event did not yield any other messages and it appear that Spectre simulator would just reuse the data that it had acquire from the first read and stored in its memory. Removing or renaming the file after the first instance did not affect the transient simulation. 

Is this behaviour expecter? Can I get Spectre to re-read the CSV file and not reuse the data from its memory? 

==========

// VerilogA for sandbox02, CTRL_PGA, veriloga

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

module CTRL_PGA (VDD, VSS, PGA_GAIN, CLK);

  output [3:0] PGA_GAIN;
  inout VDD, VSS;
  input CLK;

  electrical [3:0] PGA_GAIN;
  electrical VDD, VSS, CLK;

  integer OVR_PGA_GAIN;
  integer fileID, retval;
  real vthres;
  genvar i;

  analog begin

      @(initial_step) begin
         vthres = V(VDD)-V(VSS);
         OVR_PGA_GAIN = 0;
      end

     @(cross(V(CLK) - vthres, 1.0)) begin
        fileID = $fopen("PGA_GAIN_DATA.txt", "r");
        if (fileID > 0) begin
          retval =1;
          while (retval == 1) begin
          retval = $fscanf(fileID, "%d", OVR_PGA_GAIN);
        end
      end
    end

    for (i=3; i>=0; i=i-1) begin
      V(PGA_GAIN[i]) <+ (OVR_PGA_GAIN>>i)&1 ? V(VDD) : V(VSS);
    end

  end
endmodule

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    I would expect that you would need to use $fclose to close the file:

    if (fileID > 0) begin
      retval =1;
      while (retval == 1) begin
        retval = $fscanf(fileID, "%d", OVR_PGA_GAIN);
      end
      $fclose(fileID);
    end

    but even that doesn't appear to work in my experiments. There was a discussion about something (sort of) similar in a Cadence Change Request (CCR) 907057, but that was talking about re-reading the file contents within a tilmestep, but this seems to be on separate time steps.

    I suggest you contact customer support. I'm not sure why this doesn't work (other than some optimisation).

    Andrew

    • 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