Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

verilog - Does this SystemVerilog code have the wrong sequence of code?

I wrote the following SystemVerilog code inside always_comb:

 // State transitions
    SW2_REP: begin
        casex (mani)
            1'b0:   next = SW_TMP;
            1'b1:   next = FETCH;
            // This is never reached
            default:next = FETCH;
        endcase
    end
    SW_TMP:
        next = LSW_ADDR;

Then I wrote this too inside always_comb:

 // State Machine Outputs
    SW2_UPD: begin
        regwen      = 1'b1;
        wbsel       = WB_ALUOUT;
    end
    SW_TMP: begin
        mani        = 1'b1;
    end

But for some strange reason when I run a simulation on ModelSim, the value of mani turns to 0 after it was updated to 1 upon visiting the TMP state. What is causing this problem? (In my whole code I never changed mani's value to 0.)

If this helps, here is my diagram (please note: There isn't any need to look at all of it, only the part mentioned before - bottom right).

On the top left you can see the default values, and for mani it's 0.

Enter image description here

Here's an image from the simulation:

Enter image description here

I was expecting mali to stay 1 as long as I never changed its value to zero.

Note: my clock is 11 cycles


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...