Blame view

Examples/ChirpSignalGenerator/Models/ChirpSignalGenerator.vhd 4.38 KB
f902ce56c   Jean-Marie Gauthier   Commit of projects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  
  library IEEE;
  use IEEE.electrical_systems.all;
  use IEEE.math_real.all;
  
  
  ---------------- ENTITY DECLARATION VSIGNAL ----------------
  ENTITY VSIGNAL IS
  	GENERIC(
  		ti : time;
  		td : time
  	);
  	PORT(
  		SIGNAL v_signal : OUT real
  	);
  END ENTITY VSIGNAL;
  
  ---------------- ARCHITECTURE DECLARATION behav OF VSIGNAL ----------------
  ARCHITECTURE behav OF VSIGNAL IS
  	
  
  BEGIN
  	
  	
  	
  	v_signal <= 0.0 AFTER 0.0ms, 1.0 AFTER ti, 0.0 AFTER ti+td;
  	
  END ARCHITECTURE behav;
  
  
  library IEEE;
  use IEEE.electrical_systems.all;
  use IEEE.math_real.all;
  
  
  ---------------- ENTITY DECLARATION Resistor ----------------
  ENTITY Resistor IS
  	GENERIC(
  		res : real
  	);
  	PORT(
  		TERMINAL m : Electrical;
  		TERMINAL p : Electrical
  	);
  END ENTITY Resistor;
  
  ---------------- ARCHITECTURE DECLARATION behav OF Resistor ----------------
  ARCHITECTURE behav OF Resistor IS
  	QUANTITY v_in ACROSS i_out THROUGH p TO m;
  	
  
  BEGIN
  	
  	
  	
  	v_in == res * i_out;
  	
  END ARCHITECTURE behav;
  
  
  library IEEE;
  use IEEE.electrical_systems.all;
  use IEEE.math_real.all;
  
  
  ---------------- ENTITY DECLARATION VCVsin ----------------
  ENTITY VCVsin IS
  	
  	PORT(
  		TERMINAL m : Electrical;
  		TERMINAL p : Electrical;
  		TERMINAL f : Electrical;
  		TERMINAL a : Electrical
  	);
  END ENTITY VCVsin;
  
  ---------------- ARCHITECTURE DECLARATION behav OF VCVsin ----------------
  ARCHITECTURE behav OF VCVsin IS
  	CONSTANT twoPi : real := 6.283118530718;
  	QUANTITY v_in ACROSS i_out THROUGH p TO m;
  	QUANTITY v_f ACROSS f TO m;
  	QUANTITY v_a ACROSS a TO m;
  	
  
  BEGIN
  	
  	
  	
  	v_in == v_a * sin (twoPi * v_f * now);
  	
  END ARCHITECTURE behav;
  
  
  library IEEE;
  use IEEE.electrical_systems.all;
  use IEEE.math_real.all;
  
  library work;
  use work.ALL;
  ---------------- ENTITY DECLARATION RampSource ----------------
  ENTITY RampSource IS
  	GENERIC(
  		v1 : real := 0.0;
  		v2 : real := 1.0;
  		intT : real := 1.0;
  		ti : real;
  		td : real
  	);
  	PORT(
  		TERMINAL m : Electrical;
  		TERMINAL p : Electrical
  	);
  END ENTITY RampSource;
  
  ---------------- ARCHITECTURE DECLARATION behav OF RampSource ----------------
  ARCHITECTURE behav OF RampSource IS
  	
  	FUNCTION real2time(tt : real) RETURN time IS
  	BEGIN
  		return real(tt * 1.0e15) * 1 fs;
  	END real2time;
  	QUANTITY v_in ACROSS i_out THROUGH p TO m;
  	QUANTITY vdot : real;
  	
  	SIGNAL v_signal :  real;
  
  BEGIN
  	
  	Vsig : ENTITY VSIGNAL (behav) 
  			GENERIC MAP (ti=>real2time(ti), td=>real2time(td))
  			PORT MAP (v_signal=>v_signal);
  	
  	
  	vdot'dot == v_signal / intT * (v2 - v1);
  	
  	v_in == v_signal * (vdot + v1);
  	
  END ARCHITECTURE behav;
  
  
  library IEEE;
  use IEEE.electrical_systems.all;
  use IEEE.math_real.all;
  
  library work;
  use work.ALL;
  ---------------- ENTITY DECLARATION PolySource2 ----------------
  ENTITY PolySource2 IS
  	GENERIC(
  		ti : real;
  		td : real;
  		a : real;
  		b : real;
  		c : real
  	);
  	PORT(
  		TERMINAL m : Electrical;
  		TERMINAL p : Electrical
  	);
  END ENTITY PolySource2;
  
  ---------------- ARCHITECTURE DECLARATION behav OF PolySource2 ----------------
  ARCHITECTURE behav OF PolySource2 IS
  	
  	FUNCTION real2time(tt : real) RETURN time IS
  	BEGIN
  		return real(tt * 1.0e15) * 1 fs;
  	END real2time;
  	QUANTITY v_in ACROSS i_out THROUGH p TO m;
  	QUANTITY vdot : real;
  	QUANTITY tt : real;
  	
  	SIGNAL v_signal :  real;
  
  BEGIN
  	
  	Vsig : ENTITY VSIGNAL (behav) 
  			GENERIC MAP (ti=>real2time(ti), td=>real2time(td))
  			PORT MAP (v_signal=>v_signal);
  	
  	
  	vdot'dot == v_signal / td;
  	
  	tt == td * vdot + ti;
  	
  	v_in == v_signal * (a * tt * tt + b * tt + c);
  	
  END ARCHITECTURE behav;
  
  
  library IEEE;
  use IEEE.electrical_systems.all;
  use IEEE.math_real.all;
  
  library work;
  use work.ALL;
  ---------------- ENTITY DECLARATION Vchirp ----------------
  ENTITY Vchirp IS
  	GENERIC(
  		a1 : real := 1.0;
  		a2 : real := 2.0;
  		f1 : real := 50.0e6;
  		f2 : real := 100.0e6;
  		ti : real := 200.0;
  		tau : real := 1.0
  	);
  	
  END ENTITY Vchirp;
  
  ---------------- ARCHITECTURE DECLARATION behav OF Vchirp ----------------
  ARCHITECTURE behav OF Vchirp IS
  	
  	TERMINAL nout : Electrical;
  	TERMINAL nf : Electrical;
  	TERMINAL na : Electrical;
  
  BEGIN
  	
  	R1 : ENTITY Resistor (behav) 
  			GENERIC MAP (res=>100.0e3)
  			PORT MAP (p=>nout, m=>ground);
  	Src : ENTITY VCVsin (behav) 
  			PORT MAP (m=>ground, a=>na, f=>nf, p=>nout);
  	dcf : ENTITY PolySource2 (behav) 
  			GENERIC MAP (ti=>ti, td=>tau, a=>0.0, b=>(f2 - f1)/tau, c=>(f1*(ti+tau)-f2*ti)/tau)
  			PORT MAP (m=>ground, p=>nf);
  	DCA : ENTITY RampSource (behav) 
  			GENERIC MAP (td=>tau, ti=>ti, v2=>a2, v1=>a1, intT=>tau)
  			PORT MAP (m=>ground, p=>na);
  	
  	
  END ARCHITECTURE behav;