![]() |
|
|
|
#1 |
|
how can a component perform a self-check on its generic map at
instanciation? for example entity mycomp is generic( param1 : integer := 1; param2 : integer := 2); ..... architecture... .... begin... .... let's say, I want to be sure that param2 is greater than param1 and detect this assertion? "assert" does the job too late. Stephane |
|
|
|
|
#2 |
|
Posts: n/a
|
On Jun 8, 5:59 am, Stephane <steph...@nospam.fr> wrote:
> how can a component perform a self-check on its generic map at > instanciation? > > for example > > entity mycomp is > generic( > param1 : integer := 1; > param2 : integer := 2); > .... > architecture... > ... > begin... > ... > > let's say, I want to be sure that param2 is greater than param1 and > detect this assertion? "assert" does the job too late. Some tools (nc-sim) will try assertions on constant (including generic) expressions during elaboration. Most tools would trip out during compilation/elaboration if you had a declaration that was out of bounds: constant test_param1 : integer range 0 to param2 - 1 := param1; Or more generally, maybe something like: subtype test_t is boolean range true to true; -- is this legal? constant test1: test_t := testfunc1(generic1); Andy Andy |
|
|
|
#3 |
|
Posts: n/a
|
> Some tools (nc-sim) will try assertions on constant (including > generic) expressions during elaboration. > > Most tools would trip out during compilation/elaboration if you had a > declaration that was out of bounds: > > constant test_param1 : integer range 0 to param2 - 1 := param1; > > Or more generally, maybe something like: > > subtype test_t is boolean range true to true; -- is this legal? absolutely: ** Fatal: (vsim-3421) Value 0 is out of range 1 to 1. thank you for your solution; it matches my need! It is true that the problem would have appeared later at elaboration, but it is far easier to have the line of an assertion to correct the bug quickly. Plus, the assertions at the beginning of architecture are almost part of the specification... Stephane |
|
|
|
#4 |
|
Posts: n/a
|
On Jun 8, 10:23 am, Stephane <steph...@nospam.fr> wrote:
> > Some tools (nc-sim) will try assertions on constant (including > > generic) expressions during elaboration. > > > Most tools would trip out during compilation/elaboration if you had a > > declaration that was out of bounds: > > > constant test_param1 : integer range 0 to param2 - 1 := param1; > > > Or more generally, maybe something like: > > > subtype test_t is boolean range true to true; -- is this legal? > > absolutely: > > ** Fatal: (vsim-3421) Value 0 is out of range 1 to 1. > > thank you for your solution; it matches my need! > > It is true that the problem would have appeared later at elaboration, > but it is far easier to have the line of an assertion to correct the bug > quickly. > Plus, the assertions at the beginning of architecture are almost part of > the specification... If the types do not match that can be caught by the simulator. Say if you declare a positive parameter and assign 0 or negative to it, elaboration would stop with an error. One way to check for valid range, is to put assertions in your entity declaration as follows: entity mycomp is generic( param1 : integer := 1; param2 : integer := 2 ); port ( ); -- ----------------------- -- translate_off begin assert( 1 < param1 and param1 < 5 ) report "param1 can should be in range [2..4]!" severity ERROR; -- translate_on end entity mycomp; architecture ??? of mycomp is begin end architecture ???; Not that not all synthesis tools like to see begin before the entity end statement. So, you need to put translate off/on pragmas around it. -- Amal Amal |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Obatin MCSE,CCNA,CCNP,ORACLE,JAVA And Many More Certs WithoutExams..Pay After Check Results..100% Passing Gaurantee | certexpert | MCTS | 0 | 01-16-2009 12:41 PM |
| Obatin MCSE,CCNA,CCNP,ORACLE,JAVA And Many More Certs WithoutExams..Pay After Check Results..100% Passing Gaurantee | EXAMSATHOME | MCITP | 0 | 12-26-2008 09:10 AM |
| 100% Pass Without Exams Microsoft,Cisco,Comptia,Oracle,Sun,Java,CwnpAnd Many More( Pay After Check Results) | ExamsAtHome | MCITP | 0 | 12-07-2008 10:56 AM |
| 100% Pass Without Exams Microsoft,Cisco,Comptia,Oracle,Sun,Java,CwnpAnd Many More( Pay After Check Results) | EXAMSATHOME | A+ Certification | 0 | 11-23-2008 06:17 PM |
| Obtain Mcse,Ccna,Ccnp Without Exams( Pay After Check Results) 100%Passing Gaurantee | Scr | MCTS | 0 | 06-19-2008 08:50 AM |