• 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. [SOLVED] unable to compile with genvar variable in veri...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 64
  • Views 19822
  • 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

[SOLVED] unable to compile with genvar variable in veriloga

msharma
msharma over 10 years ago

I am writing a verilog-ams model for an 8 bit ADC. The code is derived from section 4.5.8 example 2 of vams2.3.1 reference. However, the use of genvar gives an error:

--------------

Error found by spectre during AHDL compile.
    ERROR (VACOMP-1149):
        "/.../adc_8bit/veriloga/veriloga.va", line
        27: Genvar loop evaluation failed. Check whether `/usr/bin/perl' is
        available.
    ERROR (VACOMP-1816): Exiting AHDL compilation.
Internal error found in spectre during AHDL compile, during generation of
        Artist DPLs.  
Encountered a critical error during simulation. Submit a Service Request via
        Cadence Online Support, including the netlist, the Spectre log file,
        the behavioral model files, and any other information that can help
        identify the problem.
    FATAL (SPECTRE-18): Segmentation fault.
/uusoc/facility/cad_tools/Cadence/MMSIM_13.11.176_lnx86/tools/bin/spectre[80]: .: line 1076: 22896: Abort

--------------

The error is in the first line that uses genvar, and complains about "usr/bin/perl". Any clues to fixing this?

Here is my complete code

--------------


`include "constants.vams"
`include "disciplines.vams"
`timescale 1ns / 1ps

module adc_8bit (out, in, clk, vref, avdd, agnd, ibias) ;
input in, clk, vref, avdd, agnd, ibias;
output [0:7] out;
electrical in, clk, vref, avdd, agnd, ibias;
electrical [0:7] out;

real vdd, ref;
real sample;
integer result[0:7];
//integer i;
genvar i;

analog begin

 vdd = V(avdd) - V(agnd);
 ref = V(vref) - V(agnd);
        @(cross(V(clk) - vdd/2, +1)) begin
                sample = V(in);
                for ( i = 7; i >= 0; i = 1-1) begin
                        if (sample > ref) begin
                                result[i] = 1;
                                sample = sample - ref;
                        end
                        else begin
                                result[i] = 0;
                        end
                        sample = 2.0*sample;
                end
        /*
                for ( i = 7; i >= 0; i = 1-1) begin
                        V(out[i]) <+ transition(result[i], 0, 10n);
                end
        */
                V(out[7]) <+ transition(result[7], 0, 10n);
                V(out[6]) <+ transition(result[6], 0, 10n);
                V(out[5]) <+ transition(result[5], 0, 10n);
                V(out[4]) <+ transition(result[4], 0, 10n);
                V(out[3]) <+ transition(result[3], 0, 10n);
                V(out[2]) <+ transition(result[2], 0, 10n);
                V(out[1]) <+ transition(result[1], 0, 10n);
                V(out[0]) <+ transition(result[0], 0, 10n);
        end

endmodule

