1 | #include "Behavioural/include/Usage.h" |
---|
2 | #include "Common/include/Debug.h" |
---|
3 | #include "Common/include/ErrorMorpheo.h" |
---|
4 | |
---|
5 | namespace morpheo { |
---|
6 | namespace behavioural { |
---|
7 | |
---|
8 | #ifdef MODELSIM_COSIMULATION |
---|
9 | Tusage_t usage_cosimulation(Tusage_t usage) |
---|
10 | { |
---|
11 | Tusage_t _return = usage; |
---|
12 | // _return = usage_unset(_return,USE_SYSTEMC ); |
---|
13 | _return = usage_unset(_return,USE_SYSTEMC_INTERFACE ); |
---|
14 | _return = usage_unset(_return,USE_SYSTEMC_BODY ); |
---|
15 | _return = usage_unset(_return,USE_VHDL ); |
---|
16 | _return = usage_unset(_return,USE_VHDL_TESTBENCH ); |
---|
17 | _return = usage_unset(_return,USE_VHDL_TESTBENCH_ASSERT); |
---|
18 | // _return = usage_unset(_return,USE_POSITION ); |
---|
19 | _return = usage_unset(_return,USE_STATISTICS ); |
---|
20 | // _return = usage_unset(_return,USE_INFORMATION ); |
---|
21 | // _return = usage_unset(_return,USE_HEADER ); |
---|
22 | _return = usage_set (_return,USE_COSIMULATION ); |
---|
23 | |
---|
24 | return _return; |
---|
25 | } |
---|
26 | #endif |
---|
27 | |
---|
28 | Tusage_t usage_set (Tusage_t usage, Tusage_t flag) |
---|
29 | { |
---|
30 | return ( usage | flag); |
---|
31 | } |
---|
32 | |
---|
33 | Tusage_t usage_unset (Tusage_t usage, Tusage_t flag) |
---|
34 | { |
---|
35 | return ~(~usage | flag); |
---|
36 | } |
---|
37 | |
---|
38 | bool usage_is_set (Tusage_t usage, Tusage_t flag) |
---|
39 | { |
---|
40 | return ((usage & flag) != 0); |
---|
41 | } |
---|
42 | #undef FUNCTION |
---|
43 | #define FUNCTION "usage_environment" |
---|
44 | Tusage_t usage_environment (Tusage_t usage) |
---|
45 | { |
---|
46 | #ifndef SYSTEMC |
---|
47 | if (usage_is_set(usage,USE_SYSTEMC_INTERFACE)) |
---|
48 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_SYSTEMC_INTERFACE\", but the macro's compiler \"SYSTEMC\" is unset.\n")); |
---|
49 | if (usage_is_set(usage,USE_SYSTEMC_BODY)) |
---|
50 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_SYSTEMC_BODY\", but the macro's compiler \"SYSTEMC\" is unset.\n")); |
---|
51 | #endif |
---|
52 | #ifndef VHDL |
---|
53 | if (usage_is_set(usage,USE_VHDL)) |
---|
54 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_VHDL\", but the macro's compiler \"VHDL\" is unset.\n")); |
---|
55 | #endif |
---|
56 | #ifndef VHDL_TESTBENCH |
---|
57 | if (usage_is_set(usage,USE_VHDL_TESTBENCH)) |
---|
58 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_VHDL_TESTBENCH\", but the macro's compiler \"VHDL_TESTBENCH\" is unset.\n")); |
---|
59 | #endif |
---|
60 | #ifndef VHDL_TESTBENCH_ASSERT |
---|
61 | if (usage_is_set(usage,USE_VHDL_TESTBENCH_ASSERT)) |
---|
62 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_VHDL_TESTBENCH_ASSERT\", but the macro's compiler \"VHDL_TESTBENCH_ASSERT\" is unset.\n")); |
---|
63 | #endif |
---|
64 | #ifndef POSITION |
---|
65 | if (usage_is_set(usage,USE_POSITION)) |
---|
66 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_POSITION\", but the macro's compiler \"POSITION\" is unset.\n")); |
---|
67 | #endif |
---|
68 | #ifndef STATISTICS |
---|
69 | if (usage_is_set(usage,USE_STATISTICS)) |
---|
70 | throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_STATISTICS\", but the macro's compiler \"STATISTICS\" is unset.\n")); |
---|
71 | #endif |
---|
72 | // #ifndef INFORMATION |
---|
73 | // if (usage_is_set(usage,USE_INFORMATION)) |
---|
74 | // throw ERRORMORPHEO(FUNCTION,_("Component use the flag \"USE_INFORMATION\", but the macro's compiler \"INFORMATION\" is unset.\n")); |
---|
75 | // #endif |
---|
76 | |
---|
77 | #ifndef DEBUG |
---|
78 | #endif |
---|
79 | |
---|
80 | if (usage_is_set(usage,USE_STATISTICS) and not usage_is_set(usage,USE_SYSTEMC_BODY)) |
---|
81 | throw ERRORMORPHEO(FUNCTION,_("Usage flags conflit : to use the statistics, you must set flag USE_SYSTEMC_BODY\n")); |
---|
82 | |
---|
83 | // if (usage_is_set(usage,USE_INFORMATION) and not usage_is_set(usage,USE_STATISTICS)) |
---|
84 | // throw ERRORMORPHEO(FUNCTION,_("Usage flags conflit : to use the information, you must set flag USE_STATISTICS\n")); |
---|
85 | |
---|
86 | if (usage_is_set(usage,USE_VHDL_TESTBENCH) and not usage_is_set(usage,USE_SYSTEMC_BODY)) |
---|
87 | throw ERRORMORPHEO(FUNCTION,_("Usage flags conflit : to use the vhdl's test bench, you must set flag USE_SYSTEMC_BODY\n")); |
---|
88 | |
---|
89 | if (usage_is_set(usage,USE_VHDL_TESTBENCH) and not usage_is_set(usage,USE_VHDL)) |
---|
90 | throw ERRORMORPHEO(FUNCTION,_("Usage flags conflit : to use the vhdl's test bench, you must set flag USE_VHDL\n")); |
---|
91 | |
---|
92 | if (usage_is_set(usage,USE_VHDL_TESTBENCH_ASSERT) and not usage_is_set(usage,USE_VHDL_TESTBENCH)) |
---|
93 | throw ERRORMORPHEO(FUNCTION,_("Usage flags conflit : to use an assert in vhdl's test bench, you must set flag USE_VHDL_TESTBENCH\n")); |
---|
94 | |
---|
95 | return usage; |
---|
96 | } |
---|
97 | |
---|
98 | Tusage_t usage_all (void) |
---|
99 | { |
---|
100 | Tusage_t usage = USE_NONE; |
---|
101 | |
---|
102 | #ifdef SYSTEMC |
---|
103 | usage = usage_set(usage,USE_SYSTEMC_INTERFACE); |
---|
104 | usage = usage_set(usage,USE_SYSTEMC_BODY); |
---|
105 | #endif |
---|
106 | #ifdef VHDL |
---|
107 | usage = usage_set(usage,USE_VHDL); |
---|
108 | #endif |
---|
109 | #ifdef VHDL_TESTBENCH |
---|
110 | usage = usage_set(usage,USE_VHDL_TESTBENCH); |
---|
111 | #endif |
---|
112 | #ifdef VHDL_TESTBENCH_ASSERT |
---|
113 | usage = usage_set(usage,USE_VHDL_TESTBENCH_ASSERT); |
---|
114 | #endif |
---|
115 | #ifdef POSITION |
---|
116 | usage = usage_set(usage,USE_POSITION); |
---|
117 | #endif |
---|
118 | #ifdef STATISTICS |
---|
119 | usage = usage_set(usage,USE_STATISTICS); |
---|
120 | #endif |
---|
121 | // #ifdef INFORMATION |
---|
122 | // usage = usage_set(usage,USE_INFORMATION); |
---|
123 | // #endif |
---|
124 | usage = usage_set(usage,USE_HEADER); |
---|
125 | #ifdef DEBUG |
---|
126 | #endif |
---|
127 | |
---|
128 | return usage; |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | }; // end namespace behavioural |
---|
133 | }; // end namespace morpheo |
---|