• 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. Functional Verification
  3. NC-verilog logical bug

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 65
  • Views 15005
  • 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

NC-verilog logical bug

Aiya
Aiya over 13 years ago

 I found a logical bug of simulation RTL code using NC-verilog.

Here is the test RTL code of mux implementation,

the input data of mux options are all zeroes (1'b0) 

the select signal is unknown (2'bxx)

The output result of do0 = 1'bx, do1 = 1'bx,  do2 = 1'b0,

varies depending on the coding style,

 Is this a bug of NC-verilog tool ? Can it be fixed ?

module  muxa(
input   wire  [ 1:0]  sel   ,
input   wire          di0   ,
input   wire          di1   ,
input   wire          di2   ,
input   wire          di3   ,
output  reg           do0   ,
output  wire          do1   ,
output  wire          do2  
);

always@*
  case(sel)
    2'h0: do0 = di0;
    2'h1: do0 = di1;
    2'h2: do0 = di2;
    2'h3: do0 = di3;
  endcase

wire  [3:0] di    = {di3, di2, di1, di0};
assign      do1   = di[sel];
assign      do2   = sel[1] ? (sel[0] ? di3 : di2) : (sel[0] ? di1 : di0);

endmodule

  • Cancel
Parents
  • StephenH
    StephenH over 13 years ago
    I think the mistake you're making is that you are expecting the tool to do logic synthesis and give you the output of pure boolean operations.
    A Verilog simulator is actually just an interpreter for your code, it executes program statements sequentially, following rules of the language.
    The simulator does not know that you're modelling a mux.

    In your case statement you don't have a default case, so if "sel" is 2'bxx, none of your explicit branches match, and do0 is not assigned.
    Remember 'bx in Verilog doesn't necessarily mean "don't care", it is just a symbol, so 2'bxx won't match 2'b00, 2'b01, 2'b10 or 2'b11.

    Your do2 is modelled differently and works, because it's basically a set of nested "if" statements.
    if (sel[0]=1) will fail when sel=2'bxx, so you drop into the else branch. But the do0 case doesn't have an "else", i.e. default branch to drop into.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • StephenH
    StephenH over 13 years ago
    I think the mistake you're making is that you are expecting the tool to do logic synthesis and give you the output of pure boolean operations.
    A Verilog simulator is actually just an interpreter for your code, it executes program statements sequentially, following rules of the language.
    The simulator does not know that you're modelling a mux.

    In your case statement you don't have a default case, so if "sel" is 2'bxx, none of your explicit branches match, and do0 is not assigned.
    Remember 'bx in Verilog doesn't necessarily mean "don't care", it is just a symbol, so 2'bxx won't match 2'b00, 2'b01, 2'b10 or 2'b11.

    Your do2 is modelled differently and works, because it's basically a set of nested "if" statements.
    if (sel[0]=1) will fail when sel=2'bxx, so you drop into the else branch. But the do0 case doesn't have an "else", i.e. default branch to drop into.
    • 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