source: PlatformSupport/CustomPeripherals/pcores/radio_controller_v1_22_a/hdl/verilog/radio_controller_TxTiming.v

Last change on this file was 891, checked in by murphpo, 16 years ago

updated radio controller 1.20 for better compatibility with faster PLB46

File size: 3.7 KB
Line 
1module radio_controller_TxTiming
2(
3    clk,
4    reset,
5   
6    Tx_swEnable,
7   
8    TxGain_target,
9    TxGain_rampGainStep,
10    TxGain_rampTimeStep,
11   
12    dly_hwTxEn,
13    dly_TxStart,
14    dly_PowerAmpEn,
15    dly_RampGain,
16   
17    hw_TxEn,
18    hw_TxGain,
19    hw_PAEn,
20    hw_TxStart
21);
22
23    input           clk;
24    input           reset;
25   
26    input           Tx_swEnable;
27    input   [0:5]   TxGain_target;
28    input   [0:3]   TxGain_rampGainStep;
29    input   [0:3]   TxGain_rampTimeStep;
30   
31    input   [0:7]   dly_hwTxEn;
32    input   [0:11]  dly_TxStart;
33    input   [0:7]   dly_PowerAmpEn;
34    input   [0:7]   dly_RampGain;
35
36    output          hw_TxEn;
37    output          hw_TxStart;
38    output          hw_PAEn;
39    output  [0:5]   hw_TxGain;
40
41    reg     [0:7]   GainRamp_clockEn_counter;
42    reg     [0:7]   timing_counter;
43    reg     [0:11]  timing_counter_big;
44
45    wire    [0:6]   NewTxGain;
46    reg     [0:6]   TxGainBig;
47   
48    wire AutoGainRampEn;
49
50
51    //The output gain signal is the output of an accumulator, enabled after dly_RampGain clock cycles
52    //This signal is the input to the accumulator register. TxGainBig has one extra MSB to ease overflow detection
53    assign NewTxGain = ( (TxGainBig + TxGain_rampGainStep) > TxGain_target) ? TxGain_target : (TxGainBig + TxGain_rampGainStep);
54
55    //The hw_TxGain output, which eventually connects to the radio's parallel gain control bus,
56    //  gets the 6 LSB of the internal accumulator value
57    assign hw_TxGain = TxGainBig[1:6];
58
59    //Enable the outputs when the timing counter has excedded the various control thresholds given by the dly_* inputs
60    //  A delay value of 254 will hold the corresponding output high forever
61    //  A delay value of 255 will hold the corresponding output low forever (the counter below never reaches 255)
62    assign hw_TxEn = (timing_counter > dly_hwTxEn) || dly_hwTxEn == 8'd254;
63    assign hw_PAEn = (timing_counter > dly_PowerAmpEn) || dly_PowerAmpEn == 8'd254;
64
65    //TxStart can have a longer delay, up to 2^12 cycles (probably overkill)
66    // A delay value of 2^12-2 (4094) will hold TxStart high forever
67    // A delay value of 2^12-1 (4095) will hold TxStart low forever (timing_counter_big never reaches 4095)
68    assign hw_TxStart = (timing_counter_big > dly_TxStart) || dly_TxStart == 12'd4094;
69
70    //Enable the gain ramp accumulator after the given delay
71    //  A delay value of 254 or 255 will disable the gain ramp, regardless of the ramp parameters
72    assign AutoGainRampEn = timing_counter > dly_RampGain;
73
74    //Instiantiates a counter which runs once the timing counter exceeds the threshold
75    //  for starting the ramping of Tx gains; the counter increments every TxGain_rampTimeStep cycles
76    always @( posedge clk )
77    begin
78        if(reset | ~Tx_swEnable)
79            TxGainBig <= 0;
80        else if( AutoGainRampEn & (GainRamp_clockEn_counter==1))
81            TxGainBig <= NewTxGain;
82    end
83
84    //Instantiate a counter that starts when the software enables Tx mode
85    // This counter intentionally stops at 253, allowing delay values of 254 and 255 to have other uses
86    always @( posedge clk )
87    begin
88        if(reset | ~Tx_swEnable)
89            timing_counter <= 0;
90        else if(Tx_swEnable & timing_counter < 254)
91            timing_counter <= timing_counter + 1;
92    end
93
94    //Instantiate a counter that starts when the software enables Tx mode
95    // This counter intentionally stops at 4093, allowing delay values of 4094 and 4095 to have other uses
96    always @( posedge clk )
97    begin
98        if(reset | ~Tx_swEnable)
99            timing_counter_big <= 0;
100        else if(Tx_swEnable & timing_counter_big < 4094)
101            timing_counter_big <= timing_counter_big + 1;
102    end
103
104    //Instantiate a counter used to drive the clock enable of the gain ramp counter above
105    always @( posedge clk )
106    begin
107        if(reset | GainRamp_clockEn_counter == TxGain_rampTimeStep)
108            GainRamp_clockEn_counter <= 0;
109        else
110            GainRamp_clockEn_counter <= GainRamp_clockEn_counter + 1;
111    end
112endmodule
Note: See TracBrowser for help on using the repository browser.