--------------

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    First of all, please read the forum guidelines. These ask you not to post the same question in multiple forums. I will answer your issue here and add a cross-reference in the other post.

    The cause of the problem (unfortunately it gives a rather cryptic message) is that your for loop is incorrect. You have:

                    for ( i = 7; i >= 0; i = 1-1) begin

    this means that you have an infinite loop. because i is set to 0 at the end of each iteration and so will never end. A genvar causes it to attempt to expand the loop at compilation time (or elaboration time - not entirely sure which off the top of my head) and so it can't succeed. The message about perl is misleading in this case.

    In the code as it stood, you could have left it as an integer rather than a genvar because there's no need for it to be a genvar (only the commented out part needs a genvar). However, that reveals that  you have an end statement missing. This needs to end the begin for the @cross statement, because the contribution statements need to be outside of the @cross block as they need to be present on every iteration, not just during the cross events. If you'd fixed the missing end and left it as an integer rather than genvar, you'd have seen it hang at simulaton time because of the infinite loop.

    Anyway, by fixing the for loop and uncommenting the for loop around the contribution statements (and fixing the for loop there too as that was also incorrect) and inserting the missing end, I get:

    `include "constants.vams"
    `include "disciplines.vams"
    `timescale 1ns / 1ps

    module adc_8bit (out, in, clk, vref, avdd, agnd, ibias) ;
    input in, clk, vref, avdd, agnd, ibias;
    output [0:7] out;
    electrical in, clk, vref, avdd, agnd, ibias;
    electrical [0:7] out;

    real vdd, ref;
    real sample;
    integer result[0:7];
    //integer i;
    genvar i;

    analog begin

     vdd = V(avdd) - V(agnd);
     ref = V(vref) - V(agnd);
            @(cross(V(clk) - vdd/2, +1)) begin
                    sample = V(in);
                    //for ( i = 7; i >= 0; i = 1-1) begin
                    for ( i = 7; i >= 0; i = i-1) begin
                            if (sample > ref) begin
                                    result[i] = 1;
                                    sample = sample - ref;
                            end
                            else begin
                                    result[i] = 0;
                            end
                            sample = 2.0*sample;
                    end
            end
            for ( i = 7; i >= 0; i = i-1) begin
                    V(out[i]) <+ transition(result[i], 0, 10n);
            end
            /*
                    V(out[7]) <+ transition(result[7], 0, 10n);
                    V(out[6]) <+ transition(result[6], 0, 10n);
                    V(out[5]) <+ transition(result[5], 0, 10n);
                    V(out[4]) <+ transition(result[4], 0, 10n);
                    V(out[3]) <+ transition(result[3], 0, 10n);
                    V(out[2]) <+ transition(result[2], 0, 10n);
                    V(out[1]) <+ transition(result[1], 0, 10n);
                    V(out[0]) <+ transition(result[0], 0, 10n);
            */
            end

    endmodule

    which works correctly.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    First of all, please read the forum guidelines. These ask you not to post the same question in multiple forums. I will answer your issue here and add a cross-reference in the other post.

    The cause of the problem (unfortunately it gives a rather cryptic message) is that your for loop is incorrect. You have:

                    for ( i = 7; i >= 0; i = 1-1) begin

    this means that you have an infinite loop. because i is set to 0 at the end of each iteration and so will never end. A genvar causes it to attempt to expand the loop at compilation time (or elaboration time - not entirely sure which off the top of my head) and so it can't succeed. The message about perl is misleading in this case.

    In the code as it stood, you could have left it as an integer rather than a genvar because there's no need for it to be a genvar (only the commented out part needs a genvar). However, that reveals that  you have an end statement missing. This needs to end the begin for the @cross statement, because the contribution statements need to be outside of the @cross block as they need to be present on every iteration, not just during the cross events. If you'd fixed the missing end and left it as an integer rather than genvar, you'd have seen it hang at simulaton time because of the infinite loop.

    Anyway, by fixing the for loop and uncommenting the for loop around the contribution statements (and fixing the for loop there too as that was also incorrect) and inserting the missing end, I get:

    `include "constants.vams"
    `include "disciplines.vams"
    `timescale 1ns / 1ps

    module adc_8bit (out, in, clk, vref, avdd, agnd, ibias) ;
    input in, clk, vref, avdd, agnd, ibias;
    output [0:7] out;
    electrical in, clk, vref, avdd, agnd, ibias;
    electrical [0:7] out;

    real vdd, ref;
    real sample;
    integer result[0:7];
    //integer i;
    genvar i;

    analog begin

     vdd = V(avdd) - V(agnd);
     ref = V(vref) - V(agnd);
            @(cross(V(clk) - vdd/2, +1)) begin
                    sample = V(in);
                    //for ( i = 7; i >= 0; i = 1-1) begin
                    for ( i = 7; i >= 0; i = i-1) begin
                            if (sample > ref) begin
                                    result[i] = 1;
                                    sample = sample - ref;
                            end
                            else begin
                                    result[i] = 0;
                            end
                            sample = 2.0*sample;
                    end
            end
            for ( i = 7; i >= 0; i = i-1) begin
                    V(out[i]) <+ transition(result[i], 0, 10n);
            end
            /*
                    V(out[7]) <+ transition(result[7], 0, 10n);
                    V(out[6]) <+ transition(result[6], 0, 10n);
                    V(out[5]) <+ transition(result[5], 0, 10n);
                    V(out[4]) <+ transition(result[4], 0, 10n);
                    V(out[3]) <+ transition(result[3], 0, 10n);
                    V(out[2]) <+ transition(result[2], 0, 10n);
                    V(out[1]) <+ transition(result[1], 0, 10n);
                    V(out[0]) <+ transition(result[0], 0, 10n);
            */
            end

    endmodule

    which works correctly.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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