Hi all,
I got some errors when I try to compile the following code:
1
libraryIEEE;
2
useIEEE.std_logic_1164.all;
3
useieee.std_logic_arith.all;
4
useIEEE.std_logic_unsigned.all;
5
6
librarypeb_lib;
7
usepeb_lib.all;
8
9
entityadc_simuis
10
11
port(CLK:instd_logic;
12
MODE:inreal;
13
OF_out:outstd_logic;-- OF pin
14
D:outstd_logic_vector(13downto0)
15
);
16
17
endadc_simu;
18
19
architecturearchiofadc_simuis
20
21
componentadc
22
23
generic(RefH,RefL:real;
24
VDD:real);
25
26
port(Ain_pos:inreal;
27
Ain_neg:inreal;
28
CLK:instd_logic;
29
MODE:inreal;
30
OF_out:outstd_logic;-- OF pin
31
D:outstd_logic_vector(13downto0)
32
);
33
34
endcomponent;
35
36
componentsquare_generator
37
38
generic(LOW:real;
39
HIGH:real);
40
41
port(wave:outreal);
42
43
endcomponent;
44
45
componenttriangle_generator
46
47
generic(AMP:real;
48
OFFSET:real;
49
FREQ:real;
50
PHASE:real);
51
52
port(wave:outreal);
53
54
endcomponent;
55
56
componentsinus_generator
57
58
generic(AMP:real;
59
OFFSET:real;
60
FREQ:real;
61
PHASE:real);
62
63
port(sinus:outreal);
64
65
endcomponent;
66
67
componentsawtooth_generator
68
69
generic(AMP:real;
70
OFFSET:real;
71
FREQ:real;
72
PHASE:real);
73
74
port(sawtooth:outreal);
75
76
endcomponent;
77
78
signalplus:real;
79
signalmoins:real;
80
81
typewaveformis(sinus,triangle,sawtooth,square);
82
83
signalwave_type:waveform:=sinus;
84
85
begin
86
87
TRI:ifwave_type=trianglegenerate
88
Vplus:triangle_generator
89
genericmap(AMP=>1.0,
90
OFFSET=>1.5,
91
FREQ=>100000.0,
92
PHASE=>0.0)
93
94
portmap(plus);
95
96
Vmoins:triangle_generator
97
genericmap(AMP=>1.0,
98
OFFSET=>1.5,
99
FREQ=>100000.0,
100
PHASE=>180.0)
101
102
portmap(moins);
103
104
endgenerateTRI;
105
106
SQ:ifwave_type=squaregenerate
107
Vplus:square_generator
108
genericmap(LOW=>1.0,
109
HIGH=>0.000122)
110
111
portmap(plus);
112
113
Vmoins:square_generator
114
genericmap(LOW=>0.000122,
115
HIGH=>0.000244)
116
117
portmap(moins);
118
119
endgenerateSQ;
120
121
SIN:ifwave_type=sinusgenerate
122
Vplus:sinus_generator
123
genericmap(AMP=>1.0,
124
OFFSET=>1.5,
125
FREQ=>10000000.0,
126
PHASE=>0.0)
127
128
portmap(plus);
129
130
Vmoins:sinus_generator
131
genericmap(AMP=>1.0,
132
OFFSET=>1.5,
133
FREQ=>10000000.0,
134
PHASE=>180.0)
135
136
portmap(moins);
137
138
endgenerateSIN;
139
140
SAW:ifwave_type=sawtoothgenerate
141
Vplus:sawtooth_generator
142
genericmap(AMP=>3.3,
143
OFFSET=>1.65,
144
FREQ=>10000000.0,
145
PHASE=>0.0)
146
147
portmap(plus);
148
149
Vmoins:sawtooth_generator
150
genericmap(AMP=>3.3,
151
OFFSET=>1.65,
152
FREQ=>10000000.0,
153
PHASE=>180.0)
154
155
portmap(moins);
156
157
endgenerateSAW;
158
159
CAN:adcgenericmap(RefH=>1.0,RefL=>-1.0,VDD=>3.3)
160
161
portmap(plus,moins,CLK,MODE,OF_out,D);
162
163
endarchi;
Errors are:
../RTL/adc_simu.vhdl:
TRI: if wave_type = triangle generate
|
ncvhdl_p: *E,ILSGRD (../RTL/adc_simu.vhdl,92|18): illegal reference of a
signal (WAVE_TYPE) during static elaboration [12.3].
SQ: if wave_type = square generate
|
ncvhdl_p: *E,ILSGRD (../RTL/adc_simu.vhdl,102|17): illegal reference of
a signal (WAVE_TYPE) during static elaboration [12.3].
SIN: if wave_type = sinus generate
|
ncvhdl_p: *E,ILSGRD (../RTL/adc_simu.vhdl,112|18): illegal reference of
a signal (WAVE_TYPE) during static elaboration [12.3].
SAW: if wave_type = sawtooth generate
|
ncvhdl_p: *E,ILSGRD (../RTL/adc_simu.vhdl,122|18): illegal reference of
a signal (WAVE_TYPE) during static elaboration [12.3].
Can you tell me what is wrong in my code please!
bob wrote:> type waveform is (sinus, triangle, sawtooth, square);>> signal wave_type: waveform := sinus;
For the condition in your "if...generate" construct you have to use a
generic or a constant, because both are static values when you are doing
a synthesis or the simulator compiles your sources.
bob wrote:> ncvhdl_p: *E,ILSGRD (../RTL/adc_simu.vhdl,122|18): illegal reference of> a signal (WAVE_TYPE) during static elaboration [12.3].
Read: "You are giving me a signal to decide what I should do, but a
signal is some thing dynamic and I have to do a static (permanent)
decision."
bob wrote:> So, if I understand right I have to remplace the type waveform by a> integer or generic type in the condition?
No. You don't have to replace the type. You can use any type and all the
types you created yourself.
bob wrote:> signal wave_type: waveform := sinus;
You have to chance wave_type, you can't use a signal here. You have to
use a generic (defined in the entity) or in this case simply replace the
word "signal" with "constant".
bob wrote:> So, if I understand right I have to remplace the type waveform by a> integer or generic type in the condition?
You understood him wrong. I'm not sure if it works, but try this:
1
constantwave_type:waveform:=sinus;
Or try a generic (but then you will have to define a package with your
data type and include that in your entity)...