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

Last change on this file was 128, checked in by sgupta, 18 years ago

Has the changed location values for the LEDs

File size: 28.0 KB
Line 
1//----------------------------------------------------------------------------
2// user_logic.v - module
3//----------------------------------------------------------------------------
4//
5// ***************************************************************************
6// ** Copyright (c) 1995-2006 Xilinx, Inc.  All rights reserved.            **
7// **                                                                       **
8// ** Xilinx, Inc.                                                          **
9// ** XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"         **
10// ** AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND       **
11// ** SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,        **
12// ** OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,        **
13// ** APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION           **
14// ** THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,     **
15// ** AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE      **
16// ** FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY              **
17// ** WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE               **
18// ** IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR        **
19// ** REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF       **
20// ** INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS       **
21// ** FOR A PARTICULAR PURPOSE.                                             **
22// **                                                                       **
23// ***************************************************************************
24// Copyright (C) 2005 Rice University - Rice Open License Fill
25//
26//----------------------------------------------------------------------------
27// Filename:          user_logic.v
28// Version:           1.03.a
29// Description:       User logic module.
30// Date:              Sat Apr 15 16:16:16 2006 (by Create and Import Peripheral Wizard)
31// Verilog Standard:  Verilog-2001
32//----------------------------------------------------------------------------
33// Naming Conventions:
34//   active low signals:                    "*_n"
35//   clock signals:                         "clk", "clk_div#", "clk_#x"
36//   reset signals:                         "rst", "rst_n"
37//   generics:                              "C_*"
38//   user defined types:                    "*_TYPE"
39//   state machine next state:              "*_ns"
40//   state machine current state:           "*_cs"
41//   combinatorial signals:                 "*_com"
42//   pipelined or register delay signals:   "*_d#"
43//   counter signals:                       "*cnt*"
44//   clock enable signals:                  "*_ce"
45//   internal version of output port:       "*_i"
46//   device pins:                           "*_pin"
47//   ports:                                 "- Names begin with Uppercase"
48//   processes:                             "*_PROCESS"
49//   component instantiations:              "<ENTITY_>I_<#|FUNC>"
50//----------------------------------------------------------------------------
51
52module user_logic
53(
54  // -- ADD USER PORTS BELOW THIS LINE ---------------
55  // --USER ports added here
56 
57    spi_clk,
58    data_out,
59    Radio1_cs,
60    Radio2_cs,
61    Radio3_cs,
62    Radio4_cs,
63    Dac1_cs,
64    Dac2_cs,
65    Dac3_cs,
66    Dac4_cs,
67    Radio1_SHDN,
68    Radio1_TxEn,
69    Radio1_RxEn,
70    Radio1_RxHP,
71    Radio1_LD,
72    Radio1_24PA,
73    Radio1_5PA,
74    Radio1_ANTSW,
75    Radio1_LED,
76    Radio1_ADC_RX_DCS,
77    Radio1_ADC_RX_DFS,
78    Radio1_ADC_RX_OTRA,
79    Radio1_ADC_RX_OTRB,
80    Radio1_ADC_RX_PWDNA,
81    Radio1_ADC_RX_PWDNB,
82    Radio1_DIPSW,
83    Radio1_RSSI_ADC_CLAMP,
84    Radio1_RSSI_ADC_HIZ,
85    Radio1_RSSI_ADC_OTR,
86    Radio1_RSSI_ADC_SLEEP,
87    Radio1_RSSI_ADC_D,
88    Radio1_TX_DAC_PLL_LOCK,
89    Radio1_TX_DAC_RESET,
90    Radio1_RxHP_external,
91    Radio2_SHDN,
92    Radio2_TxEn,
93    Radio2_RxEn,
94    Radio2_RxHP,
95    Radio2_LD,
96    Radio2_24PA,
97    Radio2_5PA,
98    Radio2_ANTSW,
99    Radio2_LED,
100    Radio2_ADC_RX_DCS,
101    Radio2_ADC_RX_DFS,
102    Radio2_ADC_RX_OTRA,
103    Radio2_ADC_RX_OTRB,
104    Radio2_ADC_RX_PWDNA,
105    Radio2_ADC_RX_PWDNB,
106    Radio2_DIPSW,
107    Radio2_RSSI_ADC_CLAMP,
108    Radio2_RSSI_ADC_HIZ,
109    Radio2_RSSI_ADC_OTR,
110    Radio2_RSSI_ADC_SLEEP,
111    Radio2_RSSI_ADC_D,
112    Radio2_TX_DAC_PLL_LOCK,
113    Radio2_TX_DAC_RESET,
114    Radio2_RxHP_external,
115    Radio3_SHDN,
116    Radio3_TxEn,
117    Radio3_RxEn,
118    Radio3_RxHP,
119    Radio3_LD,
120    Radio3_24PA,
121    Radio3_5PA,
122    Radio3_ANTSW,
123    Radio3_LED,
124    Radio3_ADC_RX_DCS,
125    Radio3_ADC_RX_DFS,
126    Radio3_ADC_RX_OTRA,
127    Radio3_ADC_RX_OTRB,
128    Radio3_ADC_RX_PWDNA,
129    Radio3_ADC_RX_PWDNB,
130    Radio3_DIPSW,
131    Radio3_RSSI_ADC_CLAMP,
132    Radio3_RSSI_ADC_HIZ,
133    Radio3_RSSI_ADC_OTR,
134    Radio3_RSSI_ADC_SLEEP,
135    Radio3_RSSI_ADC_D,
136    Radio3_TX_DAC_PLL_LOCK,
137    Radio3_TX_DAC_RESET,
138    Radio3_RxHP_external,
139    Radio4_SHDN,
140    Radio4_TxEn,
141    Radio4_RxEn,
142    Radio4_RxHP,
143    Radio4_LD,
144    Radio4_24PA,
145    Radio4_5PA,
146    Radio4_ANTSW,
147    Radio4_LED,
148    Radio4_ADC_RX_DCS,
149    Radio4_ADC_RX_DFS,
150    Radio4_ADC_RX_OTRA,
151    Radio4_ADC_RX_OTRB,
152    Radio4_ADC_RX_PWDNA,
153    Radio4_ADC_RX_PWDNB,
154    Radio4_DIPSW,
155    Radio4_RSSI_ADC_CLAMP,
156    Radio4_RSSI_ADC_HIZ,
157    Radio4_RSSI_ADC_OTR,
158    Radio4_RSSI_ADC_SLEEP,
159    Radio4_RSSI_ADC_D,
160    Radio4_TX_DAC_PLL_LOCK,
161    Radio4_TX_DAC_RESET,
162    Radio4_RxHP_external,
163 
164 
165  // -- ADD USER PORTS ABOVE THIS LINE ---------------
166
167  // -- DO NOT EDIT BELOW THIS LINE ------------------
168  // -- Bus protocol ports, do not add to or delete
169  Bus2IP_Clk,                     // Bus to IP clock
170  Bus2IP_Reset,                   // Bus to IP reset
171  Bus2IP_Data,                    // Bus to IP data bus for user logic
172  Bus2IP_BE,                      // Bus to IP byte enables for user logic
173  Bus2IP_RdCE,                    // Bus to IP read chip enable for user logic
174  Bus2IP_WrCE,                    // Bus to IP write chip enable for user logic
175  IP2Bus_Data,                    // IP to Bus data bus for user logic
176  IP2Bus_Ack,                     // IP to Bus acknowledgement
177  IP2Bus_Retry,                   // IP to Bus retry response
178  IP2Bus_Error,                   // IP to Bus error response
179  IP2Bus_ToutSup                  // IP to Bus timeout suppress
180  // -- DO NOT EDIT ABOVE THIS LINE ------------------
181); // user_logic
182
183// -- ADD USER PARAMETERS BELOW THIS LINE ------------
184// --USER parameters added here
185// -- ADD USER PARAMETERS ABOVE THIS LINE ------------
186
187// -- DO NOT EDIT BELOW THIS LINE --------------------
188// -- Bus protocol parameters, do not add to or delete
189parameter C_DWIDTH                       = 32;
190parameter C_NUM_CE                       = 8;
191// -- DO NOT EDIT ABOVE THIS LINE --------------------
192
193// -- ADD USER PORTS BELOW THIS LINE -----------------
194// --USER ports added here
195
196   
197    output                  spi_clk;
198    output                  data_out;
199    output                  Radio1_cs;
200    output                  Radio2_cs;
201    output                  Radio3_cs;
202    output                  Radio4_cs;
203    output                  Dac1_cs;
204    output                  Dac2_cs;
205    output                  Dac3_cs;
206    output                  Dac4_cs;
207    output                                  Radio1_SHDN;
208    output                                  Radio1_TxEn;
209    output                                  Radio1_RxEn;
210    output                                  Radio1_RxHP;
211    input                                   Radio1_LD;
212    output                                  Radio1_24PA;
213    output                                  Radio1_5PA;
214    output          [0 : 1]                 Radio1_ANTSW;
215    output          [0 : 2]                 Radio1_LED;
216    output                                  Radio1_ADC_RX_DCS;
217    output                                  Radio1_ADC_RX_DFS;
218    input                                   Radio1_ADC_RX_OTRA;
219    input                                   Radio1_ADC_RX_OTRB;
220    output                                  Radio1_ADC_RX_PWDNA;
221    output                                  Radio1_ADC_RX_PWDNB;
222    input           [0 : 3]                 Radio1_DIPSW;
223    output                                  Radio1_RSSI_ADC_CLAMP;
224    output                                  Radio1_RSSI_ADC_HIZ;
225    input                                   Radio1_RSSI_ADC_OTR;
226    output                                  Radio1_RSSI_ADC_SLEEP;
227    input           [0 : 9]                 Radio1_RSSI_ADC_D;
228    input                                   Radio1_TX_DAC_PLL_LOCK;
229    output                                  Radio1_TX_DAC_RESET;
230    input                   Radio1_RxHP_external;
231    output                                  Radio2_SHDN;
232    output                                  Radio2_TxEn;
233    output                                  Radio2_RxEn;
234    output                                  Radio2_RxHP;
235    input                                   Radio2_LD;
236    output                                  Radio2_24PA;
237    output                                  Radio2_5PA;
238    output          [0 : 1]                 Radio2_ANTSW;
239    output          [0 : 2]                 Radio2_LED;
240    output                                  Radio2_ADC_RX_DCS;
241    output                                  Radio2_ADC_RX_DFS;
242    input                                   Radio2_ADC_RX_OTRA;
243    input                                   Radio2_ADC_RX_OTRB;
244    output                                  Radio2_ADC_RX_PWDNA;
245    output                                  Radio2_ADC_RX_PWDNB;
246    input           [0 : 3]                 Radio2_DIPSW;
247    output                                  Radio2_RSSI_ADC_CLAMP;
248    output                                  Radio2_RSSI_ADC_HIZ;
249    input                                   Radio2_RSSI_ADC_OTR;
250    output                                  Radio2_RSSI_ADC_SLEEP;
251    input           [0 : 9]                 Radio2_RSSI_ADC_D;
252    input                                   Radio2_TX_DAC_PLL_LOCK;
253    output                                  Radio2_TX_DAC_RESET;
254    input                   Radio2_RxHP_external;
255    output                                  Radio3_SHDN;
256    output                                  Radio3_TxEn;
257    output                                  Radio3_RxEn;
258    output                                  Radio3_RxHP;
259    input                                   Radio3_LD;
260    output                                  Radio3_24PA;
261    output                                  Radio3_5PA;
262    output          [0 : 1]                 Radio3_ANTSW;
263    output          [0 : 2]                 Radio3_LED;
264    output                                  Radio3_ADC_RX_DCS;
265    output                                  Radio3_ADC_RX_DFS;
266    input                                   Radio3_ADC_RX_OTRA;
267    input                                   Radio3_ADC_RX_OTRB;
268    output                                  Radio3_ADC_RX_PWDNA;
269    output                                  Radio3_ADC_RX_PWDNB;
270    input           [0 : 3]                 Radio3_DIPSW;
271    output                                  Radio3_RSSI_ADC_CLAMP;
272    output                                  Radio3_RSSI_ADC_HIZ;
273    input                                   Radio3_RSSI_ADC_OTR;
274    output                                  Radio3_RSSI_ADC_SLEEP;
275    input           [0 : 9]                 Radio3_RSSI_ADC_D;
276    input                                   Radio3_TX_DAC_PLL_LOCK;
277    output                                  Radio3_TX_DAC_RESET;
278    input                   Radio3_RxHP_external;
279    output                                  Radio4_SHDN;
280    output                                  Radio4_TxEn;
281    output                                  Radio4_RxEn;
282    output                                  Radio4_RxHP;
283    input                                   Radio4_LD;
284    output                                  Radio4_24PA;
285    output                                  Radio4_5PA;
286    output          [0 : 1]                 Radio4_ANTSW;
287    output          [0 : 2]                 Radio4_LED;                     //
288    output                                  Radio4_ADC_RX_DCS;
289    output                                  Radio4_ADC_RX_DFS;              // 1
290    input                                   Radio4_ADC_RX_OTRA;
291    input                                   Radio4_ADC_RX_OTRB;
292    output                                  Radio4_ADC_RX_PWDNA;
293    output                                  Radio4_ADC_RX_PWDNB;
294    input           [0 : 3]                 Radio4_DIPSW;
295    output                                  Radio4_RSSI_ADC_CLAMP;          //
296    output                                  Radio4_RSSI_ADC_HIZ;            //
297    input                                   Radio4_RSSI_ADC_OTR;
298    output                                  Radio4_RSSI_ADC_SLEEP;          //
299    input           [0 : 9]                 Radio4_RSSI_ADC_D;
300    input                                   Radio4_TX_DAC_PLL_LOCK;
301    output                                  Radio4_TX_DAC_RESET;
302    input                   Radio4_RxHP_external;
303
304
305// -- ADD USER PORTS ABOVE THIS LINE -----------------
306
307// -- DO NOT EDIT BELOW THIS LINE --------------------
308// -- Bus protocol ports, do not add to or delete
309input                                     Bus2IP_Clk;
310input                                     Bus2IP_Reset;
311input      [0 : C_DWIDTH-1]               Bus2IP_Data;
312input      [0 : C_DWIDTH/8-1]             Bus2IP_BE;
313input      [0 : C_NUM_CE-1]               Bus2IP_RdCE;
314input      [0 : C_NUM_CE-1]               Bus2IP_WrCE;
315output     [0 : C_DWIDTH-1]               IP2Bus_Data;
316output                                    IP2Bus_Ack;
317output                                    IP2Bus_Retry;
318output                                    IP2Bus_Error;
319output                                    IP2Bus_ToutSup;
320// -- DO NOT EDIT ABOVE THIS LINE --------------------
321
322//----------------------------------------------------------------------------
323// Implementation
324//----------------------------------------------------------------------------
325
326  // --USER nets declarations added here, as needed for user logic
327
328  // Nets for user logic slave model s/w accessible register example
329  reg        [0 : C_DWIDTH-1]               slv_reg0;
330  reg        [0 : C_DWIDTH-1]               slv_reg1;
331  reg        [0 : C_DWIDTH-1]               slv_reg2;
332  reg        [0 : C_DWIDTH-1]               slv_reg3;
333  reg        [0 : C_DWIDTH-1]               slv_reg4;
334  reg        [0 : C_DWIDTH-1]               slv_reg5;
335  reg        [0 : C_DWIDTH-1]               slv_reg6;
336  reg        [0 : C_DWIDTH-1]               slv_reg7;
337  wire       [0 : 7]                        slv_reg_write_select;
338  wire       [0 : 7]                        slv_reg_read_select;
339  reg        [0 : C_DWIDTH-1]               slv_ip2bus_data;
340  wire                                      slv_read_ack;
341  wire                                      slv_write_ack;
342  integer                                   byte_index, bit_index;
343
344  // --USER logic implementation added here
345 
346 
347  wire [7:0] ss_pad_o;
348  wire mytip;
349  wire [13:0] reg_ctrl;
350  wire [7:0] reg_ss;
351  wire reg_divider;
352  wire [17:0] reg_tx;
353 
354 
355  assign  Radio1_SHDN = ~slv_reg0[31];
356  assign  Radio1_TxEn = slv_reg0[30];
357  assign  Radio1_RxEn = slv_reg0[29];
358  assign  Radio1_RxHP = (slv_reg0[27])?slv_reg0[28]:Radio1_RxHP_external;
359  assign  Radio1_24PA = ~slv_reg0[26];
360  assign  Radio1_5PA = ~slv_reg0[25];
361  assign  Radio1_ANTSW[0] = slv_reg0[24];
362  assign  Radio1_ANTSW[1] = slv_reg0[23];
363  assign  Radio1_ADC_RX_DCS = slv_reg0[22];
364  assign  Radio1_LED[0] = ~Radio1_LD;
365  assign  Radio1_LED[1] = Radio1_TxEn;
366  assign  Radio1_LED[2] = ~Radio1_TX_DAC_PLL_LOCK;
367  assign  Radio1_ADC_RX_PWDNA = slv_reg0[18];
368  assign  Radio1_ADC_RX_PWDNB = slv_reg0[17];
369  assign  Radio1_RSSI_ADC_SLEEP = slv_reg0[16];
370  assign  Radio1_TX_DAC_RESET = slv_reg0[10];
371   
372  assign  Radio1_ADC_RX_DFS = 1'b1; //slv_reg0[18];
373  assign  Radio1_RSSI_ADC_CLAMP = 1'b0; //slv_reg0[9];
374  assign  Radio1_RSSI_ADC_HIZ = 1'b0; //slv_reg0[8]; 
375 
376  assign  Radio2_SHDN = ~slv_reg1[31];
377  assign  Radio2_TxEn = slv_reg1[30];
378  assign  Radio2_RxEn = slv_reg1[29];
379  assign  Radio2_RxHP = (slv_reg1[27])?slv_reg1[28]:Radio2_RxHP_external;
380  assign  Radio2_24PA = ~slv_reg1[26];
381  assign  Radio2_5PA = ~slv_reg1[25];
382  assign  Radio2_ANTSW[0] = slv_reg1[24];
383  assign  Radio2_ANTSW[1] = slv_reg1[23];
384  assign  Radio2_ADC_RX_DCS = slv_reg1[22];
385  assign  Radio2_LED[0] = ~Radio2_LD;
386  assign  Radio2_LED[1] = Radio2_TxEn;
387  assign  Radio2_LED[2] = ~Radio2_TX_DAC_PLL_LOCK;
388  assign  Radio2_ADC_RX_PWDNA = slv_reg1[18];
389  assign  Radio2_ADC_RX_PWDNB = slv_reg1[17];
390  assign  Radio2_RSSI_ADC_SLEEP = slv_reg1[16];
391  assign  Radio2_TX_DAC_RESET = slv_reg1[10];
392   
393  assign  Radio2_ADC_RX_DFS = 1'b1; //slv_reg1[18];
394  assign  Radio2_RSSI_ADC_CLAMP = 1'b0; //slv_reg1[9];
395  assign  Radio2_RSSI_ADC_HIZ = 1'b0; //slv_reg1[8]; 
396
397  assign  Radio3_SHDN = ~slv_reg2[31];
398  assign  Radio3_TxEn = slv_reg2[30];
399  assign  Radio3_RxEn = slv_reg2[29];
400  assign  Radio3_RxHP = (slv_reg2[27])?slv_reg2[28]:Radio3_RxHP_external;
401  assign  Radio3_24PA = ~slv_reg2[26];
402  assign  Radio3_5PA = ~slv_reg2[25];
403  assign  Radio3_ANTSW[0] = slv_reg2[24];
404  assign  Radio3_ANTSW[1] = slv_reg2[23];
405  assign  Radio3_ADC_RX_DCS = slv_reg2[22];
406  assign  Radio3_LED[0] = ~Radio3_LD;
407  assign  Radio3_LED[1] = Radio3_TxEn;
408  assign  Radio3_LED[2] = ~Radio3_TX_DAC_PLL_LOCK;
409  assign  Radio3_ADC_RX_PWDNA = slv_reg2[18];
410  assign  Radio3_ADC_RX_PWDNB = slv_reg2[17];
411  assign  Radio3_RSSI_ADC_SLEEP = slv_reg2[16];
412  assign  Radio3_TX_DAC_RESET = slv_reg2[10];
413   
414  assign  Radio3_ADC_RX_DFS = 1'b1; //slv_reg2[18];
415  assign  Radio3_RSSI_ADC_CLAMP = 1'b0; //slv_reg2[9];
416  assign  Radio3_RSSI_ADC_HIZ = 1'b0; //slv_reg2[8]; 
417
418  assign  Radio4_SHDN = ~slv_reg3[31];
419  assign  Radio4_TxEn = slv_reg3[30];
420  assign  Radio4_RxEn = slv_reg3[29];
421  assign  Radio4_RxHP = (slv_reg3[27])?slv_reg3[28]:Radio4_RxHP_external;
422  assign  Radio4_24PA = ~slv_reg3[26];
423  assign  Radio4_5PA = ~slv_reg3[25];
424  assign  Radio4_ANTSW[0] = slv_reg3[24];
425  assign  Radio4_ANTSW[1] = slv_reg3[23];
426  assign  Radio4_ADC_RX_DCS = slv_reg3[22];
427  assign  Radio4_LED[0] = ~Radio4_LD;
428  assign  Radio4_LED[1] = Radio4_TxEn;
429  assign  Radio4_LED[2] = ~Radio4_TX_DAC_PLL_LOCK;
430  assign  Radio4_ADC_RX_PWDNA = slv_reg3[18];
431  assign  Radio4_ADC_RX_PWDNB = slv_reg3[17];
432  assign  Radio4_RSSI_ADC_SLEEP = slv_reg3[16];
433  assign  Radio4_TX_DAC_RESET = slv_reg3[10];
434   
435  assign  Radio4_ADC_RX_DFS = 1'b1; //slv_reg3[18];
436  assign  Radio4_RSSI_ADC_CLAMP = 1'b0; //slv_reg3[9];
437  assign  Radio4_RSSI_ADC_HIZ = 1'b0; //slv_reg3[8]; 
438
439  assign  Radio1_cs = ss_pad_o[0];
440  assign  Radio2_cs = ss_pad_o[1];
441  assign  Radio3_cs = ss_pad_o[2];
442  assign  Radio4_cs = ss_pad_o[3];
443  assign  Dac1_cs = ss_pad_o[4];
444  assign  Dac2_cs = ss_pad_o[5];
445  assign  Dac3_cs = ss_pad_o[6];
446  assign  Dac4_cs = ss_pad_o[7];
447   
448  assign reg_ctrl = slv_reg4[18:31];
449  assign reg_divider = slv_reg5[31];
450  assign reg_ss = slv_reg6[24:31];
451  assign reg_tx = slv_reg7[14:31];
452 
453  spi_top spi_top(
454    .opb_clk_i(Bus2IP_Clk),
455    .opb_rst_i(Bus2IP_Reset),
456    .reg_ctrl(reg_ctrl),
457    .reg_ss(reg_ss),
458    .reg_divider(reg_divider),
459    .reg_tx(reg_tx),
460    .ctrlwrite(Bus2IP_WrCE[4]),
461    .busval(Bus2IP_Data[23]), 
462    .go(mytip),
463    .ss_pad_o(ss_pad_o),
464    .sclk_pad_o(spi_clk),
465    .mosi_pad_o(data_out)
466  );
467 
468
469  // ------------------------------------------------------
470  // Example code to read/write user logic slave model s/w accessible registers
471  //
472  // Note:
473  // The example code presented here is to show you one way of reading/writing
474  // software accessible registers implemented in the user logic slave model.
475  // Each bit of the Bus2IP_WrCE/Bus2IP_RdCE signals is configured to correspond
476  // to one software accessible register by the top level template. For example,
477  // if you have four 32 bit software accessible registers in the user logic, you
478  // are basically operating on the following memory mapped registers:
479  //
480  //    Bus2IP_WrCE or   Memory Mapped
481  //       Bus2IP_RdCE   Register
482  //            "1000"   C_BASEADDR + 0x0
483  //            "0100"   C_BASEADDR + 0x4
484  //            "0010"   C_BASEADDR + 0x8
485  //            "0001"   C_BASEADDR + 0xC
486  //
487  // ------------------------------------------------------
488 
489  assign
490    slv_reg_write_select = Bus2IP_WrCE[0:7],
491    slv_reg_read_select  = Bus2IP_RdCE[0:7],
492    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],
493    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];
494
495  // implement slave model register(s)
496  always @( posedge Bus2IP_Clk )
497    begin: SLAVE_REG_WRITE_PROC
498
499      if ( Bus2IP_Reset == 1 )
500        begin
501          slv_reg0 <= 0;
502          slv_reg1 <= 0;
503          slv_reg2 <= 0;
504          slv_reg3 <= 0;
505          slv_reg4 <= 0;
506          slv_reg5 <= 0;
507          slv_reg6 <= 0;
508          slv_reg7 <= 0;
509        end
510      else
511        case ( slv_reg_write_select )
512          8'b10000000 :
513            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
514              if ( Bus2IP_BE[byte_index] == 1 )
515                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
516                  slv_reg0[bit_index] <= Bus2IP_Data[bit_index];
517          8'b01000000 :
518            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
519              if ( Bus2IP_BE[byte_index] == 1 )
520                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
521                  slv_reg1[bit_index] <= Bus2IP_Data[bit_index];
522          8'b00100000 :
523            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
524              if ( Bus2IP_BE[byte_index] == 1 )
525                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
526                  slv_reg2[bit_index] <= Bus2IP_Data[bit_index];
527          8'b00010000 :
528            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
529              if ( Bus2IP_BE[byte_index] == 1 )
530                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
531                  slv_reg3[bit_index] <= Bus2IP_Data[bit_index];
532          8'b00001000 :
533            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
534              if ( Bus2IP_BE[byte_index] == 1 )
535                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
536                  slv_reg4[bit_index] <= Bus2IP_Data[bit_index];
537          8'b00000100 :
538            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
539              if ( Bus2IP_BE[byte_index] == 1 )
540                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
541                  slv_reg5[bit_index] <= Bus2IP_Data[bit_index];
542          8'b00000010 :
543            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
544              if ( Bus2IP_BE[byte_index] == 1 )
545                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
546                  slv_reg6[bit_index] <= Bus2IP_Data[bit_index];
547          8'b00000001 :
548            for ( byte_index = 0; byte_index <= (C_DWIDTH/8)-1; byte_index = byte_index+1 )
549              if ( Bus2IP_BE[byte_index] == 1 )
550                for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
551                  slv_reg7[bit_index] <= Bus2IP_Data[bit_index];
552          default : ;
553        endcase
554
555    end // SLAVE_REG_WRITE_PROC
556
557  // implement slave model register read mux
558  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 )
559    begin: SLAVE_REG_READ_PROC
560
561      case ( slv_reg_read_select )
562        8'b10000000 : slv_ip2bus_data <= {Radio1_RSSI_ADC_D[0:9],
563                                          slv_reg0[10],
564                                          Radio1_TX_DAC_PLL_LOCK,
565                                          Radio1_RSSI_ADC_OTR,
566                                          Radio1_DIPSW[0:3],
567                                          slv_reg0[17:18],
568                                          Radio1_ADC_RX_OTRB,
569                                          Radio1_ADC_RX_OTRA,
570                                          Radio1_ADC_RX_DFS,
571                                          slv_reg0[22:26],
572                                          Radio1_LD,
573                                          slv_reg0[28:31]};
574                                         
575        8'b01000000 : slv_ip2bus_data <= {Radio2_RSSI_ADC_D[0:9],
576                                          slv_reg1[10],
577                                          Radio2_TX_DAC_PLL_LOCK,
578                                          Radio2_RSSI_ADC_OTR,
579                                          Radio2_DIPSW[0:3],
580                                          slv_reg1[17:18],
581                                          Radio2_ADC_RX_OTRB,
582                                          Radio2_ADC_RX_OTRA,
583                                          Radio2_ADC_RX_DFS,
584                                          slv_reg1[22:26],
585                                          Radio2_LD,
586                                          slv_reg1[28:31]};
587                                         
588        8'b00100000 : slv_ip2bus_data <= {Radio3_RSSI_ADC_D[0:9],
589                                          slv_reg2[10],
590                                          Radio3_TX_DAC_PLL_LOCK,
591                                          Radio3_RSSI_ADC_OTR,
592                                          Radio3_DIPSW[0:3],
593                                          slv_reg2[17:18],
594                                          Radio3_ADC_RX_OTRB,
595                                          Radio3_ADC_RX_OTRA,
596                                          Radio3_ADC_RX_DFS,
597                                          slv_reg2[22:26],
598                                          Radio3_LD,
599                                          slv_reg2[28:31]};
600                                         
601        8'b00010000 : slv_ip2bus_data <= {Radio4_RSSI_ADC_D[0:9],
602                                          slv_reg3[10],
603                                          Radio4_TX_DAC_PLL_LOCK,
604                                          Radio4_RSSI_ADC_OTR,
605                                          Radio4_DIPSW[0:3],
606                                          slv_reg3[17:18],
607                                          Radio4_ADC_RX_OTRB,
608                                          Radio4_ADC_RX_OTRA,
609                                          Radio4_ADC_RX_DFS,
610                                          slv_reg3[22:26],
611                                          Radio4_LD,
612                                          slv_reg3[28:31]};
613                                         
614        8'b00001000 : slv_ip2bus_data <= {slv_reg4[0:22], mytip, slv_reg4[24:31]};
615        8'b00000100 : slv_ip2bus_data <= slv_reg5;
616        8'b00000010 : slv_ip2bus_data <= slv_reg6;
617        8'b00000001 : slv_ip2bus_data <= slv_reg7;
618        default : slv_ip2bus_data <= 0;
619      endcase
620
621    end // SLAVE_REG_READ_PROC
622
623  // ------------------------------------------------------------
624  // Example code to drive IP to Bus signals
625  // ------------------------------------------------------------
626
627  assign IP2Bus_Data        = slv_ip2bus_data;
628  assign IP2Bus_Ack         = slv_write_ack || slv_read_ack;
629  assign IP2Bus_Error       = 0;
630  assign IP2Bus_Retry       = 0;
631  assign IP2Bus_ToutSup     = 0;
632
633endmodule
Note: See TracBrowser for help on using the repository browser.