+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 6
    Points: 701, Level: 5

    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    12
    Helped
    0 / 0
    Points
    701
    Level
    5

    Help Need: Please help me to understand this code

    Not a RTL coder but I need to understand this piece of code:

    finalGater = scanEn ? testModeEn: ~scanEn ? funcMode : 1'hx;

    what does it means? any sample code/syntax I can use as reference?

    thanks!

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 3
    Points: 6,551, Level: 19
    Achievements:
    Created Blog entry 7 years registered

    Join Date
    Dec 2011
    Location
    Fremont, CA, USA
    Posts
    794
    Helped
    355 / 355
    Points
    6,551
    Level
    19
    Blog Entries
    4

    Re: Help Need: Please help me to understand this code

    See section 11.4.11 Conditional operator of the IEEE 1800-2012 LRM.
    Dave Rich
    Senior Verification Consultant
    Mentor Graphics Corporation



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 6
    Points: 701, Level: 5

    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    12
    Helped
    0 / 0
    Points
    701
    Level
    5

    Re: Help Need: Please help me to understand this code

    Thank you! Appreciate for pointing me the document.



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 5
    Points: 14,946, Level: 29
    mrflibble's Avatar
    Join Date
    Apr 2010
    Posts
    2,724
    Helped
    687 / 683
    Points
    14,946
    Level
    29

    Re: Help Need: Please help me to understand this code

    Quote Originally Posted by tokwatbaboy View Post
    finalGater = scanEn ? testModeEn: ~scanEn ? funcMode : 1'hx;
    And regarding code readability, personally I'd write that like so:
    Code SystemVerilog - [expand]
    1
    
    finalGater = scanEn ? testModeEn : (~scanEn ? funcMode : 1'hx);
    That way it's easier to see how the ~scanEn ? funcMode : 1'hx part of the expression is evaluated. Not just for yourself, but also for future victims. Even if that future victim is future you. ;)



--[[ ]]--