Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem with 'logical anding' in Verilog !!

Status
Not open for further replies.

osm3000

Newbie level 6
Newbie level 6
Joined
Mar 6, 2012
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,385
Hi everyone,

I've this annoying problem in my Verilog code.

This my code

HTML:
always @(posedge REF_CLK or negedge all_reset)
  begin
    if (~all_reset)
      TSM_R_B_N <= 1'b0;
    else if (clr_r_b_n)
      TSM_R_B_N <= ( (1'b0) && LUNSTATUS6 );
    else if (set_r_b_n)
      TSM_R_B_N <= ( (1'b1) && LUNSTATUS6 );
  end

What I want is to simply OR 'LUNSTATUS6 ' signal with another value - depending on a flag - and assign this to 'TSM_R_B_N '.

In the waveform however, when 'LUNSTATUS6' changes to 0, 'TSM_R_B_N' doesn't make any change.

result.PNG

Can anyone give me a help?
 
Last edited:

Could be a race condition. How are the other signals being assigned? with non-blocking assignment? You can run vsim -nowlfcollapse to recode the exact order that variables change within a time-step. See the section on "Expanded Time in the Wave Window" in the User Manual.
 

Well, the sensitivity list is as you made a flip-flop, so the TSM_.. will change only when ref_clk will rise.
And 1'b0 && ... Will always give 0, 0 and what you want equal 0.
The or is made with |.
 

Thanks dave_59 and rca for your replies.

I actually discovered that the problem is much simpler - and honestly I feel really stupid about it -.

The flags 'clr_r_b_n' and 'set_r_b_n' aren't working properly. I was actually looking at the wrong waves for these flags.

As soon as I fixed this, the problem became an issue with the logic itself.

This is the code after fixing

HTML:
always @(posedge REF_CLK or negedge all_reset)
  //always @(*)
  begin
    if (~all_reset)
      TSM_R_B_N <= 1'b0;
    else if (clr_r_b_n || ~LUNSTATUS6)
      TSM_R_B_N <= 1'b0;
    else if (set_r_b_n || LUNSTATUS6)
      TSM_R_B_N <= 1'b1;
  end

This will make the right behavior.

- - - Updated - - -

Could be a race condition. How are the other signals being assigned? with non-blocking assignment? You can run vsim -nowlfcollapse to recode the exact order that variables change within a time-step. See the section on "Expanded Time in the Wave Window" in the User Manual.

Thank you for this information. Also this it turns out that this is not the case here, yet I made use for this in other parts of my code. Thanks a lot.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top