Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)
-   -   Does the last elseif run or not? (http://www.velocityreviews.com/forums/t958023-does-the-last-elseif-run-or-not.html)

fl 02-24-2013 07:39 PM

Does the last elseif run or not?
 
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;

Nicolas Matringe 02-24-2013 08:40 PM

Re: Does the last elseif run or not?
 
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


rickman 02-24-2013 09:49 PM

Re: Does the last elseif run or not?
 
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

fl 02-24-2013 10:14 PM

Re: Does the last elseif run or not?
 
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,

Andy 02-25-2013 06:41 PM

Re: Does the last elseif run or not?
 
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

Reuven 02-27-2013 08:47 PM

Re: Does the last elseif run or not?
 
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.

HT-Lab 02-28-2013 10:28 AM

Re: Does the last elseif run or not?
 
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


All times are GMT. The time now is 12:37 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.