@@ -43,159 +43,159 @@ uint32_t getXcvrRegisterAddress(int wrapper, int bank, int link, int reg)
4343 Cru::Registers::GBT_LINK_XCVR_OFFSET.address + (4 * reg);
4444}
4545
46- void atxcal0 (std::shared_ptr<Pda::PdaBar> pdaBar , uint32_t baseAddress)
46+ void atxcal0 (std::shared_ptr<BarInterface> bar , uint32_t baseAddress)
4747{
4848
4949 // std::cout << "Starting ATX PLL calibration" << std::endl;
5050
51- /* uint32_t identifier = pdaBar ->readRegister((baseAddress + 4 * 0x200)/4);
51+ /* uint32_t identifier = bar ->readRegister((baseAddress + 4 * 0x200)/4);
5252
5353 std::cout << "Base Address: 0x" << std::hex << baseAddress <<
5454 " Identifier: 0x" << std::hex << identifier << std::endl;
5555 std::cout << "Requesting internal configuration bus user access..." << std::endl;*/
5656
5757 // a. Direct write of 0x2 to address 0x00 to request access (do not use modify...)
5858
59- pdaBar ->writeRegister ((baseAddress + 4 * 0x000 ) / 4 , 0x02 ); // ...
59+ bar ->writeRegister ((baseAddress + 4 * 0x000 ) / 4 , 0x02 ); // ...
6060
6161 // b. Validate that user has control
62- waitForBit (pdaBar , baseAddress + 4 * 0x280 , 2 , 0 );
62+ waitForBit (bar , baseAddress + 4 * 0x280 , 2 , 0 );
6363
6464 // c. Enable ATX PLL alibration
65- pdaBar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 0 , 1 , 0x1 );
65+ bar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 0 , 1 , 0x1 );
6666
6767 // d. let PreSice do the calibration
68- pdaBar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
68+ bar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
6969
7070 // e. Wait...
71- waitForBit (pdaBar , baseAddress + 4 * 0x280 , 1 , 0 );
71+ waitForBit (bar , baseAddress + 4 * 0x280 , 1 , 0 );
7272
7373 // f. Calibration complete...
7474}
7575
7676// / Calibrate XCVR TX
77- void txcal0 (std::shared_ptr<Pda::PdaBar> pdaBar , uint32_t baseAddress)
77+ void txcal0 (std::shared_ptr<BarInterface> bar , uint32_t baseAddress)
7878{
7979
8080 // a. Request access to internal configuration bus
81- pdaBar ->writeRegister ((baseAddress + 4 * 0x000 ) / 4 , 0x2 );
81+ bar ->writeRegister ((baseAddress + 4 * 0x000 ) / 4 , 0x2 );
8282
8383 // b. Validate that user has control
84- waitForBit (pdaBar , baseAddress + 4 * 0x280 , 2 , 0 );
84+ waitForBit (bar , baseAddress + 4 * 0x280 , 2 , 0 );
8585
8686 // c. Mask out rx_cal_busy...
87- pdaBar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 5 , 1 , 0x0 );
87+ bar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 5 , 1 , 0x0 );
8888
8989 // d. Set the Tx calibration bit
90- pdaBar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 5 , 1 , 0x1 );
91- pdaBar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 6 , 1 , 0x0 );
90+ bar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 5 , 1 , 0x1 );
91+ bar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 6 , 1 , 0x0 );
9292
9393 // e. Let PreSice do the calibration
94- pdaBar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
94+ bar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
9595
9696 // f. Wait..
97- waitForBit (pdaBar , baseAddress + 4 * 0x281 , 1 , 0 );
97+ waitForBit (bar , baseAddress + 4 * 0x281 , 1 , 0 );
9898
9999 // g. Calibration is complete
100100
101101 // h. Enable rx_cal_busy
102- pdaBar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 5 , 1 , 0x1 );
102+ bar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 5 , 1 , 0x1 );
103103}
104104
105105// / Calibrate XCVR RX
106- void rxcal0 (std::shared_ptr<Pda::PdaBar> pdaBar , uint32_t baseAddress)
106+ void rxcal0 (std::shared_ptr<BarInterface> bar , uint32_t baseAddress)
107107{
108108 // a. Request access to internal configuration bus
109- pdaBar ->writeRegister ((baseAddress + 4 * 0x000 ) / 4 , 0x2 );
109+ bar ->writeRegister ((baseAddress + 4 * 0x000 ) / 4 , 0x2 );
110110
111111 // b. Validate that user has control
112- waitForBit (pdaBar , baseAddress + 4 * 0x280 , 2 , 0 );
112+ waitForBit (bar , baseAddress + 4 * 0x280 , 2 , 0 );
113113
114114 // c. Mask out tx_cal_busy...
115- pdaBar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 4 , 1 , 0x0 );
115+ bar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 4 , 1 , 0x0 );
116116
117117 // d. Set the Rx calibration bit
118- pdaBar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 1 , 1 , 0x1 );
119- pdaBar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 6 , 1 , 0x1 );
118+ bar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 1 , 1 , 0x1 );
119+ bar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 6 , 1 , 0x1 );
120120
121121 // e. Set the rate switch flag register for PMA Rx calibration TODO(cru-sw)
122122
123123 // f. Let PreSice do the calibration
124- pdaBar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
124+ bar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
125125
126126 // g. Wait..
127- waitForBit (pdaBar , baseAddress + 4 * 0x281 , 1 , 0 );
127+ waitForBit (bar , baseAddress + 4 * 0x281 , 1 , 0 );
128128
129129 // h. Calibration is complete
130130
131131 // i. Enable tx_cal_busy
132- pdaBar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 4 , 1 , 0x1 );
132+ bar ->modifyRegister ((baseAddress + 4 * 0x281 ) / 4 , 4 , 1 , 0x1 );
133133}
134134
135- void fpllref0 (std::shared_ptr<Pda::PdaBar> pdaBar , uint32_t baseAddress, uint32_t refClock)
135+ void fpllref0 (std::shared_ptr<BarInterface> bar , uint32_t baseAddress, uint32_t refClock)
136136{
137137 // uint32_t current114 = mPdaBar->readRegister((baseAddress + 4 * 0x114)/4);
138- // uint32_t current11C = pdaBar ->readRegister((baseAddress + 4 * 0x11C)/4);
138+ // uint32_t current11C = bar ->readRegister((baseAddress + 4 * 0x11C)/4);
139139
140- uint32_t new114 = pdaBar ->readRegister ((baseAddress + 4 * (0x117 + refClock)) / 4 );
141- uint32_t new11C = pdaBar ->readRegister ((baseAddress + 4 * (0x11D + refClock)) / 4 );
140+ uint32_t new114 = bar ->readRegister ((baseAddress + 4 * (0x117 + refClock)) / 4 );
141+ uint32_t new11C = bar ->readRegister ((baseAddress + 4 * (0x11D + refClock)) / 4 );
142142
143- pdaBar ->modifyRegister ((baseAddress + 4 * 0x114 ) / 4 , 0 , 8 , new114);
144- pdaBar ->modifyRegister ((baseAddress + 4 * 0x11C ) / 4 , 0 , 8 , new11C);
143+ bar ->modifyRegister ((baseAddress + 4 * 0x114 ) / 4 , 0 , 8 , new114);
144+ bar ->modifyRegister ((baseAddress + 4 * 0x11C ) / 4 , 0 , 8 , new11C);
145145}
146146
147- void fpllcal0 (std::shared_ptr<Pda::PdaBar> pdaBar , uint32_t baseAddress, bool configCompensation)
147+ void fpllcal0 (std::shared_ptr<BarInterface> bar , uint32_t baseAddress, bool configCompensation)
148148{
149- /* uint32_t identifier = pdaBar ->readRegister((baseAddress + 4 * 0x200)/4);
149+ /* uint32_t identifier = bar ->readRegister((baseAddress + 4 * 0x200)/4);
150150
151151 std::cout << "Base Address: 0x" << std::hex << baseAddress <<
152152 " Identifier: 0x" << std::hex << identifier << std::endl;*/
153153
154154 // Set fPLL to direct feedback mode
155- pdaBar ->modifyRegister ((baseAddress + 4 * 0x126 ) / 4 , 0 , 1 , 0x1 );
155+ bar ->modifyRegister ((baseAddress + 4 * 0x126 ) / 4 , 0 , 1 , 0x1 );
156156
157157 // a. Request internal configuration bus (do not use modify but modify is used...)
158- pdaBar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x02 );
158+ bar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x02 );
159159
160160 // b. Validate that user has control
161- waitForBit (pdaBar , baseAddress + 4 * 0x280 , 2 , 0 );
161+ waitForBit (bar , baseAddress + 4 * 0x280 , 2 , 0 );
162162
163163 // c. Enable fPLL calibration
164- pdaBar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 1 , 1 , 0x1 );
164+ bar ->modifyRegister ((baseAddress + 4 * 0x100 ) / 4 , 1 , 1 , 0x1 );
165165
166166 // d. let PreSice do the calibration
167- pdaBar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
167+ bar ->modifyRegister ((baseAddress + 4 * 0x000 ) / 4 , 0 , 8 , 0x1 );
168168
169169 // e. Wait...
170- waitForBit (pdaBar , baseAddress + 4 * 0x280 , 1 , 0 );
170+ waitForBit (bar , baseAddress + 4 * 0x280 , 1 , 0 );
171171
172172 // f. Calibration is complete
173173
174174 // g. Set fPLL to feedback compensation mode
175175 if (configCompensation) {
176- pdaBar ->modifyRegister ((baseAddress + 4 * 0x126 ) / 4 , 0 , 1 , 0x0 );
176+ bar ->modifyRegister ((baseAddress + 4 * 0x126 ) / 4 , 0 , 1 , 0x0 );
177177 }
178178}
179179
180- uint32_t waitForBit (std::shared_ptr<Pda::PdaBar> pdaBar , uint32_t address, uint32_t position, uint32_t value)
180+ uint32_t waitForBit (std::shared_ptr<BarInterface> bar , uint32_t address, uint32_t position, uint32_t value)
181181{
182182 auto start = std::chrono::system_clock::now ();
183183 auto curr = start;
184184 auto elapsed = curr - start;
185185
186- uint32_t readValue = pdaBar ->readRegister (address / 4 );
186+ uint32_t readValue = bar ->readRegister (address / 4 );
187187 uint32_t bit = Utilities::getBit (readValue, position);
188188
189189 while ((elapsed <= std::chrono::milliseconds (500 )) && bit != value) {
190- readValue = pdaBar ->readRegister (address / 4 );
190+ readValue = bar ->readRegister (address / 4 );
191191 bit = Utilities::getBit (readValue, position);
192192 curr = std::chrono::system_clock::now ();
193193 elapsed = curr - start;
194194 }
195195 return bit;
196196}
197197
198- void fpllref (std::map<int , Link> linkMap, std::shared_ptr<Pda::PdaBar > mPdaBar , uint32_t refClock, uint32_t baseAddress) // baseAddress = 0
198+ void fpllref (std::map<int , Link> linkMap, std::shared_ptr<BarInterface > mPdaBar , uint32_t refClock, uint32_t baseAddress) // baseAddress = 0
199199{
200200 if (baseAddress == 0 ) {
201201 int prevWrapper = -1 ;
@@ -212,7 +212,7 @@ void fpllref(std::map<int, Link> linkMap, std::shared_ptr<Pda::PdaBar> mPdaBar,
212212 Cru::fpllref0 (mPdaBar , baseAddress, refClock);
213213}
214214
215- void fpllcal (std::map<int , Link> linkMap, std::shared_ptr<Pda::PdaBar > mPdaBar , uint32_t baseAddress, bool configCompensation) // baseAddress = 0, configCompensation = true
215+ void fpllcal (std::map<int , Link> linkMap, std::shared_ptr<BarInterface > mPdaBar , uint32_t baseAddress, bool configCompensation) // baseAddress = 0, configCompensation = true
216216{
217217 if (baseAddress == 0 ) {
218218 int prevWrapper = -1 ;
0 commit comments