Prevent signals from being optimized away

Hi all,

I’ve written a SV testbench with a program block generating the stimulus for the DUT. Additionaly I added a signal in my program block which I don’t use but want to see in my Wave windows. I have the problem that it is optimized away.

Is there a possibility to keep certain signals without disable the whole optimization? Just say the simulation tool to keep certain signals?

My program:



`timescale 1ns/10ps


program automatic SlopeMeasurement_MainProg(slope_interface.TB slope_mif);
    
    logic signed [17:0] angle = 0;
    logic signal_change = 0;
    real expectedAngle = 0;
    
    initial begin : Slope_Increments
        slope_mif.IncrementFactor1 = 'b0010101010101101;
        slope_mif.IncrementFactor2 = 'b0010101010101101;
        slope_mif.nSampleForSlope = 3;
        // wait 100 us
        #100_000;
        slope_mif.IncrementFactor1 = 5000;
        // wait 100 us
        #100_000;
        slope_mif.IncrementFactor1 = 10000;
        // wait 100 us
        #100_000;
        slope_mif.IncrementFactor1 = 100000;
    end
    
    
    
    initial begin
        angle = -12500*5/2;
        forever begin
            // rising
            for (int i = 0; i < 12500; i++) begin
                for (int i = 0; i < 127; i++) begin
                    @(posedge slope_mif.clk);
                end
                angle += 5;
                signal_change <= 'b1;
                @(posedge slope_mif.clk);
                signal_change <= 'b0;
            end
            // falling
            for (int i = 0; i < 12500; i++) begin
                for (int i = 0; i < 127; i++) begin
                    @(posedge slope_mif.clk);
                end
                angle -= 5;
                signal_change <= 'b1;
                @(posedge slope_mif.clk);
                signal_change <= 'b0;
            end
        end
    end
    
    assign slope_mif.angle = angle;
    assign slope_mif.signal_change = signal_change;
    
    
    // calculate the expected angle
    initial begin : ExpectedAngle_ib
        integer counter;
        forever begin
            @(posedge slope_mif.clk);
            if (signal_change == 'b1) begin
                counter = 0;
            end else begin
                counter++;
            end
            expectedAngle = angle + slope_mif.extrapol_inc1 / 128;
        end
    end
    
endprogram


The signal I want prevent from optimization is the expectedAngle!

Kind regards
Sebastian

In reply to sebastian_z:

Most tools have ways of preserving the visibility of certain signals. That is going to be tool specific and you will need to read the user manual or contact your vendor.

In reply to dave_59:

Hi Dave,

thank you very much for your answer. I noticed that I did forget to write the tool: it is MentorGraphics Questa!

Kind regards
Sebastian

In reply to sebastian_z:

Definitely not an expert but here are my 2 cents… As far as I have figured it out, for QuestaSim you need to have +acc flag included…

So, when writing your scripts you should have something like:

vopt +acc top -o top_opt -debugdb

where “top” is your top module and “top_opt” is your optimized design which you will later simulate.

Again, still learning myself, so I recommend you try this but wait for some master in this to confirm or give proper answer.

In reply to mirkic:
This public forum is not for tool specific support. But I will tell you that +acc does not accomplish the requirement of keeping certain signals visible without disabling the whole optimization.