source: PlatformSupport/Deprecated/pcores/radio_controller_v1_05_a/hdl/verilog/user_logic.v

Last change on this file was 388, checked in by murphpo, 18 years ago

Updated 1.05 controller and bridge

File size: 33.5 KB
Line 
1/* Copyright (c) 2006 Rice University */
2/* All Rights Reserved */
3/* This code is covered by the Rice-WARP license */
4/* See http://warp.rice.edu/license/ for details */
5
6module user_logic
7(
8    spi_clk,
9    data_out,
10    Radio1_cs,
11    Radio2_cs,
12    Radio3_cs,
13    Radio4_cs,
14    Dac1_cs,
15    Dac2_cs,
16    Dac3_cs,
17    Dac4_cs,
18    Radio1_SHDN,
19    Radio1_TxEn,
20    Radio1_RxEn,
21    Radio1_RxHP,
22    Radio1_LD,
23    Radio1_24PA,
24    Radio1_5PA,
25    Radio1_ANTSW,
26    Radio1_LED,
27    Radio1_ADC_RX_DCS,
28    Radio1_ADC_RX_DFS,
29    Radio1_ADC_RX_OTRA,
30    Radio1_ADC_RX_OTRB,
31    Radio1_ADC_RX_PWDNA,
32    Radio1_ADC_RX_PWDNB,
33    Radio1_DIPSW,
34    Radio1_RSSI_ADC_CLAMP,
35    Radio1_RSSI_ADC_HIZ,
36    Radio1_RSSI_ADC_OTR,
37    Radio1_RSSI_ADC_SLEEP,
38    Radio1_RSSI_ADC_D,
39    Radio1_TX_DAC_PLL_LOCK,
40    Radio1_TX_DAC_RESET,
41    Radio1_RxHP_external,
42    Radio1_TxGain, 
43    Radio1_TxStart,
44    Radio2_SHDN,
45    Radio2_TxEn,
46    Radio2_RxEn,
47    Radio2_RxHP,
48    Radio2_LD,
49    Radio2_24PA,
50    Radio2_5PA,
51    Radio2_ANTSW,
52    Radio2_LED,
53    Radio2_ADC_RX_DCS,
54    Radio2_ADC_RX_DFS,
55    Radio2_ADC_RX_OTRA,
56    Radio2_ADC_RX_OTRB,
57    Radio2_ADC_RX_PWDNA,
58    Radio2_ADC_RX_PWDNB,
59    Radio2_DIPSW,
60    Radio2_RSSI_ADC_CLAMP,
61    Radio2_RSSI_ADC_HIZ,
62    Radio2_RSSI_ADC_OTR,
63    Radio2_RSSI_ADC_SLEEP,
64    Radio2_RSSI_ADC_D,
65    Radio2_TX_DAC_PLL_LOCK,
66    Radio2_TX_DAC_RESET,
67    Radio2_RxHP_external,
68    Radio2_TxGain, 
69    Radio2_TxStart,
70    Radio3_SHDN,
71    Radio3_TxEn,
72    Radio3_RxEn,
73    Radio3_RxHP,
74    Radio3_LD,
75    Radio3_24PA,
76    Radio3_5PA,
77    Radio3_ANTSW,
78    Radio3_LED,
79    Radio3_ADC_RX_DCS,
80    Radio3_ADC_RX_DFS,
81    Radio3_ADC_RX_OTRA,
82    Radio3_ADC_RX_OTRB,
83    Radio3_ADC_RX_PWDNA,
84    Radio3_ADC_RX_PWDNB,
85    Radio3_DIPSW,
86    Radio3_RSSI_ADC_CLAMP,
87    Radio3_RSSI_ADC_HIZ,
88    Radio3_RSSI_ADC_OTR,
89    Radio3_RSSI_ADC_SLEEP,
90    Radio3_RSSI_ADC_D,
91    Radio3_TX_DAC_PLL_LOCK,
92    Radio3_TX_DAC_RESET,
93    Radio3_RxHP_external,
94    Radio3_TxGain,
95    Radio3_TxStart,
96    Radio4_SHDN,
97    Radio4_TxEn,
98    Radio4_RxEn,
99    Radio4_RxHP,
100    Radio4_LD,
101    Radio4_24PA,
102    Radio4_5PA,
103    Radio4_ANTSW,
104    Radio4_LED,
105    Radio4_ADC_RX_DCS,
106    Radio4_ADC_RX_DFS,
107    Radio4_ADC_RX_OTRA,
108    Radio4_ADC_RX_OTRB,
109    Radio4_ADC_RX_PWDNA,
110    Radio4_ADC_RX_PWDNB,
111    Radio4_DIPSW,
112    Radio4_RSSI_ADC_CLAMP,
113    Radio4_RSSI_ADC_HIZ,
114    Radio4_RSSI_ADC_OTR,
115    Radio4_RSSI_ADC_SLEEP,
116    Radio4_RSSI_ADC_D,
117    Radio4_TX_DAC_PLL_LOCK,
118    Radio4_TX_DAC_RESET,
119    Radio4_RxHP_external,
120    Radio4_TxGain, 
121    Radio4_TxStart,
122
123    // -- DO NOT EDIT BELOW THIS LINE ------------------
124    // -- Bus protocol ports, do not add to or delete
125    Bus2IP_Clk,                     // Bus to IP clock
126    Bus2IP_Reset,                   // Bus to IP reset
127    Bus2IP_Data,                    // Bus to IP data bus for user logic
128    Bus2IP_BE,                      // Bus to IP byte enables for user logic
129    Bus2IP_RdCE,                    // Bus to IP read chip enable for user logic
130    Bus2IP_WrCE,                    // Bus to IP write chip enable for user logic
131    IP2Bus_Data,                    // IP to Bus data bus for user logic
132    IP2Bus_Ack,                     // IP to Bus acknowledgement
133    IP2Bus_Retry,                   // IP to Bus retry response
134    IP2Bus_Error,                   // IP to Bus error response
135    IP2Bus_ToutSup                  // IP to Bus timeout suppress
136    // -- DO NOT EDIT ABOVE THIS LINE ------------------
137);
138
139    // -- DO NOT EDIT BELOW THIS LINE --------------------
140    // -- Bus protocol parameters, do not add to or delete
141    parameter C_DWIDTH                       = 32;
142//  parameter C_NUM_CE                       = 8;
143    parameter C_NUM_CE                       = 16;
144    // -- DO NOT EDIT ABOVE THIS LINE --------------------
145
146    output                spi_clk;
147    output                data_out;
148    output                Radio1_cs;
149    output                Radio2_cs;
150    output                Radio3_cs;
151    output                Radio4_cs;
152    output                Dac1_cs;
153    output                Dac2_cs;
154    output                Dac3_cs;
155    output                Dac4_cs;
156    output                                  Radio1_SHDN;
157    output                                  Radio1_TxEn;
158    output                                  Radio1_RxEn;
159    output                                  Radio1_RxHP;
160    input                                   Radio1_LD;
161    output                                  Radio1_24PA;
162    output                                  Radio1_5PA;
163    output          [0 : 1]                 Radio1_ANTSW;
164    output          [0 : 2]                 Radio1_LED;
165    output                                  Radio1_ADC_RX_DCS;
166    output                                  Radio1_ADC_RX_DFS;
167    input                                   Radio1_ADC_RX_OTRA;
168    input                                   Radio1_ADC_RX_OTRB;
169    output                                  Radio1_ADC_RX_PWDNA;
170    output                                  Radio1_ADC_RX_PWDNB;
171    input           [0 : 3]                 Radio1_DIPSW;
172    output                                  Radio1_RSSI_ADC_CLAMP;
173    output                                  Radio1_RSSI_ADC_HIZ;
174    input                                   Radio1_RSSI_ADC_OTR;
175    output                                  Radio1_RSSI_ADC_SLEEP;
176    input           [0 : 9]                 Radio1_RSSI_ADC_D;
177    input                                   Radio1_TX_DAC_PLL_LOCK;
178    output                                  Radio1_TX_DAC_RESET;
179    input                                   Radio1_RxHP_external;
180    output          [0:5]                   Radio1_TxGain;
181    output                                  Radio1_TxStart;
182    output                                  Radio2_SHDN;
183    output                                  Radio2_TxEn;
184    output                                  Radio2_RxEn;
185    output                                  Radio2_RxHP;
186    input                                   Radio2_LD;
187    output                                  Radio2_24PA;
188    output                                  Radio2_5PA;
189    output          [0 : 1]                 Radio2_ANTSW;
190    output          [0 : 2]                 Radio2_LED;
191    output                                  Radio2_ADC_RX_DCS;
192    output                                  Radio2_ADC_RX_DFS;
193    input                                   Radio2_ADC_RX_OTRA;
194    input                                   Radio2_ADC_RX_OTRB;
195    output                                  Radio2_ADC_RX_PWDNA;
196    output                                  Radio2_ADC_RX_PWDNB;
197    input           [0 : 3]                 Radio2_DIPSW;
198    output                                  Radio2_RSSI_ADC_CLAMP;
199    output                                  Radio2_RSSI_ADC_HIZ;
200    input                                   Radio2_RSSI_ADC_OTR;
201    output                                  Radio2_RSSI_ADC_SLEEP;
202    input           [0 : 9]                 Radio2_RSSI_ADC_D;
203    input                                   Radio2_TX_DAC_PLL_LOCK;
204    output                                  Radio2_TX_DAC_RESET;
205    input                                   Radio2_RxHP_external;
206    output          [0:5]                   Radio2_TxGain;
207    output                                  Radio2_TxStart;
208    output                                  Radio3_SHDN;
209    output                                  Radio3_TxEn;
210    output                                  Radio3_RxEn;
211    output                                  Radio3_RxHP;
212    input                                   Radio3_LD;
213    output                                  Radio3_24PA;
214    output                                  Radio3_5PA;
215    output          [0 : 1]                 Radio3_ANTSW;
216    output          [0 : 2]                 Radio3_LED;
217    output                                  Radio3_ADC_RX_DCS;
218    output                                  Radio3_ADC_RX_DFS;
219    input                                   Radio3_ADC_RX_OTRA;
220    input                                   Radio3_ADC_RX_OTRB;
221    output                                  Radio3_ADC_RX_PWDNA;
222    output                                  Radio3_ADC_RX_PWDNB;
223    input           [0 : 3]                 Radio3_DIPSW;
224    output                                  Radio3_RSSI_ADC_CLAMP;
225    output                                  Radio3_RSSI_ADC_HIZ;
226    input                                   Radio3_RSSI_ADC_OTR;
227    output                                  Radio3_RSSI_ADC_SLEEP;
228    input           [0 : 9]                 Radio3_RSSI_ADC_D;
229    input                                   Radio3_TX_DAC_PLL_LOCK;
230    output                                  Radio3_TX_DAC_RESET;
231    input                                   Radio3_RxHP_external;
232    output          [0:5]                   Radio3_TxGain;
233    output                                  Radio3_TxStart;
234    output                                  Radio4_SHDN;
235    output                                  Radio4_TxEn;
236    output                                  Radio4_RxEn;
237    output                                  Radio4_RxHP;
238    input                                   Radio4_LD;
239    output                                  Radio4_24PA;
240    output                                  Radio4_5PA;
241    output          [0 : 1]                 Radio4_ANTSW;
242    output          [0 : 2]                 Radio4_LED;
243    output                                  Radio4_ADC_RX_DCS;
244    output                                  Radio4_ADC_RX_DFS;
245    input                                   Radio4_ADC_RX_OTRA;
246    input                                   Radio4_ADC_RX_OTRB;
247    output                                  Radio4_ADC_RX_PWDNA;
248    output                                  Radio4_ADC_RX_PWDNB;
249    input           [0 : 3]                 Radio4_DIPSW;
250    output                                  Radio4_RSSI_ADC_CLAMP;
251    output                                  Radio4_RSSI_ADC_HIZ;
252    input                                   Radio4_RSSI_ADC_OTR;
253    output                                  Radio4_RSSI_ADC_SLEEP;
254    input           [0 : 9]                 Radio4_RSSI_ADC_D;
255    input                                   Radio4_TX_DAC_PLL_LOCK;
256    output                                  Radio4_TX_DAC_RESET;
257    input                                   Radio4_RxHP_external;
258    output          [0:5]                   Radio4_TxGain;
259    output                                  Radio4_TxStart;
260
261// -- DO NOT EDIT BELOW THIS LINE --------------------
262// -- Bus protocol ports, do not add to or delete
263input                                     Bus2IP_Clk;
264input                                     Bus2IP_Reset;
265input      [0 : C_DWIDTH-1]               Bus2IP_Data;
266input      [0 : C_DWIDTH/8-1]             Bus2IP_BE;
267input      [0 : C_NUM_CE-1]               Bus2IP_RdCE;
268input      [0 : C_NUM_CE-1]               Bus2IP_WrCE;
269output     [0 : C_DWIDTH-1]               IP2Bus_Data;
270output                                    IP2Bus_Ack;
271output                                    IP2Bus_Retry;
272output                                    IP2Bus_Error;
273output                                    IP2Bus_ToutSup;
274// -- DO NOT EDIT ABOVE THIS LINE --------------------
275
276//----------------------------------------------------------------------------
277// Implementation
278//----------------------------------------------------------------------------
279
280    reg        [0 : C_DWIDTH-1]               slv_reg0;
281    reg        [0 : C_DWIDTH-1]               slv_reg1;
282    reg        [0 : C_DWIDTH-1]               slv_reg2;
283    reg        [0 : C_DWIDTH-1]               slv_reg3;
284    reg        [0 : C_DWIDTH-1]               slv_reg4;
285    reg        [0 : C_DWIDTH-1]               slv_reg5;
286    reg        [0 : C_DWIDTH-1]               slv_reg6;
287    reg        [0 : C_DWIDTH-1]               slv_reg7;
288    reg        [0 : C_DWIDTH-1]               slv_reg8;
289    reg        [0 : C_DWIDTH-1]               slv_reg9;
290    reg        [0 : C_DWIDTH-1]               slv_reg10;
291    reg        [0 : C_DWIDTH-1]               slv_reg11;
292    reg        [0 : C_DWIDTH-1]               slv_reg12;
293    reg        [0 : C_DWIDTH-1]               slv_reg13;
294    reg        [0 : C_DWIDTH-1]               slv_reg14;
295    reg        [0 : C_DWIDTH-1]               slv_reg15;
296    wire       [0 : 15]                       slv_reg_write_select;
297    wire       [0 : 15]                       slv_reg_read_select;
298    reg        [0 : C_DWIDTH-1]               slv_ip2bus_data;
299    wire                                      slv_read_ack;
300    wire                                      slv_write_ack;
301    integer                                   byte_index, bit_index;
302
303    wire [7:0] ss_pad_o;
304    wire mytip;
305    wire [13:0] reg_ctrl;
306    wire [7:0] reg_ss;
307    wire reg_divider;
308    wire [17:0] reg_tx;
309
310    wire Radio1_PowerAmpEnable, Radio1_swTxEn, Radio1_sw24PAEn, Radio1_sw5PAEn;
311    wire Radio2_PowerAmpEnable, Radio2_swTxEn, Radio2_sw24PAEn, Radio2_sw5PAEn;
312    wire Radio3_PowerAmpEnable, Radio3_swTxEn, Radio3_sw24PAEn, Radio3_sw5PAEn;
313    wire Radio4_PowerAmpEnable, Radio4_swTxEn, Radio4_sw24PAEn, Radio4_sw5PAEn;
314
315    //Internal signals for calculating Tx gains
316    wire [0:5] Radio1_TargetTxGain, Radio2_TargetTxGain, Radio3_TargetTxGain, Radio4_TargetTxGain;
317    wire [0:3] Radio1_TxGainStep, Radio2_TxGainStep, Radio3_TxGainStep, Radio4_TxGainStep;
318    wire [0:3] Radio1_TxGainTimeStep, Radio2_TxGainTimeStep, Radio3_TxGainTimeStep, Radio4_TxGainTimeStep;
319
320    //Internal signals setting delays used to control Tx timing
321    wire [0:7] Radio1_GainRampThresh, Radio1_PAThresh, Radio1_TxEnThresh, Radio1_TxStartThresh;
322    wire [0:7] Radio2_GainRampThresh, Radio2_PAThresh, Radio2_TxEnThresh, Radio2_TxStartThresh;
323    wire [0:7] Radio3_GainRampThresh, Radio3_PAThresh, Radio3_TxEnThresh, Radio3_TxStartThresh;
324    wire [0:7] Radio4_GainRampThresh, Radio4_PAThresh, Radio4_TxEnThresh, Radio4_TxStartThresh;
325
326    assign  Radio1_SHDN = ~slv_reg0[31];
327    assign  Radio1_RxEn = slv_reg0[29];
328
329    assign  Radio1_swTxEn = slv_reg0[30];
330
331    assign  Radio1_RxHP = (slv_reg0[27])?slv_reg0[28]:Radio1_RxHP_external;
332
333    assign  Radio1_sw24PAEn = slv_reg0[26];
334    assign  Radio1_sw5PAEn = slv_reg0[25];
335
336    assign  Radio1_24PA = ~(Radio1_sw24PAEn & Radio1_PowerAmpEnable); //active low output
337    assign  Radio1_5PA = ~(Radio1_sw5PAEn & Radio1_PowerAmpEnable); //active low output
338
339    assign  Radio1_ANTSW[0] = slv_reg0[23];
340    assign  Radio1_ANTSW[1] = slv_reg0[24];
341    assign  Radio1_ADC_RX_DCS = slv_reg0[22];
342    assign  Radio1_LED[0] = ~Radio1_TX_DAC_PLL_LOCK;
343    assign  Radio1_LED[1] = Radio1_TxEn;
344    assign  Radio1_LED[2] = ~Radio1_LD;
345    assign  Radio1_ADC_RX_PWDNA = slv_reg0[18];
346    assign  Radio1_ADC_RX_PWDNB = slv_reg0[17];
347    assign  Radio1_RSSI_ADC_SLEEP = slv_reg0[16];
348    assign  Radio1_TX_DAC_RESET = slv_reg0[10];
349       
350    assign  Radio1_ADC_RX_DFS = 1'b1; //slv_reg0[18];
351    assign  Radio1_RSSI_ADC_CLAMP = 1'b0; //slv_reg0[9];
352    assign  Radio1_RSSI_ADC_HIZ = 1'b0; //slv_reg0[8]; 
353   
354    assign  Radio2_SHDN = ~slv_reg1[31];
355
356    assign  Radio2_swTxEn = slv_reg1[30];
357
358    assign  Radio2_RxEn = slv_reg1[29];
359    assign  Radio2_RxHP = (slv_reg1[27])?slv_reg1[28]:Radio2_RxHP_external;
360
361    assign  Radio2_sw24PAEn = slv_reg1[26];
362    assign  Radio2_sw5PAEn = slv_reg1[25];
363
364    assign  Radio2_24PA = ~(Radio2_sw24PAEn & Radio2_PowerAmpEnable); //active low output
365    assign  Radio2_5PA = ~(Radio2_sw5PAEn & Radio2_PowerAmpEnable); //active low output
366
367    assign  Radio2_ANTSW[0] = slv_reg1[23];
368    assign  Radio2_ANTSW[1] = slv_reg1[24];
369    assign  Radio2_ADC_RX_DCS = slv_reg1[22];
370    assign  Radio2_LED[0] = ~Radio2_TX_DAC_PLL_LOCK;
371    assign  Radio2_LED[1] = Radio2_TxEn;
372    assign  Radio2_LED[2] = ~Radio2_LD;
373    assign  Radio2_ADC_RX_PWDNA = slv_reg1[18];
374    assign  Radio2_ADC_RX_PWDNB = slv_reg1[17];
375    assign  Radio2_RSSI_ADC_SLEEP = slv_reg1[16];
376    assign  Radio2_TX_DAC_RESET = slv_reg1[10];
377       
378    assign  Radio2_ADC_RX_DFS = 1'b1; //slv_reg1[18];
379    assign  Radio2_RSSI_ADC_CLAMP = 1'b0; //slv_reg1[9];
380    assign  Radio2_RSSI_ADC_HIZ = 1'b0; //slv_reg1[8]; 
381
382    assign  Radio3_SHDN = ~slv_reg2[31];
383
384    assign  Radio3_swTxEn = slv_reg2[30];
385
386    assign  Radio3_RxEn = slv_reg2[29];
387    assign  Radio3_RxHP = (slv_reg2[27])?slv_reg2[28]:Radio3_RxHP_external;
388
389    assign  Radio3_sw24PAEn = slv_reg2[26];
390    assign  Radio3_sw5PAEn = slv_reg2[25];
391
392    assign  Radio3_24PA = ~(Radio3_sw24PAEn & Radio3_PowerAmpEnable); //active low output
393    assign  Radio3_5PA = ~(Radio3_sw5PAEn & Radio3_PowerAmpEnable); //active low output
394
395    assign  Radio3_ANTSW[0] = slv_reg2[23];
396    assign  Radio3_ANTSW[1] = slv_reg2[24];
397    assign  Radio3_ADC_RX_DCS = slv_reg2[22];
398    assign  Radio3_LED[0] = ~Radio3_TX_DAC_PLL_LOCK;
399    assign  Radio3_LED[1] = Radio3_TxEn;
400    assign  Radio3_LED[2] = ~Radio3_LD;
401    assign  Radio3_ADC_RX_PWDNA = slv_reg2[18];
402    assign  Radio3_ADC_RX_PWDNB = slv_reg2[17];
403    assign  Radio3_RSSI_ADC_SLEEP = slv_reg2[16];
404    assign  Radio3_TX_DAC_RESET = slv_reg2[10];
405       
406    assign  Radio3_ADC_RX_DFS = 1'b1; //slv_reg2[18];
407    assign  Radio3_RSSI_ADC_CLAMP = 1'b0; //slv_reg2[9];
408    assign  Radio3_RSSI_ADC_HIZ = 1'b0; //slv_reg2[8]; 
409
410    assign  Radio4_SHDN = ~slv_reg3[31];
411
412    assign  Radio4_swTxEn = slv_reg3[30];
413
414    assign  Radio4_RxEn = slv_reg3[29];
415    assign  Radio4_RxHP = (slv_reg3[27])?slv_reg3[28]:Radio4_RxHP_external;
416
417    assign  Radio4_sw24PAEn = slv_reg3[26];
418    assign  Radio4_sw5PAEn = slv_reg3[25];
419
420    assign  Radio4_24PA = ~(Radio4_sw24PAEn & Radio4_PowerAmpEnable); //active low output
421    assign  Radio4_5PA = ~(Radio4_sw5PAEn & Radio4_PowerAmpEnable); //active low output
422
423    assign  Radio4_ANTSW[0] = slv_reg3[23];
424    assign  Radio4_ANTSW[1] = slv_reg3[24];
425    assign  Radio4_ADC_RX_DCS = slv_reg3[22];
426    assign  Radio4_LED[0] = ~Radio4_TX_DAC_PLL_LOCK;
427    assign  Radio4_LED[1] = Radio4_TxEn;
428    assign  Radio4_LED[2] = ~Radio4_LD;
429    assign  Radio4_ADC_RX_PWDNA = slv_reg3[18];
430    assign  Radio4_ADC_RX_PWDNB = slv_reg3[17];
431    assign  Radio4_RSSI_ADC_SLEEP = slv_reg3[16];
432    assign  Radio4_TX_DAC_RESET = slv_reg3[10];
433       
434    assign  Radio4_ADC_RX_DFS = 1'b1; //slv_reg3[18];
435    assign  Radio4_RSSI_ADC_CLAMP = 1'b0; //slv_reg3[9];
436    assign  Radio4_RSSI_ADC_HIZ = 1'b0; //slv_reg3[8]; 
437
438    assign  Radio1_cs = ss_pad_o[0];
439    assign  Radio2_cs = ss_pad_o[1];
440    assign  Radio3_cs = ss_pad_o[2];
441    assign  Radio4_cs = ss_pad_o[3];
442    assign  Dac1_cs = ss_pad_o[4];
443    assign  Dac2_cs = ss_pad_o[5];
444    assign  Dac3_cs = ss_pad_o[6];
445    assign  Dac4_cs = ss_pad_o[7];
446   
447    assign reg_ctrl = slv_reg4[18:31];
448    assign reg_divider = slv_reg5[31];
449    assign reg_ss = slv_reg6[24:31];
450    assign reg_tx = slv_reg7[14:31];
451   
452    assign
453        slv_reg_write_select = Bus2IP_WrCE[0:15],
454        slv_reg_read_select  = Bus2IP_RdCE[0:15],
455        slv_write_ack        = Bus2IP_WrCE[0] || Bus2IP_WrCE[1] || Bus2IP_WrCE[2] || Bus2IP_WrCE[3] || Bus2IP_WrCE[4] || Bus2IP_WrCE[5] || Bus2IP_WrCE[6] || Bus2IP_WrCE[7] || Bus2IP_WrCE[8] || Bus2IP_WrCE[9] || Bus2IP_WrCE[10] || Bus2IP_WrCE[11] || Bus2IP_WrCE[12] || Bus2IP_WrCE[13] || Bus2IP_WrCE[14] || Bus2IP_WrCE[15],
456        slv_read_ack         = Bus2IP_RdCE[0] || Bus2IP_RdCE[1] || Bus2IP_RdCE[2] || Bus2IP_RdCE[3] || Bus2IP_RdCE[4] || Bus2IP_RdCE[5] || Bus2IP_RdCE[6] || Bus2IP_RdCE[7] || Bus2IP_RdCE[8] || Bus2IP_RdCE[9] || Bus2IP_RdCE[10] || Bus2IP_RdCE[11] || Bus2IP_RdCE[12] || Bus2IP_RdCE[13] || Bus2IP_RdCE[14] || Bus2IP_RdCE[15];
457
458    assign IP2Bus_Data        = slv_ip2bus_data;
459    assign IP2Bus_Ack         = slv_write_ack || slv_read_ack;
460    assign IP2Bus_Error       = 0;
461    assign IP2Bus_Retry       = 0;
462    assign IP2Bus_ToutSup     = 0;
463
464    // implement slave model register(s)
465    always @( posedge Bus2IP_Clk )
466    begin: SLAVE_REG_WRITE_PROC
467
468      if ( Bus2IP_Reset == 1 )
469        begin
470          slv_reg0 <= 0;
471          slv_reg1 <= 0;
472          slv_reg2 <= 0;
473          slv_reg3 <= 0;
474          slv_reg4 <= 0;
475          slv_reg5 <= 0;
476          slv_reg6 <= 0;
477          slv_reg7 <= 0;
478          slv_reg8 <= {14'h3fff, 22'h0}; //Gain increment, targets & delays all default to max values
479          slv_reg9 <= {14'h3fff, 22'h0};
480          slv_reg10 <= {14'h3fff, 22'h0};
481          slv_reg11 <= {14'h3fff, 22'h0};
482          slv_reg12 <= 0;
483          slv_reg13 <= 0;
484          slv_reg14 <= 0;
485          slv_reg15 <= 0;
486
487        end
488      else
489        case ( slv_reg_write_select )
490          16'b1000000000000000 :
491            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
492              if ( Bus2IP_BE[byte_index] == 1 )
493                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
494                  slv_reg0[bit_index] <= Bus2IP_Data[bit_index];
495          16'b0100000000000000 :
496            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
497              if ( Bus2IP_BE[byte_index] == 1 )
498                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
499                  slv_reg1[bit_index] <= Bus2IP_Data[bit_index];
500          16'b0010000000000000 :
501            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
502              if ( Bus2IP_BE[byte_index] == 1 )
503                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
504                  slv_reg2[bit_index] <= Bus2IP_Data[bit_index];
505          16'b0001000000000000 :
506            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
507              if ( Bus2IP_BE[byte_index] == 1 )
508                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
509                  slv_reg3[bit_index] <= Bus2IP_Data[bit_index];
510          16'b0000100000000000 :
511            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
512              if ( Bus2IP_BE[byte_index] == 1 )
513                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
514                  slv_reg4[bit_index] <= Bus2IP_Data[bit_index];
515          16'b0000010000000000 :
516            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
517              if ( Bus2IP_BE[byte_index] == 1 )
518                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
519                  slv_reg5[bit_index] <= Bus2IP_Data[bit_index];
520          16'b0000001000000000 :
521            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
522              if ( Bus2IP_BE[byte_index] == 1 )
523                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
524                  slv_reg6[bit_index] <= Bus2IP_Data[bit_index];
525          16'b0000000100000000 :
526            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
527              if ( Bus2IP_BE[byte_index] == 1 )
528                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
529                  slv_reg7[bit_index] <= Bus2IP_Data[bit_index];
530          16'b0000000010000000 :
531            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
532              if ( Bus2IP_BE[byte_index] == 1 )
533                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
534                  slv_reg8[bit_index] <= Bus2IP_Data[bit_index];
535          16'b0000000001000000 :
536            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
537              if ( Bus2IP_BE[byte_index] == 1 )
538                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
539                  slv_reg9[bit_index] <= Bus2IP_Data[bit_index];
540          16'b0000000000100000 :
541            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
542              if ( Bus2IP_BE[byte_index] == 1 )
543                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
544                  slv_reg10[bit_index] <= Bus2IP_Data[bit_index];
545          16'b0000000000010000 :
546            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
547              if ( Bus2IP_BE[byte_index] == 1 )
548                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
549                  slv_reg11[bit_index] <= Bus2IP_Data[bit_index];
550          16'b0000000000001000 :
551            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
552              if ( Bus2IP_BE[byte_index] == 1 )
553                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
554                  slv_reg12[bit_index] <= Bus2IP_Data[bit_index];
555          16'b0000000000000100 :
556            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
557              if ( Bus2IP_BE[byte_index] == 1 )
558                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
559                  slv_reg13[bit_index] <= Bus2IP_Data[bit_index];
560          16'b0000000000000010 :
561            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
562              if ( Bus2IP_BE[byte_index] == 1 )
563                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
564                  slv_reg14[bit_index] <= Bus2IP_Data[bit_index];
565          16'b0000000000000001 :
566            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
567              if ( Bus2IP_BE[byte_index] == 1 )
568                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
569                  slv_reg15[bit_index] <= Bus2IP_Data[bit_index];
570          default : ;
571        endcase
572
573    end // SLAVE_REG_WRITE_PROC
574
575    // implement slave model register read mux
576    always @( slv_reg_read_select or slv_reg0 or slv_reg1 or slv_reg2 or slv_reg3 or slv_reg4 or slv_reg5 or slv_reg6 or slv_reg7 or slv_reg8 or slv_reg9 or slv_reg10 or slv_reg11 or slv_reg12 or slv_reg13 or slv_reg14 or slv_reg15
577            or Radio1_RSSI_ADC_D or Radio1_TX_DAC_PLL_LOCK or Radio1_RSSI_ADC_OTR or Radio1_DIPSW or Radio1_ADC_RX_OTRB or Radio1_ADC_RX_OTRA or Radio1_ADC_RX_DFS or Radio1_LD
578            or Radio2_RSSI_ADC_D or Radio2_TX_DAC_PLL_LOCK or Radio2_RSSI_ADC_OTR or Radio2_DIPSW or Radio2_ADC_RX_OTRB or Radio2_ADC_RX_OTRA or Radio2_ADC_RX_DFS or Radio2_LD
579            or Radio3_RSSI_ADC_D or Radio3_TX_DAC_PLL_LOCK or Radio3_RSSI_ADC_OTR or Radio3_DIPSW or Radio3_ADC_RX_OTRB or Radio3_ADC_RX_OTRA or Radio3_ADC_RX_DFS or Radio3_LD
580            or Radio4_RSSI_ADC_D or Radio4_TX_DAC_PLL_LOCK or Radio4_RSSI_ADC_OTR or Radio4_DIPSW or Radio4_ADC_RX_OTRB or Radio4_ADC_RX_OTRA or Radio4_ADC_RX_DFS or Radio4_LD
581            or mytip )
582    begin: SLAVE_REG_READ_PROC
583
584      case ( slv_reg_read_select )
585        16'b1000000000000000 : slv_ip2bus_data <= {Radio1_RSSI_ADC_D[0:9],
586                                          slv_reg0[10],
587                                          Radio1_TX_DAC_PLL_LOCK,
588                                          Radio1_RSSI_ADC_OTR,
589                                          Radio1_DIPSW[3],
590                                          Radio1_DIPSW[2],
591                                          Radio1_DIPSW[1],
592                                          Radio1_DIPSW[0],
593                                          slv_reg0[17:18],
594                                          Radio1_ADC_RX_OTRB,
595                                          Radio1_ADC_RX_OTRA,
596                                          Radio1_ADC_RX_DFS,
597                                          slv_reg0[22:26],
598                                          Radio1_LD,
599                                          slv_reg0[28:31]};
600                                         
601        16'b0100000000000000 : slv_ip2bus_data <= {Radio2_RSSI_ADC_D[0:9],
602                                          slv_reg1[10],
603                                          Radio2_TX_DAC_PLL_LOCK,
604                                          Radio2_RSSI_ADC_OTR,
605                                          Radio2_DIPSW[3],
606                                          Radio2_DIPSW[2],
607                                          Radio2_DIPSW[1],
608                                          Radio2_DIPSW[0],
609                                          slv_reg1[17:18],
610                                          Radio2_ADC_RX_OTRB,
611                                          Radio2_ADC_RX_OTRA,
612                                          Radio2_ADC_RX_DFS,
613                                          slv_reg1[22:26],
614                                          Radio2_LD,
615                                          slv_reg1[28:31]};
616                                         
617        16'b0010000000000000 : slv_ip2bus_data <= {Radio3_RSSI_ADC_D[0:9],
618                                          slv_reg2[10],
619                                          Radio3_TX_DAC_PLL_LOCK,
620                                          Radio3_RSSI_ADC_OTR,
621                                          Radio3_DIPSW[3],
622                                          Radio3_DIPSW[2],
623                                          Radio3_DIPSW[1],
624                                          Radio3_DIPSW[0],
625                                          slv_reg2[17:18],
626                                          Radio3_ADC_RX_OTRB,
627                                          Radio3_ADC_RX_OTRA,
628                                          Radio3_ADC_RX_DFS,
629                                          slv_reg2[22:26],
630                                          Radio3_LD,
631                                          slv_reg2[28:31]};
632                                         
633        16'b0001000000000000 : slv_ip2bus_data <= {Radio4_RSSI_ADC_D[0:9],
634                                          slv_reg3[10],
635                                          Radio4_TX_DAC_PLL_LOCK,
636                                          Radio4_RSSI_ADC_OTR,
637                                          Radio4_DIPSW[3],
638                                          Radio4_DIPSW[2],
639                                          Radio4_DIPSW[1],
640                                          Radio4_DIPSW[0],
641                                          slv_reg3[17:18],
642                                          Radio4_ADC_RX_OTRB,
643                                          Radio4_ADC_RX_OTRA,
644                                          Radio4_ADC_RX_DFS,
645                                          slv_reg3[22:26],
646                                          Radio4_LD,
647                                          slv_reg3[28:31]};
648                                         
649        16'b0000100000000000 : slv_ip2bus_data <= {slv_reg4[0:22], mytip, slv_reg4[24:31]};
650        16'b0000010000000000 : slv_ip2bus_data <= slv_reg5;
651        16'b0000001000000000 : slv_ip2bus_data <= slv_reg6;
652        16'b0000000100000000 : slv_ip2bus_data <= slv_reg7;
653        16'b0000000010000000 : slv_ip2bus_data <= slv_reg8;
654        16'b0000000001000000 : slv_ip2bus_data <= slv_reg9;
655        16'b0000000000100000 : slv_ip2bus_data <= slv_reg10;
656        16'b0000000000010000 : slv_ip2bus_data <= slv_reg11;
657        16'b0000000000001000 : slv_ip2bus_data <= slv_reg12;
658        16'b0000000000000100 : slv_ip2bus_data <= slv_reg13;
659        16'b0000000000000010 : slv_ip2bus_data <= slv_reg14;
660        16'b0000000000000001 : slv_ip2bus_data <= slv_reg15;
661        default : slv_ip2bus_data <= 0;
662      endcase
663
664    end // SLAVE_REG_READ_PROC
665
666    //Instantiate the SPI controller top-level
667    spi_top spi_top(
668        .opb_clk_i(Bus2IP_Clk),
669        .opb_rst_i(Bus2IP_Reset),
670        .reg_ctrl(reg_ctrl),
671        .reg_ss(reg_ss),
672        .reg_divider(reg_divider),
673        .reg_tx(reg_tx),
674        .ctrlwrite(Bus2IP_WrCE[4]),
675        .busval(Bus2IP_Data[23]), 
676        .go(mytip),
677        .ss_pad_o(ss_pad_o),
678        .sclk_pad_o(spi_clk),
679        .mosi_pad_o(data_out)
680    );
681
682
683    //Instantiate four copies of the mode which controls the timing
684    // of various signals during each Tx cycle
685    radio_controller_TxTiming Radio1_TxTiming (
686        .clk(Bus2IP_Clk),
687        .reset(Bus2IP_Reset),
688
689        .Tx_swEnable(Radio1_swTxEn),
690
691        .TxGain_target(Radio1_TargetTxGain),
692        .TxGain_rampGainStep(Radio1_TxGainStep),
693        .TxGain_rampTimeStep(Radio1_TxGainTimeStep),
694
695        .dly_hwTxEn(Radio1_TxEnThresh),
696        .dly_TxStart(Radio1_TxStartThresh),
697        .dly_PowerAmpEn(Radio1_PAThresh),
698        .dly_RampGain(Radio1_GainRampThresh),
699
700        .hw_TxEn(Radio1_TxEn),
701        .hw_TxGain(Radio1_TxGain),
702        .hw_PAEn(Radio1_PowerAmpEnable),
703        .hw_TxStart(Radio1_TxStart)
704    );
705
706    radio_controller_TxTiming Radio2_TxTiming (
707        .clk(Bus2IP_Clk),
708        .reset(Bus2IP_Reset),
709
710        .Tx_swEnable(Radio2_swTxEn),
711
712        .TxGain_target(Radio2_TargetTxGain),
713        .TxGain_rampGainStep(Radio2_TxGainStep),
714        .TxGain_rampTimeStep(Radio2_TxGainTimeStep),
715
716        .dly_hwTxEn(Radio2_TxEnThresh),
717        .dly_TxStart(Radio2_TxStartThresh),
718        .dly_PowerAmpEn(Radio2_PAThresh),
719        .dly_RampGain(Radio2_GainRampThresh),
720
721        .hw_TxEn(Radio2_TxEn),
722        .hw_TxGain(Radio2_TxGain),
723        .hw_PAEn(Radio2_PowerAmpEnable),
724        .hw_TxStart(Radio2_TxStart)
725    );
726
727    radio_controller_TxTiming Radio3_TxTiming (
728        .clk(Bus2IP_Clk),
729        .reset(Bus2IP_Reset),
730
731        .Tx_swEnable(Radio3_swTxEn),
732
733        .TxGain_target(Radio3_TargetTxGain),
734        .TxGain_rampGainStep(Radio3_TxGainStep),
735        .TxGain_rampTimeStep(Radio3_TxGainTimeStep),
736
737        .dly_hwTxEn(Radio3_TxEnThresh),
738        .dly_TxStart(Radio3_TxStartThresh),
739        .dly_PowerAmpEn(Radio3_PAThresh),
740        .dly_RampGain(Radio3_GainRampThresh),
741
742        .hw_TxEn(Radio3_TxEn),
743        .hw_TxGain(Radio3_TxGain),
744        .hw_PAEn(Radio3_PowerAmpEnable),
745        .hw_TxStart(Radio3_TxStart)
746    );
747
748    radio_controller_TxTiming Radio4_TxTiming (
749        .clk(Bus2IP_Clk),
750        .reset(Bus2IP_Reset),
751
752        .Tx_swEnable(Radio4_swTxEn),
753
754        .TxGain_target(Radio4_TargetTxGain),
755        .TxGain_rampGainStep(Radio4_TxGainStep),
756        .TxGain_rampTimeStep(Radio4_TxGainTimeStep),
757
758        .dly_hwTxEn(Radio4_TxEnThresh),
759        .dly_TxStart(Radio4_TxStartThresh),
760        .dly_PowerAmpEn(Radio4_PAThresh),
761        .dly_RampGain(Radio4_GainRampThresh),
762
763        .hw_TxEn(Radio4_TxEn),
764        .hw_TxGain(Radio4_TxGain),
765        .hw_PAEn(Radio4_PowerAmpEnable),
766        .hw_TxStart(Radio4_TxStart)
767    );
768
769    //Read the user register for each radio's programmed target Tx gain
770    assign Radio1_TargetTxGain = slv_reg8[0:5];
771    assign Radio2_TargetTxGain = slv_reg9[0:5];
772    assign Radio3_TargetTxGain = slv_reg10[0:5];
773    assign Radio4_TargetTxGain = slv_reg11[0:5];
774
775    //Read the user regsiter for each radio's programmed Tx gain ramp increment
776    assign Radio1_TxGainStep = slv_reg8[6:9];
777    assign Radio2_TxGainStep = slv_reg9[6:9];
778    assign Radio3_TxGainStep = slv_reg10[6:9];
779    assign Radio4_TxGainStep = slv_reg11[6:9];
780
781    //Read the user register for each radio's programmed delay between gain steps
782    assign Radio1_TxGainTimeStep = slv_reg8[10:13];
783    assign Radio2_TxGainTimeStep = slv_reg9[10:13];
784    assign Radio3_TxGainTimeStep = slv_reg10[10:13];
785    assign Radio4_TxGainTimeStep = slv_reg11[10:13];
786
787    //slv_reg{8,9,10,11}[14:31] available for future use
788   
789    //Read the user registers for the the delays before each Tx event
790    assign Radio1_GainRampThresh = slv_reg12[0:7];
791    assign Radio2_GainRampThresh = slv_reg13[0:7];
792    assign Radio3_GainRampThresh = slv_reg14[0:7];
793    assign Radio4_GainRampThresh = slv_reg15[0:7];
794
795    assign Radio1_PAThresh = slv_reg12[8:15];
796    assign Radio2_PAThresh = slv_reg13[8:15];
797    assign Radio3_PAThresh = slv_reg14[8:15];
798    assign Radio4_PAThresh = slv_reg15[8:15];
799
800    assign Radio1_TxEnThresh = slv_reg12[16:23];
801    assign Radio2_TxEnThresh = slv_reg13[16:23];
802    assign Radio3_TxEnThresh = slv_reg14[16:23];
803    assign Radio4_TxEnThresh = slv_reg15[16:23];
804
805    assign Radio1_TxStartThresh = slv_reg12[24:31];
806    assign Radio2_TxStartThresh = slv_reg13[24:31];
807    assign Radio3_TxStartThresh = slv_reg14[24:31];
808    assign Radio4_TxStartThresh = slv_reg15[24:31];
809
810endmodule
Note: See TracBrowser for help on using the repository browser.