Does the last elseif run or not?

Discussion in 'VHDL' started by fl, Feb 24, 2013.

  1. fl

    fl Guest

    Hi,
    I have the testbench generated by Matlab HDL coder below the dot line.
    Signal "filter_out_rdenb" is connected to a filter CE_OUT component pin (This filter is the DUT of this testbench).


    I am curious about line ld. It has the condition line la:

    filter_out_rdenb='1';

    then line lb through le will has condition: "filter_out_rdenb='0'". Is this right?

    But it again check
    lc: ELSIF filter_out_rdenb = '1'
    at line lc.

    I think ld will never be run. Does Matlab HDL Coder wrong?
    Or this is intentional to test an abnormal filter CE_OUT condition? I cannot imagine it now. Could you tell me that if that is right?


    Thanks

    ...............
    checker_1: PROCESS(clk, reset)
    BEGIN
    IF reset = '1' THEN
    filter_out_timeout <= 0;
    filter_out_errCnt <= 0;
    filter_out_testFailure <= '0';
    ELSIF clk'event and clk ='1' THEN
    la: IF filter_out_rdenb = '1' THEN
    filter_out_timeout <= 0;
    IF filter_out /= filter_out_expected THEN
    filter_out_errCnt <= filter_out_errCnt + 1;
    filter_out_testFailure <= '1';
    ASSERT FALSE
    REPORT "Error in filter_out: Expected "
    & to_hex(filter_out_expected)
    & " Actual "
    & to_hex(filter_out)
    SEVERITY ERROR;
    IF filter_out_errCnt >= MAX_ERROR_COUNT THEN
    ASSERT FALSE
    REPORT "Number of errors have exceeded the maximum error"
    SEVERITY Warning;
    END IF;
    END IF;
    lb: ELSIF filter_out_timeout > MAX_TIMEOUT AND filter_out_rdenb = '1' THEN
    filter_out_errCnt <= filter_out_errCnt + 1;
    filter_out_testFailure <= '1';
    ASSERT FALSE
    REPORT "Timeout: Data was not received after timeout."
    SEVERITY FAILURE ;
    lc: ELSIF filter_out_rdenb = '1' THEN
    ld: filter_out_timeout <= filter_out_timeout + 1 ;
    le: END IF;
    END IF;
    END PROCESS checker_1;
     
    fl, Feb 24, 2013
    #1
    1. Advertising

  2. Hello

    Le 24/02/2013 20:39, fl a écrit :
    > Hi,
    > I have the testbench generated by Matlab HDL coder below the dot line.
    > Signal "filter_out_rdenb" is connected to a filter CE_OUT component pin (This filter is the DUT of this testbench).
    >
    > I am curious about line ld. It has the condition line la:
    > filter_out_rdenb='1';
    >
    > then line lb through le will has condition: "filter_out_rdenb='0'". Is this right?
    >
    > But it again check
    > lc: ELSIF filter_out_rdenb = '1'
    > at line lc.
    >
    > I think ld will never be run. Does Matlab HDL Coder wrong?
    > Or this is intentional to test an abnormal filter CE_OUT condition? I cannot imagine it now. Could you tell me that if that is right?
    >
    >
    > Thanks
    >
    > ..............
    > checker_1: PROCESS(clk, reset)
    > BEGIN
    > IF reset = '1' THEN

    [...]
    > ELSIF clk'event and clk ='1' THEN
    > la: IF filter_out_rdenb = '1' THEN

    [...]
    > lb: ELSIF filter_out_timeout > MAX_TIMEOUT AND filter_out_rdenb = '1' THEN

    [...]
    > lc: ELSIF filter_out_rdenb = '1' THEN
    > ld: filter_out_timeout <= filter_out_timeout + 1 ;
    > le: END IF;
    > END IF;
    > END PROCESS checker_1;


    This makes no sense, every condition tests for filter_out_rdenb = '1'.
    Conditions lb and lc will always be false or overriden by la.

    I've never trusted automatic code generation and this is not going to
    make me change my mind...

    Nicolas
     
    Nicolas Matringe, Feb 24, 2013
    #2
    1. Advertising

  3. fl

    rickman Guest

    On 2/24/2013 2:39 PM, fl wrote:
    > Hi,
    > I have the testbench generated by Matlab HDL coder below the dot line.
    > Signal "filter_out_rdenb" is connected to a filter CE_OUT component pin (This filter is the DUT of this testbench).
    >
    >
    > I am curious about line ld. It has the condition line la:
    >
    > filter_out_rdenb='1';
    >
    > then line lb through le will has condition: "filter_out_rdenb='0'". Is this right?
    >
    > But it again check
    > lc: ELSIF filter_out_rdenb = '1'
    > at line lc.
    >
    > I think ld will never be run. Does Matlab HDL Coder wrong?
    > Or this is intentional to test an abnormal filter CE_OUT condition? I cannot imagine it now. Could you tell me that if that is right?


    Not only will the section under 1c not run, the condition at 1b will
    never evaluate as true and so that section can never run either. Unless
    there is something I'm missing that would make the structure different
    from the indentation this code is rather bogus. How was the code
    generated? What are the inputs?

    I would report it to MatLab.

    Rick


    > ..............
    > checker_1: PROCESS(clk, reset)
    > BEGIN
    > IF reset = '1' THEN
    > filter_out_timeout<= 0;
    > filter_out_errCnt<= 0;
    > filter_out_testFailure<= '0';
    > ELSIF clk'event and clk ='1' THEN
    > la: IF filter_out_rdenb = '1' THEN
    > filter_out_timeout<= 0;
    > IF filter_out /= filter_out_expected THEN
    > filter_out_errCnt<= filter_out_errCnt + 1;
    > filter_out_testFailure<= '1';
    > ASSERT FALSE
    > REPORT "Error in filter_out: Expected "
    > & to_hex(filter_out_expected)
    > & " Actual"
    > & to_hex(filter_out)
    > SEVERITY ERROR;
    > IF filter_out_errCnt>= MAX_ERROR_COUNT THEN
    > ASSERT FALSE
    > REPORT "Number of errors have exceeded the maximum error"
    > SEVERITY Warning;
    > END IF;
    > END IF;
    > lb: ELSIF filter_out_timeout> MAX_TIMEOUT AND filter_out_rdenb = '1' THEN
    > filter_out_errCnt<= filter_out_errCnt + 1;
    > filter_out_testFailure<= '1';
    > ASSERT FALSE
    > REPORT "Timeout: Data was not received after timeout."
    > SEVERITY FAILURE ;
    > lc: ELSIF filter_out_rdenb = '1' THEN
    > ld: filter_out_timeout<= filter_out_timeout + 1 ;
    > le: END IF;
    > END IF;
    > END PROCESS checker_1;



    --

    Rick
     
    rickman, Feb 24, 2013
    #3
  4. fl

    fl Guest

    On Sunday, February 24, 2013 4:49:58 PM UTC-5, rickman wrote:
    > On 2/24/2013 2:39 PM, fl wrote:
    >
    > > Hi,

    >
    > > I have the testbench generated by Matlab HDL coder below the dot line.

    >
    > > Signal "filter_out_rdenb" is connected to a filter CE_OUT component pin(This filter is the DUT of this testbench).

    >
    > >

    >
    > >

    >
    > > I am curious about line ld. It has the condition line la:

    >
    > >

    >
    > > filter_out_rdenb='1';

    >
    > >

    >
    > > then line lb through le will has condition: "filter_out_rdenb='0'". Is this right?

    >
    > >

    >
    > > But it again check

    >
    > > lc: ELSIF filter_out_rdenb = '1'

    >
    > > at line lc.

    >
    > >

    >
    > > I think ld will never be run. Does Matlab HDL Coder wrong?

    >
    > > Or this is intentional to test an abnormal filter CE_OUT condition? I cannot imagine it now. Could you tell me that if that is right?

    >
    >
    >
    > Not only will the section under 1c not run, the condition at 1b will
    >
    > never evaluate as true and so that section can never run either. Unless
    >
    > there is something I'm missing that would make the structure different
    >
    > from the indentation this code is rather bogus. How was the code
    >
    > generated? What are the inputs?
    >
    >
    >
    > I would report it to MatLab.
    >
    >
    >
    > Rick
    >
    >
    >
    >
    >
    > > ..............

    >
    > > checker_1: PROCESS(clk, reset)

    >
    > > BEGIN

    >
    > > IF reset = '1' THEN

    >
    > > filter_out_timeout<= 0;

    >
    > > filter_out_errCnt<= 0;

    >
    > > filter_out_testFailure<= '0';

    >
    > > ELSIF clk'event and clk ='1' THEN

    >
    > > la: IF filter_out_rdenb = '1' THEN

    >
    > > filter_out_timeout<= 0;

    >
    > > IF filter_out /= filter_out_expected THEN

    >
    > > filter_out_errCnt<= filter_out_errCnt + 1;

    >
    > > filter_out_testFailure<= '1';

    >
    > > ASSERT FALSE

    >
    > > REPORT "Error in filter_out: Expected "

    >
    > > & to_hex(filter_out_expected)

    >
    > > & " Actual"

    >
    > > & to_hex(filter_out)

    >
    > > SEVERITY ERROR;

    >
    > > IF filter_out_errCnt>= MAX_ERROR_COUNT THEN

    >
    > > ASSERT FALSE

    >
    > > REPORT "Number of errors have exceeded the maximum error"

    >
    > > SEVERITY Warning;

    >
    > > END IF;

    >
    > > END IF;

    >
    > > lb: ELSIF filter_out_timeout> MAX_TIMEOUT AND filter_out_rdenb = '1' THEN

    >
    > > filter_out_errCnt<= filter_out_errCnt + 1;

    >
    > > filter_out_testFailure<= '1';

    >
    > > ASSERT FALSE

    >
    > > REPORT "Timeout: Data was not received after timeout."

    >
    > > SEVERITY FAILURE ;

    >
    > > lc: ELSIF filter_out_rdenb = '1' THEN

    >
    > > ld: filter_out_timeout<= filter_out_timeout + 1 ;

    >
    > > le: END IF;

    >
    > > END IF;

    >
    > > END PROCESS checker_1;

    >
    >
    >
    >
    >
    > --
    >
    >
    >
    > Rick


    Thanks both of you. This testbench is for a filter:


    u_hcic: hcic
    PORT MAP (
    clk => clk,
    clk_enable => clk_enable,
    reset => reset,
    filter_in => filter_in,
    filter_out => filter_out,
    ce_out => h_ce_out );

    I have a further question to ask here. I have several years experience of digital circuits design, including EPLD and small implementation on FPGA. For testbench, I assumed it was not a big problem at all in the past. Occasionally I programmed small VHDL code. I used Matlab/Simulink for a medium algorithm project. Recently, I realize that there are some importance on the testbench. I do not find a tutorial or book useful for me on this subject.

    Conceptually, testbench can test suspicious point/component in a big design.. At least there are some techniques to write code on different hierarchy levels etc. Could you tell me any web site, web links on testbench tutorials, typical examples?

    Thanks,
     
    fl, Feb 24, 2013
    #4
  5. fl

    Andy Guest

    I highly recommend "Writing Testbenches: Functional Verification of HDL Models", by Janick Bergeron.

    If you plan on writing tesbenches in verilog or VHDL, the first edition (blue cover) is actually better than the second edition (red cover), which has less detail on VHDL/Verilog in favor of other verification languages.

    Janick also has a similar book for SystemVerilog, but I am not familiar with it.

    You might also be interested in Open Source VHDL Verification Methodology (OSVVM.org). It is a VHDL library of packages written by Jim Lewis for constrained random pattern generation and coverage modeling.

    Andy
     
    Andy, Feb 25, 2013
    #5
  6. fl

    Reuven Guest

    On Monday, February 25, 2013 10:41:26 AM UTC-8, Andy wrote:
    > I highly recommend "Writing Testbenches: Functional Verification of HDL Models", by Janick Bergeron.
    >
    >
    >
    > If you plan on writing tesbenches in verilog or VHDL, the first edition (blue cover) is actually better than the second edition (red cover), which has less detail on VHDL/Verilog in favor of other verification languages.
    >
    >
    >
    > Janick also has a similar book for SystemVerilog, but I am not familiar with it.
    >
    >
    >
    > You might also be interested in Open Source VHDL Verification Methodology (OSVVM.org). It is a VHDL library of packages written by Jim Lewis for constrained random pattern generation and coverage modeling.
    >
    >
    >
    > Andy


    I also recommend using the OVL library for verification. Use the VHDL only checkers is you only have a VHDL simulator license.
     
    Reuven, Feb 27, 2013
    #6
  7. fl

    HT-Lab Guest

    On 27/02/2013 20:47, Reuven wrote:
    > On Monday, February 25, 2013 10:41:26 AM UTC-8, Andy wrote:
    > ....
    > I also recommend using the OVL library for verification. Use the VHDL only checkers is you only have a VHDL simulator license.
    >

    Sorry for the people who worked hard on the OVL but I actually wouldn't
    recommend it, at least not to everybody. If you are serious about
    assertions and functional verification than dive straight into PSL or SVA.

    When I tried the latest OVL library I was actually struggling to get a
    simple checker working. Only when I played with the ovl_ctrl_record did
    I managed to get it up and running. The same checker was just a single
    line of PSL (excluding the default clock statement etc).

    Another slight disadvantage is that a large number of VHDL checkers call
    the Verilog version and hence you need a dual language license.

    Get yourself Modelsim DE or the Aldec equivalent and start using PSL,
    you can pick up basic PSL in just a few hours, it is not difficult.

    What would be great if Doulos decided to allocate one of their free 1
    hour training courses to PSL (I know they read this newsgroup :)

    Hans
    www.ht-lab.com
     
    HT-Lab, Feb 28, 2013
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leon

    ElseIF or Case Statement?

    Leon, Dec 16, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    487
    Dan Bass
    Dec 17, 2004
  2. sangram
    Replies:
    16
    Views:
    2,002
  3. simonced

    elseif problem

    simonced, Jun 2, 2006, in forum: Ruby
    Replies:
    7
    Views:
    137
    simonced
    Jun 3, 2006
  4. 7stud 7stud

    elseif v. elsif ??

    7stud 7stud, Mar 7, 2007, in forum: Ruby
    Replies:
    83
    Views:
    852
    Samantha
    Mar 13, 2007
  5. planetthoughtful

    Newbie: if / elseif

    planetthoughtful, Mar 14, 2007, in forum: Ruby
    Replies:
    10
    Views:
    225
    Chad Perrin
    Mar 16, 2007
Loading...

Share This Page