| 1 |
2 |
EziDebug |
#include <QString>
|
| 2 |
|
|
#include <QStringList>
|
| 3 |
|
|
#include <QVector>
|
| 4 |
|
|
#include <QMap>
|
| 5 |
|
|
#include "ezidebugmodule.h"
|
| 6 |
|
|
#include "ezidebugscanchain.h"
|
| 7 |
|
|
#include <QDebug>
|
| 8 |
|
|
#include "reg_scan.h"
|
| 9 |
|
|
|
| 10 |
|
|
|
| 11 |
|
|
EziDebugModule::EziDebugModule(const QString modulename):m_imoduleName(modulename)
|
| 12 |
|
|
{
|
| 13 |
|
|
m_ninstanceTimes = 0 ;
|
| 14 |
|
|
m_isaddedCode = false ;
|
| 15 |
|
|
m_isLibaryCore = false ;
|
| 16 |
|
|
m_isSubstituted = false ;
|
| 17 |
|
|
|
| 18 |
|
|
}
|
| 19 |
|
|
|
| 20 |
|
|
EziDebugModule::~EziDebugModule()
|
| 21 |
|
|
{
|
| 22 |
|
|
//QMap<QString,QVector<EziDebugModule::RegStructure*> > m_iregMap ;
|
| 23 |
|
|
QMap<QString,QVector<EziDebugModule::RegStructure*> >::iterator i = m_iregMap.begin() ;
|
| 24 |
|
|
while(i!= m_iregMap.end())
|
| 25 |
|
|
{
|
| 26 |
|
|
QVector<EziDebugModule::RegStructure*> iregVec = i.value();
|
| 27 |
|
|
qDeleteAll(iregVec);
|
| 28 |
|
|
++i;
|
| 29 |
|
|
}
|
| 30 |
|
|
|
| 31 |
|
|
QMap<QString,QMap<QString ,QVector<RegStructure*> > >::const_iterator iinstanceRegMapIter = m_iinstanceRegMap.constBegin() ;
|
| 32 |
|
|
while(iinstanceRegMapIter != m_iinstanceRegMap.constEnd())
|
| 33 |
|
|
{
|
| 34 |
|
|
QMap<QString ,QVector<RegStructure*> > iregClockVec = iinstanceRegMapIter.value() ;
|
| 35 |
|
|
QMap<QString ,QVector<RegStructure*> >::const_iterator iregClockVecIter = iregClockVec.constBegin() ;
|
| 36 |
|
|
while(iregClockVecIter != iregClockVec.constEnd())
|
| 37 |
|
|
{
|
| 38 |
|
|
QVector<RegStructure*> iregVec = iregClockVecIter.value();
|
| 39 |
|
|
qDeleteAll(iregVec) ;
|
| 40 |
|
|
++iregClockVecIter ;
|
| 41 |
|
|
}
|
| 42 |
|
|
++iinstanceRegMapIter ;
|
| 43 |
|
|
}
|
| 44 |
|
|
|
| 45 |
|
|
//QVector<PortStructure*> m_iportVec ;
|
| 46 |
|
|
qDeleteAll(m_iportVec);
|
| 47 |
|
|
|
| 48 |
|
|
}
|
| 49 |
|
|
|
| 50 |
|
|
QString EziDebugModule::getModuleName(void) const
|
| 51 |
|
|
{
|
| 52 |
|
|
return m_imoduleName ;
|
| 53 |
|
|
}
|
| 54 |
|
|
|
| 55 |
|
|
QVector<EziDebugModule::RegStructure*> EziDebugModule::getReg(const QString &clock)
|
| 56 |
|
|
{
|
| 57 |
|
|
return m_iregMap.value(clock) ;
|
| 58 |
|
|
}
|
| 59 |
|
|
|
| 60 |
|
|
const QMap<QString,QVector<EziDebugModule::RegStructure*> >EziDebugModule:: getRegMap(void) const
|
| 61 |
|
|
{
|
| 62 |
|
|
return m_iregMap ;
|
| 63 |
|
|
}
|
| 64 |
|
|
|
| 65 |
|
|
|
| 66 |
|
|
|
| 67 |
|
|
const QStringList &EziDebugModule::getInstanceList(void) const
|
| 68 |
|
|
{
|
| 69 |
|
|
return m_iinstanceNameList ;
|
| 70 |
|
|
}
|
| 71 |
|
|
|
| 72 |
|
|
const QMap<QString,QString> &EziDebugModule::getClockSignal(void) const
|
| 73 |
|
|
{
|
| 74 |
|
|
return m_iclockMap ;
|
| 75 |
|
|
}
|
| 76 |
|
|
|
| 77 |
|
|
const QMap<QString,QString> &EziDebugModule::getResetSignal(void) const
|
| 78 |
|
|
{
|
| 79 |
|
|
return m_iresetMap ;
|
| 80 |
|
|
}
|
| 81 |
|
|
|
| 82 |
|
|
const QVector<EziDebugModule::PortStructure*> &EziDebugModule::getPort(EziDebugPrj *prj ,const QString &instancename)
|
| 83 |
|
|
{
|
| 84 |
|
|
int nportCount = 0 ;
|
| 85 |
|
|
int nfirstBit = 0 ;
|
| 86 |
|
|
int nSecondBit = 0 ;
|
| 87 |
|
|
bool isParamInvolveMacro = false ;
|
| 88 |
|
|
QMap<QString,QString> idefParamMap = m_idefparameter.value(instancename) ;
|
| 89 |
|
|
QMap<QString,QString> imacroMap = prj->getMacroMap() ;
|
| 90 |
|
|
QString imacroPrefix("`");
|
| 91 |
|
|
QRegExp imacroStr("`(\\w+)") ;
|
| 92 |
|
|
PortStructure* pport = NULL ;
|
| 93 |
|
|
QMap<QString,QString>::const_iterator iparamIter = m_iparameter.constBegin() ;
|
| 94 |
|
|
for(;nportCount < m_iportVec.count();nportCount++)
|
| 95 |
|
|
{
|
| 96 |
|
|
pport = m_iportVec.at(nportCount) ;
|
| 97 |
|
|
QString iportWidth = QString::fromAscii(pport->m_pBitWidth);
|
| 98 |
|
|
|
| 99 |
|
|
while(iparamIter != m_iparameter.constEnd())
|
| 100 |
|
|
{
|
| 101 |
|
|
if(idefParamMap.value(iparamIter.key(),QString()).isEmpty())
|
| 102 |
|
|
{
|
| 103 |
|
|
// 用 paramete 替换
|
| 104 |
|
|
iportWidth.replace(iparamIter.key() , iparamIter.value());
|
| 105 |
|
|
}
|
| 106 |
|
|
else
|
| 107 |
|
|
{
|
| 108 |
|
|
// 用 defparam 替换
|
| 109 |
|
|
iportWidth.replace(iparamIter.key() , idefParamMap.value(iparamIter.key()));
|
| 110 |
|
|
}
|
| 111 |
|
|
|
| 112 |
|
|
|
| 113 |
|
|
// 排出 parameter 引入 define 导致 交替引用
|
| 114 |
|
|
while(-1 != imacroStr.indexIn(iportWidth))
|
| 115 |
|
|
{
|
| 116 |
|
|
QString icapMacroStr = imacroStr.cap(1) ;
|
| 117 |
|
|
iportWidth = iportWidth.replace(imacroPrefix+icapMacroStr,imacroMap.value(icapMacroStr));
|
| 118 |
|
|
isParamInvolveMacro = true ;
|
| 119 |
|
|
}
|
| 120 |
|
|
|
| 121 |
|
|
if(isParamInvolveMacro)
|
| 122 |
|
|
{
|
| 123 |
|
|
// 重新扫描 是否含有 parameter
|
| 124 |
|
|
iparamIter = m_iparameter.constBegin() ;
|
| 125 |
|
|
isParamInvolveMacro = false ;
|
| 126 |
|
|
continue ;
|
| 127 |
|
|
}
|
| 128 |
|
|
++iparamIter ;
|
| 129 |
|
|
}
|
| 130 |
|
|
|
| 131 |
|
|
if(!iportWidth.compare("1"))
|
| 132 |
|
|
{
|
| 133 |
|
|
pport->m_unStartBit = 0 ;
|
| 134 |
|
|
pport->m_unEndBit = 0 ;
|
| 135 |
|
|
pport->m_eEndian = endianBig ;
|
| 136 |
|
|
pport->m_unBitwidth = 1 ;
|
| 137 |
|
|
}
|
| 138 |
|
|
else
|
| 139 |
|
|
{
|
| 140 |
|
|
getBitRange(iportWidth,&nfirstBit,&nSecondBit);
|
| 141 |
|
|
|
| 142 |
|
|
if((nfirstBit < 0)||(nSecondBit < 0))
|
| 143 |
|
|
{
|
| 144 |
|
|
qDebug() << "EziDebug Error: The caculate result is not right!";
|
| 145 |
|
|
pport->m_unBitwidth = 0 ;
|
| 146 |
|
|
break ;
|
| 147 |
|
|
}
|
| 148 |
|
|
|
| 149 |
|
|
pport->m_unStartBit = nfirstBit ;
|
| 150 |
|
|
pport->m_unEndBit = nSecondBit ;
|
| 151 |
|
|
|
| 152 |
|
|
if(nfirstBit > nSecondBit)
|
| 153 |
|
|
{
|
| 154 |
|
|
pport->m_eEndian = endianBig ;
|
| 155 |
|
|
}
|
| 156 |
|
|
else
|
| 157 |
|
|
{
|
| 158 |
|
|
pport->m_eEndian = endianLittle ;
|
| 159 |
|
|
}
|
| 160 |
|
|
|
| 161 |
|
|
pport->m_unBitwidth = qAbs(nfirstBit-nSecondBit) + 1 ;
|
| 162 |
|
|
}
|
| 163 |
|
|
}
|
| 164 |
|
|
return m_iportVec ;
|
| 165 |
|
|
}
|
| 166 |
|
|
|
| 167 |
|
|
void EziDebugModule::addToClockMap(const QString &clock)
|
| 168 |
|
|
{
|
| 169 |
|
|
// value 暂时没有用处 ,以后可能用于 clock 的别名
|
| 170 |
|
|
m_iclockMap.insert(clock,"posedge");
|
| 171 |
|
|
return ;
|
| 172 |
|
|
}
|
| 173 |
|
|
|
| 174 |
|
|
void EziDebugModule::addToResetSignalMap(const QString &reset,const QString &edge)
|
| 175 |
|
|
{
|
| 176 |
|
|
// value 暂时没有用处 ,以后可能用于 clock 的别名
|
| 177 |
|
|
m_iresetMap.insert(reset,edge);
|
| 178 |
|
|
return ;
|
| 179 |
|
|
}
|
| 180 |
|
|
|
| 181 |
|
|
const QString &EziDebugModule::getLocatedFileName(void) const
|
| 182 |
|
|
{
|
| 183 |
|
|
return m_ilocatedFile ;
|
| 184 |
|
|
}
|
| 185 |
|
|
|
| 186 |
|
|
bool EziDebugModule::getAddCodeFlag(void)
|
| 187 |
|
|
{
|
| 188 |
|
|
return m_isaddedCode ;
|
| 189 |
|
|
}
|
| 190 |
|
|
|
| 191 |
|
|
int EziDebugModule::getInstancedTimesPerChain(const QString &chainName)
|
| 192 |
|
|
{
|
| 193 |
|
|
return m_iinstanceTimesPerChain.value(chainName);
|
| 194 |
|
|
}
|
| 195 |
|
|
|
| 196 |
|
|
int EziDebugModule::getConstInstacedTimesPerChain(const QString &chainName)
|
| 197 |
|
|
{
|
| 198 |
|
|
return m_iconstInstanceTimesPerChain.value(chainName);
|
| 199 |
|
|
}
|
| 200 |
|
|
|
| 201 |
|
|
const QMap<QString,QMap<QString,QString> > &EziDebugModule::getInstancePortMap(void) const
|
| 202 |
|
|
{
|
| 203 |
|
|
return m_iinstancePortMap ;
|
| 204 |
|
|
}
|
| 205 |
|
|
|
| 206 |
|
|
QMap<QString,QString> EziDebugModule::getInstancePortMap(const QString &instanceName)
|
| 207 |
|
|
{
|
| 208 |
|
|
return m_iinstancePortMap.value(instanceName);
|
| 209 |
|
|
}
|
| 210 |
|
|
|
| 211 |
|
|
/*
|
| 212 |
|
|
int EziDebugModule::getRegNumber(const QString &clock)
|
| 213 |
|
|
{
|
| 214 |
|
|
int nnum = 0 ;
|
| 215 |
|
|
QMap<QString,QVector<EziDebugModule::RegStructure*> >::const_iterator i = m_iregMap.constBegin();
|
| 216 |
|
|
while (i != m_iregMap.constEnd())
|
| 217 |
|
|
{
|
| 218 |
|
|
if(i.key()== clock)
|
| 219 |
|
|
{
|
| 220 |
|
|
QVector<EziDebugModule::RegStructure*> iregVec = i.value() ;
|
| 221 |
|
|
for(int j = 0 ; j < iregVec.count();j++)
|
| 222 |
|
|
{
|
| 223 |
|
|
nnum += iregVec.at(j)->m_unBitWidth*iregVec.at(j)->m_unRegNum ;
|
| 224 |
|
|
}
|
| 225 |
|
|
}
|
| 226 |
|
|
++i;
|
| 227 |
|
|
}
|
| 228 |
|
|
return nnum;
|
| 229 |
|
|
}
|
| 230 |
|
|
*/
|
| 231 |
|
|
void EziDebugModule::getBitRangeInChain(const QString& chainname, const QString &clockname, int* startbit,int * endbit)
|
| 232 |
|
|
{
|
| 233 |
|
|
QMap<QString,int> iclockStartBitMap = m_istartChainNum.value(chainname);
|
| 234 |
|
|
*startbit = iclockStartBitMap.value(clockname,-1) ;
|
| 235 |
|
|
|
| 236 |
|
|
QMap<QString,int> iclockEndBitMap = m_iendChainNum.value(chainname);
|
| 237 |
|
|
*endbit =iclockEndBitMap.value(clockname,-1) ;
|
| 238 |
|
|
return ;
|
| 239 |
|
|
}
|
| 240 |
|
|
|
| 241 |
|
|
void EziDebugModule::setBitRangeInChain(const QString& chainname, const QString &clockname, int startbit,int endbit)
|
| 242 |
|
|
{
|
| 243 |
|
|
QMap<QString,int> iclockStartBitMap ;
|
| 244 |
|
|
iclockStartBitMap.insert(clockname,startbit);
|
| 245 |
|
|
m_istartChainNum.insert(chainname,iclockStartBitMap);
|
| 246 |
|
|
|
| 247 |
|
|
|
| 248 |
|
|
QMap<QString,int> iclockEndBitMap ;
|
| 249 |
|
|
iclockEndBitMap.insert(clockname,endbit);
|
| 250 |
|
|
m_iendChainNum.insert(chainname,iclockEndBitMap);
|
| 251 |
|
|
|
| 252 |
|
|
return ;
|
| 253 |
|
|
}
|
| 254 |
|
|
|
| 255 |
|
|
void EziDebugModule::AddToRegMap(const QString &clock,RegStructure*preg)
|
| 256 |
|
|
{
|
| 257 |
|
|
QVector<RegStructure*> iregVec ;
|
| 258 |
|
|
iregVec = m_iregMap.value(clock,iregVec);
|
| 259 |
|
|
|
| 260 |
|
|
iregVec.append(preg);
|
| 261 |
|
|
|
| 262 |
|
|
m_iregMap.insert(clock,iregVec);
|
| 263 |
|
|
return ;
|
| 264 |
|
|
}
|
| 265 |
|
|
|
| 266 |
|
|
/*
|
| 267 |
|
|
void EziDebugModule::addToVaribleRegMap(const QString &clock,RegStructure*preg)
|
| 268 |
|
|
{
|
| 269 |
|
|
QVector<RegStructure*> m_ivreg ;
|
| 270 |
|
|
|
| 271 |
|
|
m_ivreg = m_ivregMap.value(clock,m_ivreg);
|
| 272 |
|
|
|
| 273 |
|
|
m_ivreg.append(preg);
|
| 274 |
|
|
|
| 275 |
|
|
m_ivregMap.insert(clock,m_ivreg);
|
| 276 |
|
|
}
|
| 277 |
|
|
*/
|
| 278 |
|
|
void EziDebugModule::addToDefParameterMap(const QString &instancename, const QString ¶metername ,const QString &value)
|
| 279 |
|
|
{
|
| 280 |
|
|
QMap<QString,QString> iparameter ;
|
| 281 |
|
|
iparameter = m_idefparameter.value(instancename,iparameter) ;
|
| 282 |
|
|
iparameter.insert(parametername,value);
|
| 283 |
|
|
m_idefparameter.insert(instancename,iparameter);
|
| 284 |
|
|
}
|
| 285 |
|
|
|
| 286 |
|
|
void EziDebugModule::addToParameterMap(const QString ¶metername,const QString &value)
|
| 287 |
|
|
{
|
| 288 |
|
|
m_iparameter.insert(parametername,value);
|
| 289 |
|
|
}
|
| 290 |
|
|
|
| 291 |
|
|
//void EziDebugModule::setInstanceTimes(int count)
|
| 292 |
|
|
//{
|
| 293 |
|
|
// m_ninstanceTimes = count ;
|
| 294 |
|
|
// return ;
|
| 295 |
|
|
//}
|
| 296 |
|
|
|
| 297 |
|
|
|
| 298 |
|
|
void EziDebugModule::setInstancedTimesPerChain(const QString &chainname,int count)
|
| 299 |
|
|
{
|
| 300 |
|
|
m_iinstanceTimesPerChain.insert(chainname,count);
|
| 301 |
|
|
return ;
|
| 302 |
|
|
}
|
| 303 |
|
|
|
| 304 |
|
|
void EziDebugModule::setConstInstanceTimesPerChain(const QString &chainname,int count)
|
| 305 |
|
|
{
|
| 306 |
|
|
m_iconstInstanceTimesPerChain.insert(chainname,count);
|
| 307 |
|
|
return ;
|
| 308 |
|
|
}
|
| 309 |
|
|
|
| 310 |
|
|
void EziDebugModule::setEziDebugCoreCounts(const QString &chainname,int count)
|
| 311 |
|
|
{
|
| 312 |
|
|
m_ieziDebugCoreCounts.insert(chainname,count);
|
| 313 |
|
|
return ;
|
| 314 |
|
|
}
|
| 315 |
|
|
|
| 316 |
|
|
int EziDebugModule::getEziDebugCoreCounts(const QString &chainname)
|
| 317 |
|
|
{
|
| 318 |
|
|
return m_ieziDebugCoreCounts.value(chainname,0);
|
| 319 |
|
|
}
|
| 320 |
|
|
|
| 321 |
|
|
void EziDebugModule::setEziDebugWireCounts(const QString &chainname,int count)
|
| 322 |
|
|
{
|
| 323 |
|
|
m_ieziDebugWireCounts.insert(chainname,count);
|
| 324 |
|
|
return ;
|
| 325 |
|
|
}
|
| 326 |
|
|
|
| 327 |
|
|
int EziDebugModule::getEziDebugWireCounts(const QString &chainname)
|
| 328 |
|
|
{
|
| 329 |
|
|
return m_ieziDebugWireCounts.value(chainname,0);
|
| 330 |
|
|
}
|
| 331 |
|
|
|
| 332 |
|
|
|
| 333 |
|
|
void EziDebugModule::AddToClockWireNameMap(const QString& chainname,const QString& clockname,const QString& lastwirename)
|
| 334 |
|
|
{
|
| 335 |
|
|
QMap<QString,QString> iclockWireMap ;
|
| 336 |
|
|
iclockWireMap = m_iclockWireNameMap.value(chainname);
|
| 337 |
|
|
iclockWireMap.insert(clockname,lastwirename);
|
| 338 |
|
|
m_iclockWireNameMap.insert(chainname,iclockWireMap);
|
| 339 |
|
|
return ;
|
| 340 |
|
|
}
|
| 341 |
|
|
|
| 342 |
|
|
void EziDebugModule::setAddCodeFlag(bool flag)
|
| 343 |
|
|
{
|
| 344 |
|
|
m_isaddedCode = flag ;
|
| 345 |
|
|
return ;
|
| 346 |
|
|
}
|
| 347 |
|
|
|
| 348 |
|
|
void EziDebugModule::setRegInfoToInitalState(void)
|
| 349 |
|
|
{
|
| 350 |
|
|
// 所有时钟
|
| 351 |
|
|
int nregCount = 0 ;
|
| 352 |
|
|
QMap<QString,QVector<RegStructure*> >::iterator iRegMapIter = m_iregMap.begin() ;
|
| 353 |
|
|
while(iRegMapIter != m_iregMap.end())
|
| 354 |
|
|
{
|
| 355 |
|
|
QString iclock = iRegMapIter.key() ;
|
| 356 |
|
|
QVector<RegStructure*> iregVec = iRegMapIter.value() ;
|
| 357 |
|
|
for(;nregCount < iregVec.count() ;nregCount++)
|
| 358 |
|
|
{
|
| 359 |
|
|
RegStructure* preg = iregVec.at(nregCount) ;
|
| 360 |
|
|
|
| 361 |
|
|
preg->m_unMaxRegNum = 0 ;
|
| 362 |
|
|
preg->m_eRegNumEndian = endianOther ;
|
| 363 |
|
|
preg->m_eRegNumType = attributeOther ;
|
| 364 |
|
|
preg->m_unMaxBitWidth = 0 ;
|
| 365 |
|
|
preg->m_eRegBitWidthEndian = endianOther ;
|
| 366 |
|
|
preg->m_eRegBitWidthType = attributeOther ;
|
| 367 |
|
|
preg->m_unStartNum = 0 ;
|
| 368 |
|
|
preg->m_unEndNum = 0 ;
|
| 369 |
|
|
preg->m_unRegNum = 0 ;
|
| 370 |
|
|
preg->m_unStartBit = 0 ;
|
| 371 |
|
|
preg->m_unEndBit = 0 ;
|
| 372 |
|
|
preg->m_unRegBitWidth = 0 ;
|
| 373 |
|
|
}
|
| 374 |
|
|
m_iregMap.insert(iclock ,iregVec);
|
| 375 |
|
|
|
| 376 |
|
|
++iRegMapIter ;
|
| 377 |
|
|
}
|
| 378 |
|
|
|
| 379 |
|
|
}
|
| 380 |
|
|
|
| 381 |
|
|
|
| 382 |
|
|
bool EziDebugModule::isChainCompleted(EziDebugScanChain *pchain)
|
| 383 |
|
|
{
|
| 384 |
|
|
int nstartPos = 0 ;
|
| 385 |
|
|
int nendPos = 0 ;
|
| 386 |
|
|
bool isFinded = false ;
|
| 387 |
|
|
//QString iregName ;
|
| 388 |
|
|
QStringList iinstList = pchain->getInstanceItemList() ;
|
| 389 |
|
|
QStringList iregRearchResult ;
|
| 390 |
|
|
|
| 391 |
|
|
|
| 392 |
|
|
QMap<QString,QVector<QStringList> > iregListMap = pchain->getRegChain() ;
|
| 393 |
|
|
|
| 394 |
|
|
QMap<QString,QString>::const_iterator imoduleClockIter = m_iclockMap.constBegin() ;
|
| 395 |
|
|
|
| 396 |
|
|
while(imoduleClockIter != m_iclockMap.constEnd())
|
| 397 |
|
|
{
|
| 398 |
|
|
iregRearchResult.clear();
|
| 399 |
|
|
QMap<QString,QVector<QStringList> >::const_iterator i = iregListMap.constBegin();
|
| 400 |
|
|
|
| 401 |
|
|
while(i != iregListMap.constEnd())
|
| 402 |
|
|
{
|
| 403 |
|
|
QVector<QStringList> iregListVec = i.value();
|
| 404 |
|
|
|
| 405 |
|
|
for(int m = 0 ; m < iregListVec.count() ; m++)
|
| 406 |
|
|
{
|
| 407 |
|
|
QStringList iregList = iregListVec.at(m) ;
|
| 408 |
|
|
// modulename#instancename#clockname#hibername#regname
|
| 409 |
|
|
nstartPos = iregList.indexOf(QRegExp(m_imoduleName + QObject::tr("#\\w+") + imoduleClockIter.key() + QObject::tr(".*")),0) ;
|
| 410 |
|
|
if(nstartPos != -1)
|
| 411 |
|
|
{
|
| 412 |
|
|
// 找到instance name
|
| 413 |
|
|
isFinded = true ;
|
| 414 |
|
|
nendPos = iregList.lastIndexOf(QRegExp(m_imoduleName + QObject::tr("#\\w+") + imoduleClockIter.key() + QObject::tr(".*")));
|
| 415 |
|
|
|
| 416 |
|
|
// 还要继续查找
|
| 417 |
|
|
if(-1 != nendPos)
|
| 418 |
|
|
{
|
| 419 |
|
|
for(int n = nstartPos ; n <= nendPos ; n++)
|
| 420 |
|
|
{
|
| 421 |
|
|
iregRearchResult << iregList.at(n);
|
| 422 |
|
|
}
|
| 423 |
|
|
break ;
|
| 424 |
|
|
}
|
| 425 |
|
|
}
|
| 426 |
|
|
}
|
| 427 |
|
|
|
| 428 |
|
|
// no finded
|
| 429 |
|
|
if(!isFinded)
|
| 430 |
|
|
{
|
| 431 |
|
|
// 换个时钟链
|
| 432 |
|
|
++i ;
|
| 433 |
|
|
continue ;
|
| 434 |
|
|
}
|
| 435 |
|
|
|
| 436 |
|
|
QString iregName ;
|
| 437 |
|
|
QString iregNum ;
|
| 438 |
|
|
QString ibitWidth ;
|
| 439 |
|
|
QString icombinatedStr ;
|
| 440 |
|
|
|
| 441 |
|
|
// finded
|
| 442 |
|
|
QStringList icompareOne ;
|
| 443 |
|
|
QStringList icompareSecond ;
|
| 444 |
|
|
if((nendPos != -1)&&(nstartPos != -1))
|
| 445 |
|
|
{
|
| 446 |
|
|
// 将链状 寄存器 转换成 字符串
|
| 447 |
|
|
for(int i = 0 ; i < iregRearchResult.count(); i++)
|
| 448 |
|
|
{
|
| 449 |
|
|
iregName = iregRearchResult.at(i).split('#').at(4);
|
| 450 |
|
|
ibitWidth = iregRearchResult.at(i).split('#').at(7);
|
| 451 |
|
|
iregNum = iregRearchResult.at(i).split('#').at(10);
|
| 452 |
|
|
|
| 453 |
|
|
icombinatedStr = iregName \
|
| 454 |
|
|
+ QObject::tr("#") \
|
| 455 |
|
|
+ ibitWidth \
|
| 456 |
|
|
+ QObject::tr("#") \
|
| 457 |
|
|
+ iregNum ;
|
| 458 |
|
|
icompareSecond << icombinatedStr ;
|
| 459 |
|
|
}
|
| 460 |
|
|
icompareSecond.removeDuplicates();
|
| 461 |
|
|
icompareSecond.sort();
|
| 462 |
|
|
|
| 463 |
|
|
QVector<EziDebugModule::RegStructure*> imoduleRegVec = m_iregMap.value(imoduleClockIter.key()) ;
|
| 464 |
|
|
for(int j = 0 ; j < imoduleRegVec.count() ; ++j)
|
| 465 |
|
|
{
|
| 466 |
|
|
EziDebugModule::RegStructure* preg = imoduleRegVec.at(j);
|
| 467 |
|
|
iregName = QString::fromAscii(preg->m_pRegName);
|
| 468 |
|
|
ibitWidth = QString::fromAscii(preg->m_pExpString) ;
|
| 469 |
|
|
iregNum = QString::fromAscii(preg->m_pregNum) ;
|
| 470 |
|
|
|
| 471 |
|
|
|
| 472 |
|
|
icombinatedStr = iregName \
|
| 473 |
|
|
+ QObject::tr("#") \
|
| 474 |
|
|
+ ibitWidth \
|
| 475 |
|
|
+ QObject::tr("#") \
|
| 476 |
|
|
+ iregNum ;
|
| 477 |
|
|
|
| 478 |
|
|
icompareOne << icombinatedStr ;
|
| 479 |
|
|
}
|
| 480 |
|
|
icompareOne.sort();
|
| 481 |
|
|
|
| 482 |
|
|
if(icompareOne == icompareSecond)
|
| 483 |
|
|
{
|
| 484 |
|
|
break ;
|
| 485 |
|
|
}
|
| 486 |
|
|
else
|
| 487 |
|
|
{
|
| 488 |
|
|
qDebug() << "EziDebug warning:The chain is destroyed!" ;
|
| 489 |
|
|
qDebug() << "EziDebug warning:first string" << icompareOne << endl;
|
| 490 |
|
|
qDebug() << "EziDebug warning:second string" << icompareSecond << endl;
|
| 491 |
|
|
return 0 ;
|
| 492 |
|
|
}
|
| 493 |
|
|
}
|
| 494 |
|
|
else
|
| 495 |
|
|
{
|
| 496 |
|
|
qDebug() << "EziDebug warning: pos is not right!";
|
| 497 |
|
|
return 0 ;
|
| 498 |
|
|
}
|
| 499 |
|
|
}
|
| 500 |
|
|
++imoduleClockIter ;
|
| 501 |
|
|
}
|
| 502 |
|
|
|
| 503 |
|
|
|
| 504 |
|
|
iinstList.removeDuplicates() ;
|
| 505 |
|
|
|
| 506 |
|
|
for(int i = 0 ; i< m_iinstanceNameList.count() ;i++)
|
| 507 |
|
|
{
|
| 508 |
|
|
if(iinstList.contains(m_iinstanceNameList.at(i)))
|
| 509 |
|
|
{
|
| 510 |
|
|
continue ;
|
| 511 |
|
|
}
|
| 512 |
|
|
else
|
| 513 |
|
|
{
|
| 514 |
|
|
qDebug() << "EziDebug warning:The chain is destroyed!" ;
|
| 515 |
|
|
qDebug() << "EziDebug warning:old list" << iinstList ;
|
| 516 |
|
|
qDebug() << "EziDebug warning:new list" << m_iinstanceNameList ;
|
| 517 |
|
|
return 0 ;
|
| 518 |
|
|
}
|
| 519 |
|
|
}
|
| 520 |
|
|
|
| 521 |
|
|
return 1 ;
|
| 522 |
|
|
}
|
| 523 |
|
|
|
| 524 |
|
|
bool EziDebugModule::isChainCompleted(EziDebugModule *pmodue)
|
| 525 |
|
|
{
|
| 526 |
|
|
QStringList icompareOne ;
|
| 527 |
|
|
QStringList icompareSecond ;
|
| 528 |
|
|
QString icombinatedStr ;
|
| 529 |
|
|
QString iregName ;
|
| 530 |
|
|
QString iregNum ;
|
| 531 |
|
|
QString iendian ;
|
| 532 |
|
|
QString ibitWidth ;
|
| 533 |
|
|
QStringList iinstList = pmodue->getInstanceList() ;
|
| 534 |
|
|
|
| 535 |
|
|
QMap<QString,QString> iclockMap = pmodue->getClockSignal();
|
| 536 |
|
|
|
| 537 |
|
|
if(iclockMap != m_iclockMap)
|
| 538 |
|
|
{
|
| 539 |
|
|
qDebug() << "EziDebug warning:The chain is destroyed!" ;
|
| 540 |
|
|
qDebug() << "EziDebug warning:old clock" << iclockMap ;
|
| 541 |
|
|
qDebug() << "EziDebug warning:old clock" << m_iclockMap ;
|
| 542 |
|
|
return 0 ;
|
| 543 |
|
|
}
|
| 544 |
|
|
|
| 545 |
|
|
QMap<QString,QString>::const_iterator imoduleClockIter = iclockMap.constBegin() ;
|
| 546 |
|
|
while(imoduleClockIter != iclockMap.constEnd())
|
| 547 |
|
|
{
|
| 548 |
|
|
QVector<EziDebugModule::RegStructure*> imoduleRegVec = m_iregMap.value(imoduleClockIter.key()) ;
|
| 549 |
|
|
for(int j = 0 ; j < imoduleRegVec.count() ; ++j)
|
| 550 |
|
|
{
|
| 551 |
|
|
EziDebugModule::RegStructure* preg = imoduleRegVec.at(j);
|
| 552 |
|
|
iregName = QString::fromAscii(preg->m_pRegName);
|
| 553 |
|
|
// iregNum = QString::number(preg->m_unRegNum) ;
|
| 554 |
|
|
// iendian = QString::number((int)preg->m_isEndian) ;
|
| 555 |
|
|
// ibitWidth = QString::number((int)preg->m_unBitWidth) ;
|
| 556 |
|
|
icombinatedStr = iregName \
|
| 557 |
|
|
+ QObject::tr("%") \
|
| 558 |
|
|
+ iregNum \
|
| 559 |
|
|
+ QObject::tr("%") \
|
| 560 |
|
|
+ ibitWidth \
|
| 561 |
|
|
+ QObject::tr("%") \
|
| 562 |
|
|
+ iendian ;
|
| 563 |
|
|
icompareOne << icombinatedStr ;
|
| 564 |
|
|
}
|
| 565 |
|
|
icompareOne.sort();
|
| 566 |
|
|
|
| 567 |
|
|
|
| 568 |
|
|
imoduleRegVec = pmodue->getReg(imoduleClockIter.key()) ;
|
| 569 |
|
|
|
| 570 |
|
|
for(int j = 0 ; j < imoduleRegVec.count() ; ++j)
|
| 571 |
|
|
{
|
| 572 |
|
|
EziDebugModule::RegStructure* preg = imoduleRegVec.at(j);
|
| 573 |
|
|
iregName = QString::fromAscii(preg->m_pRegName);
|
| 574 |
|
|
// iregNum = QString::number(preg->m_unRegNum) ;
|
| 575 |
|
|
// iendian = QString::number((int)preg->m_isEndian) ;
|
| 576 |
|
|
// ibitWidth = QString::number((int)preg->m_unBitWidth) ;
|
| 577 |
|
|
icombinatedStr = iregName \
|
| 578 |
|
|
+ QObject::tr("%") \
|
| 579 |
|
|
+ iregNum \
|
| 580 |
|
|
+ QObject::tr("%") \
|
| 581 |
|
|
+ ibitWidth \
|
| 582 |
|
|
+ QObject::tr("%") \
|
| 583 |
|
|
+ iendian ;
|
| 584 |
|
|
icompareSecond << icombinatedStr ;
|
| 585 |
|
|
}
|
| 586 |
|
|
icompareSecond.sort();
|
| 587 |
|
|
|
| 588 |
|
|
if(icompareOne == icompareSecond)
|
| 589 |
|
|
{
|
| 590 |
|
|
++imoduleClockIter ;
|
| 591 |
|
|
continue ;
|
| 592 |
|
|
}
|
| 593 |
|
|
else
|
| 594 |
|
|
{
|
| 595 |
|
|
qDebug() << "EziDebug warning:The chain is destroyed!" ;
|
| 596 |
|
|
qDebug() << "EziDebug warning:old string" << icompareOne ;
|
| 597 |
|
|
qDebug() << "EziDebug warning:new string" << icompareSecond ;
|
| 598 |
|
|
return 0 ;
|
| 599 |
|
|
}
|
| 600 |
|
|
++imoduleClockIter ;
|
| 601 |
|
|
}
|
| 602 |
|
|
|
| 603 |
|
|
for(int i = 0 ; i< m_iinstanceNameList.count() ;i++)
|
| 604 |
|
|
{
|
| 605 |
|
|
if(iinstList.contains(m_iinstanceNameList.at(i)))
|
| 606 |
|
|
{
|
| 607 |
|
|
continue ;
|
| 608 |
|
|
}
|
| 609 |
|
|
else
|
| 610 |
|
|
{
|
| 611 |
|
|
qDebug() << "EziDebug warning:The chain is destroyed!" ;
|
| 612 |
|
|
qDebug() << "EziDebug warning:old list" << iinstList ;
|
| 613 |
|
|
qDebug() << "EziDebug warning:new list" << m_iinstanceNameList ;
|
| 614 |
|
|
return 0 ;
|
| 615 |
|
|
}
|
| 616 |
|
|
}
|
| 617 |
|
|
|
| 618 |
|
|
return 1 ;
|
| 619 |
|
|
}
|
| 620 |
|
|
|
| 621 |
|
|
int EziDebugModule::getInstanceTimes(void)
|
| 622 |
|
|
{
|
| 623 |
|
|
return m_ninstanceTimes ;
|
| 624 |
|
|
}
|
| 625 |
|
|
|
| 626 |
|
|
QString EziDebugModule::getChainClockWireNameMap(const QString& chainname ,const QString& clockname)
|
| 627 |
|
|
{
|
| 628 |
|
|
QMap<QString,QString> iclockWireMap ;
|
| 629 |
|
|
iclockWireMap = m_iclockWireNameMap.value(chainname);
|
| 630 |
|
|
return iclockWireMap.value(clockname,QString());
|
| 631 |
|
|
}
|
| 632 |
|
|
|
| 633 |
|
|
bool EziDebugModule::isLibaryCore(void)
|
| 634 |
|
|
{
|
| 635 |
|
|
return m_isLibaryCore ;
|
| 636 |
|
|
}
|
| 637 |
|
|
|
| 638 |
|
|
void EziDebugModule::setLibaryCoreFlag(bool flag)
|
| 639 |
|
|
{
|
| 640 |
|
|
m_isLibaryCore = flag ;
|
| 641 |
|
|
}
|
| 642 |
|
|
|
| 643 |
|
|
void EziDebugModule::clearChainInfo(const QString& chainname)
|
| 644 |
|
|
{
|
| 645 |
|
|
m_iclockWireNameMap.remove(chainname);
|
| 646 |
|
|
m_istartChainNum.remove(chainname);
|
| 647 |
|
|
m_iendChainNum.remove(chainname);
|
| 648 |
|
|
m_iinstanceTimesPerChain.remove(chainname);
|
| 649 |
|
|
m_iconstInstanceTimesPerChain.remove(chainname);
|
| 650 |
|
|
m_ieziDebugCoreCounts.remove(chainname);
|
| 651 |
|
|
m_ieziDebugWireCounts.remove(chainname);
|
| 652 |
|
|
return ;
|
| 653 |
|
|
}
|
| 654 |
|
|
|
| 655 |
|
|
int EziDebugModule::getAllRegMap(QString clock ,QVector<EziDebugModule::RegStructure*> &sregVec,QVector<EziDebugModule::RegStructure*> &vregVec)
|
| 656 |
|
|
{
|
| 657 |
|
|
// 根据 m_iregMap 所有寄存器中的 动、静标志 来获取所有的寄存器
|
| 658 |
|
|
int nregCount = 0 ;
|
| 659 |
|
|
QVector<RegStructure*> iregVec ;
|
| 660 |
|
|
iregVec = m_iregMap.value(clock ,iregVec) ;
|
| 661 |
|
|
for(;nregCount < iregVec.count();nregCount++)
|
| 662 |
|
|
{
|
| 663 |
|
|
RegStructure* preg = iregVec.at(nregCount);
|
| 664 |
|
|
if((preg->m_eRegNumType == attributeDynamic)\
|
| 665 |
|
|
||(preg->m_eRegBitWidthType == attributeDynamic))
|
| 666 |
|
|
{
|
| 667 |
|
|
vregVec.append(preg);
|
| 668 |
|
|
}
|
| 669 |
|
|
else if((preg->m_eRegNumType == attributeOther)\
|
| 670 |
|
|
||(preg->m_eRegBitWidthType == attributeOther))
|
| 671 |
|
|
{
|
| 672 |
|
|
qDebug() << "EziDebug Error: The reg map is wrong!";
|
| 673 |
|
|
return 1 ;
|
| 674 |
|
|
}
|
| 675 |
|
|
else
|
| 676 |
|
|
{
|
| 677 |
|
|
sregVec.append(preg);
|
| 678 |
|
|
}
|
| 679 |
|
|
}
|
| 680 |
|
|
}
|
| 681 |
|
|
|
| 682 |
|
|
void EziDebugModule::calInstanceRegData(EziDebugPrj *prj , const QString &instancename)
|
| 683 |
|
|
{
|
| 684 |
|
|
int nFirstBit = 0 ;
|
| 685 |
|
|
int nSecondBit = 0 ;
|
| 686 |
|
|
int nregNumFirstBit = 0 ;
|
| 687 |
|
|
int nregNumSecondBit = 0 ;
|
| 688 |
|
|
int nregNum = 0 ;
|
| 689 |
|
|
int nbitWidth = 0 ;
|
| 690 |
|
|
bool isParamInvolveMacro = false ;
|
| 691 |
|
|
|
| 692 |
|
|
QString imacroPrefix("`");
|
| 693 |
|
|
QRegExp imacroStr("`(\\w+)") ;
|
| 694 |
|
|
QMap<QString,QString> imacroMap = prj->getMacroMap();
|
| 695 |
|
|
QMap<QString,QString> idefParamMap = prj->getdefparam(instancename);
|
| 696 |
|
|
// 加入到module的defparameter中
|
| 697 |
|
|
if(idefParamMap.count())
|
| 698 |
|
|
{
|
| 699 |
|
|
m_idefparameter.insert(instancename ,idefParamMap);
|
| 700 |
|
|
}
|
| 701 |
|
|
|
| 702 |
|
|
QMap<QString,QString>::const_iterator iparamIter = m_iparameter.constBegin() ;
|
| 703 |
|
|
|
| 704 |
|
|
QMap<QString,QVector<RegStructure*> >::const_iterator i = m_iregMap.constBegin() ;
|
| 705 |
|
|
|
| 706 |
|
|
if(!prj)
|
| 707 |
|
|
{
|
| 708 |
|
|
return ;
|
| 709 |
|
|
}
|
| 710 |
|
|
|
| 711 |
|
|
if(!m_isSubstituted)
|
| 712 |
|
|
{
|
| 713 |
|
|
while(i != m_iregMap.constEnd())
|
| 714 |
|
|
{
|
| 715 |
|
|
QVector<RegStructure*> iregVec = i.value();
|
| 716 |
|
|
for(int j = 0 ; j < iregVec.count() ; j++)
|
| 717 |
|
|
{
|
| 718 |
|
|
RegStructure* preg = iregVec.at(j) ;
|
| 719 |
|
|
|
| 720 |
|
|
QString iregWidth = QString::fromAscii(preg->m_pExpString) ;
|
| 721 |
|
|
QString iregNum = QString::fromAscii(preg->m_pregNum);
|
| 722 |
|
|
// 排出 由于 define 引入的 parameter
|
| 723 |
|
|
while(-1 != imacroStr.indexIn(iregWidth))
|
| 724 |
|
|
{
|
| 725 |
|
|
QString icapMacroStr = imacroStr.cap(1) ;
|
| 726 |
|
|
iregWidth = iregWidth.replace(imacroPrefix+icapMacroStr,imacroMap.value(icapMacroStr));
|
| 727 |
|
|
}
|
| 728 |
|
|
|
| 729 |
|
|
while(-1 != imacroStr.indexIn(iregNum))
|
| 730 |
|
|
{
|
| 731 |
|
|
QString icapMacroStr = imacroStr.cap(1) ;
|
| 732 |
|
|
iregNum = iregNum.replace(imacroPrefix+icapMacroStr,imacroMap.value(icapMacroStr));
|
| 733 |
|
|
}
|
| 734 |
|
|
|
| 735 |
|
|
// 检测 位宽中 是否存在 parameter ,
|
| 736 |
|
|
qstrcpy(preg->m_pExpNoMacroString ,iregWidth.toAscii().constData()) ;
|
| 737 |
|
|
qstrcpy(preg->m_pregNumNoMacroString,iregNum.toAscii().constData()) ;
|
| 738 |
|
|
}
|
| 739 |
|
|
++i ;
|
| 740 |
|
|
}
|
| 741 |
|
|
m_isSubstituted = true ;
|
| 742 |
|
|
}
|
| 743 |
|
|
|
| 744 |
|
|
i = m_iregMap.constBegin() ;
|
| 745 |
|
|
while(i != m_iregMap.constEnd())
|
| 746 |
|
|
{
|
| 747 |
|
|
QVector<RegStructure*> iregVec = i.value();
|
| 748 |
|
|
for(int j = 0 ; j < iregVec.count() ; j++)
|
| 749 |
|
|
{
|
| 750 |
|
|
RegStructure* preg = iregVec.at(j) ;
|
| 751 |
|
|
RegStructure* pnewReg = new RegStructure ;
|
| 752 |
|
|
QVector<RegStructure*> iregVec ;
|
| 753 |
|
|
QMap<QString ,QVector<RegStructure*> > iclockRegMap ;
|
| 754 |
|
|
|
| 755 |
|
|
memcpy((char*)pnewReg ,(char*)preg ,sizeof(struct RegStructure));
|
| 756 |
|
|
|
| 757 |
|
|
QString iregWidth = QString::fromAscii(preg->m_pExpNoMacroString);
|
| 758 |
|
|
QString iregNum = QString::fromAscii(preg->m_pregNumNoMacroString) ;
|
| 759 |
|
|
// 替换所有的 parameter
|
| 760 |
|
|
iparamIter = m_iparameter.constBegin() ;
|
| 761 |
|
|
while(iparamIter != m_iparameter.constEnd())
|
| 762 |
|
|
{
|
| 763 |
|
|
if(iregWidth.contains(iparamIter.key()))
|
| 764 |
|
|
{
|
| 765 |
|
|
if(idefParamMap.value(iparamIter.key(),QString()).isEmpty())
|
| 766 |
|
|
{
|
| 767 |
|
|
// 用 paramete 替换
|
| 768 |
|
|
iregWidth.replace(iparamIter.key() , iparamIter.value());
|
| 769 |
|
|
}
|
| 770 |
|
|
else
|
| 771 |
|
|
{
|
| 772 |
|
|
// 用 defparam 替换
|
| 773 |
|
|
iregWidth.replace(iparamIter.key() , idefParamMap.value(iparamIter.key()));
|
| 774 |
|
|
}
|
| 775 |
|
|
|
| 776 |
|
|
// 排出 parameter 引入 define 导致 交替引用
|
| 777 |
|
|
while(-1 != imacroStr.indexIn(iregWidth))
|
| 778 |
|
|
{
|
| 779 |
|
|
QString icapMacroStr = imacroStr.cap(1) ;
|
| 780 |
|
|
iregWidth = iregWidth.replace(imacroPrefix+icapMacroStr,imacroMap.value(icapMacroStr));
|
| 781 |
|
|
isParamInvolveMacro = true ;
|
| 782 |
|
|
}
|
| 783 |
|
|
|
| 784 |
|
|
if(isParamInvolveMacro)
|
| 785 |
|
|
{
|
| 786 |
|
|
// 重新扫描 是否含有 parameter
|
| 787 |
|
|
iparamIter = m_iparameter.constBegin() ;
|
| 788 |
|
|
isParamInvolveMacro = false ;
|
| 789 |
|
|
continue ;
|
| 790 |
|
|
}
|
| 791 |
|
|
}
|
| 792 |
|
|
++iparamIter ;
|
| 793 |
|
|
}
|
| 794 |
|
|
|
| 795 |
|
|
if(!iregWidth.compare("1"))
|
| 796 |
|
|
{
|
| 797 |
|
|
nbitWidth = 1 ;
|
| 798 |
|
|
nFirstBit = 0 ;
|
| 799 |
|
|
nSecondBit = 0 ;
|
| 800 |
|
|
}
|
| 801 |
|
|
else
|
| 802 |
|
|
{
|
| 803 |
|
|
getBitRange(iregWidth,&nFirstBit,&nSecondBit) ;
|
| 804 |
|
|
nbitWidth = qAbs(nFirstBit - nSecondBit) + 1 ;
|
| 805 |
|
|
}
|
| 806 |
|
|
|
| 807 |
|
|
|
| 808 |
|
|
// copy to new reg pointer
|
| 809 |
|
|
pnewReg->m_unStartBit = nFirstBit ;
|
| 810 |
|
|
pnewReg->m_unEndBit = nSecondBit ;
|
| 811 |
|
|
pnewReg->m_unRegBitWidth = nbitWidth ;
|
| 812 |
|
|
pnewReg->m_unMaxBitWidth = 0 ;
|
| 813 |
|
|
pnewReg->m_eRegNumType = attributeOther ;
|
| 814 |
|
|
|
| 815 |
|
|
if(nFirstBit > nSecondBit)
|
| 816 |
|
|
{
|
| 817 |
|
|
pnewReg->m_eRegBitWidthEndian = endianBig ;
|
| 818 |
|
|
}
|
| 819 |
|
|
else if(nFirstBit < nSecondBit)
|
| 820 |
|
|
{
|
| 821 |
|
|
pnewReg->m_eRegBitWidthEndian = endianLittle ;
|
| 822 |
|
|
}
|
| 823 |
|
|
else
|
| 824 |
|
|
{
|
| 825 |
|
|
if(nbitWidth == 1)
|
| 826 |
|
|
{
|
| 827 |
|
|
pnewReg->m_eRegBitWidthEndian = endianBig ;
|
| 828 |
|
|
}
|
| 829 |
|
|
else
|
| 830 |
|
|
{
|
| 831 |
|
|
pnewReg->m_eRegBitWidthEndian = endianOther ;
|
| 832 |
|
|
}
|
| 833 |
|
|
}
|
| 834 |
|
|
|
| 835 |
|
|
iparamIter = m_iparameter.constBegin() ;
|
| 836 |
|
|
while(iparamIter != m_iparameter.constEnd())
|
| 837 |
|
|
{
|
| 838 |
|
|
if(iregNum.contains(iparamIter.key()))
|
| 839 |
|
|
{
|
| 840 |
|
|
if(idefParamMap.value(iparamIter.key(),QString()).isEmpty())
|
| 841 |
|
|
{
|
| 842 |
|
|
// 用 paramete 替换
|
| 843 |
|
|
iregNum.replace(iparamIter.key() , iparamIter.value());
|
| 844 |
|
|
}
|
| 845 |
|
|
else
|
| 846 |
|
|
{
|
| 847 |
|
|
// 用 defparam 替换
|
| 848 |
|
|
iregNum.replace(iparamIter.key() , idefParamMap.value(iparamIter.key()));
|
| 849 |
|
|
}
|
| 850 |
|
|
|
| 851 |
|
|
// 排出 parameter 引入 define 导致 交替引用
|
| 852 |
|
|
while(-1 != imacroStr.indexIn(iregNum))
|
| 853 |
|
|
{
|
| 854 |
|
|
QString icapMacroStr = imacroStr.cap(1) ;
|
| 855 |
|
|
iregNum = iregNum.replace(imacroPrefix + icapMacroStr ,imacroMap.value(icapMacroStr));
|
| 856 |
|
|
isParamInvolveMacro = true ;
|
| 857 |
|
|
}
|
| 858 |
|
|
|
| 859 |
|
|
if(isParamInvolveMacro)
|
| 860 |
|
|
{
|
| 861 |
|
|
// 重新扫描 是否含有 parameter
|
| 862 |
|
|
iparamIter = m_iparameter.constBegin() ;
|
| 863 |
|
|
isParamInvolveMacro = false ;
|
| 864 |
|
|
continue ;
|
| 865 |
|
|
}
|
| 866 |
|
|
}
|
| 867 |
|
|
++iparamIter ;
|
| 868 |
|
|
}
|
| 869 |
|
|
|
| 870 |
|
|
|
| 871 |
|
|
if(!iregNum.compare("1"))
|
| 872 |
|
|
{
|
| 873 |
|
|
nregNum = 1 ;
|
| 874 |
|
|
nregNumFirstBit = 0 ;
|
| 875 |
|
|
nregNumSecondBit = 0 ;
|
| 876 |
|
|
}
|
| 877 |
|
|
else
|
| 878 |
|
|
{
|
| 879 |
|
|
if(iregNum.count(":") == 1)
|
| 880 |
|
|
{
|
| 881 |
|
|
// 计算 regnum
|
| 882 |
|
|
getBitRange(iregNum,&nregNumFirstBit,&nregNumSecondBit);
|
| 883 |
|
|
nregNum = qAbs(nregNumFirstBit - nregNumSecondBit) + 1 ;
|
| 884 |
|
|
}
|
| 885 |
|
|
else
|
| 886 |
|
|
{
|
| 887 |
|
|
nregNumFirstBit = 0 ;
|
| 888 |
|
|
nregNumSecondBit = 0 ;
|
| 889 |
|
|
nregNum = 0 ;
|
| 890 |
|
|
}
|
| 891 |
|
|
}
|
| 892 |
|
|
|
| 893 |
|
|
pnewReg->m_unStartNum = nregNumFirstBit ;
|
| 894 |
|
|
pnewReg->m_unEndNum = nregNumSecondBit ;
|
| 895 |
|
|
pnewReg->m_unRegNum = nregNum ;
|
| 896 |
|
|
pnewReg->m_unMaxRegNum = 0 ;
|
| 897 |
|
|
pnewReg->m_eRegBitWidthType = attributeOther ;
|
| 898 |
|
|
|
| 899 |
|
|
|
| 900 |
|
|
if(nregNumFirstBit > nregNumSecondBit)
|
| 901 |
|
|
{
|
| 902 |
|
|
pnewReg->m_eRegNumEndian = endianBig ;
|
| 903 |
|
|
}
|
| 904 |
|
|
else if(nregNumFirstBit < nregNumSecondBit)
|
| 905 |
|
|
{
|
| 906 |
|
|
pnewReg->m_eRegNumEndian = endianLittle ;
|
| 907 |
|
|
}
|
| 908 |
|
|
else
|
| 909 |
|
|
{
|
| 910 |
|
|
if(nregNum == 1)
|
| 911 |
|
|
{
|
| 912 |
|
|
pnewReg->m_eRegNumEndian = endianBig ;
|
| 913 |
|
|
}
|
| 914 |
|
|
else
|
| 915 |
|
|
{
|
| 916 |
|
|
pnewReg->m_eRegNumEndian = endianOther ;
|
| 917 |
|
|
}
|
| 918 |
|
|
}
|
| 919 |
|
|
|
| 920 |
|
|
// add to instance reg map
|
| 921 |
|
|
iclockRegMap = m_iinstanceRegMap.value(instancename , iclockRegMap) ;
|
| 922 |
|
|
iregVec = iclockRegMap.value(QString::fromAscii(pnewReg->m_pclockName),iregVec);
|
| 923 |
|
|
iregVec.append(pnewReg);
|
| 924 |
|
|
iclockRegMap.insert(QString::fromAscii(pnewReg->m_pclockName),iregVec);
|
| 925 |
|
|
m_iinstanceRegMap.insert(instancename,iclockRegMap);
|
| 926 |
|
|
}
|
| 927 |
|
|
++i ;
|
| 928 |
|
|
}
|
| 929 |
|
|
}
|
| 930 |
|
|
|
| 931 |
|
|
EziDebugModule::RegStructure* EziDebugModule::getInstanceReg(QString instancename , QString clock , QString regname)
|
| 932 |
|
|
{
|
| 933 |
|
|
int nRegCount = 0 ;
|
| 934 |
|
|
QMap<QString ,QVector<RegStructure*> > iregMap ;
|
| 935 |
|
|
QVector<RegStructure*> iregVec ;
|
| 936 |
|
|
iregMap = m_iinstanceRegMap.value(instancename,iregMap) ;
|
| 937 |
|
|
iregVec = iregMap.value(clock,iregVec);
|
| 938 |
|
|
for(;nRegCount < iregVec.count();nRegCount++)
|
| 939 |
|
|
{
|
| 940 |
|
|
RegStructure* preg = iregVec.at(nRegCount) ;
|
| 941 |
|
|
if(regname == QString::fromAscii(preg->m_pRegName))
|
| 942 |
|
|
{
|
| 943 |
|
|
return preg ;
|
| 944 |
|
|
}
|
| 945 |
|
|
}
|
| 946 |
|
|
|
| 947 |
|
|
return NULL ;
|
| 948 |
|
|
}
|
| 949 |
|
|
|
| 950 |
|
|
|
| 951 |
|
|
void EziDebugModule::getBitRange(const QString &widthStr , int *startbit , int *endbit)
|
| 952 |
|
|
{
|
| 953 |
|
|
char icalRegWidth[64] = {0} ;
|
| 954 |
|
|
QString istartBit = widthStr.split(":").at(0) ;
|
| 955 |
|
|
QString iendBit = widthStr.split(":").at(1) ;
|
| 956 |
|
|
|
| 957 |
|
|
|
| 958 |
|
|
// 分别截取 高位 与 低位 bit 算出位宽 注: 暂不支持 ?: 操作符
|
| 959 |
|
|
if(widthStr.split(":").size() > 2)
|
| 960 |
|
|
{
|
| 961 |
|
|
qDebug() << "EziDebug Error: the ? : operator is not sopported or encounter error!";
|
| 962 |
|
|
*startbit = 0 ;
|
| 963 |
|
|
*endbit = 0 ;
|
| 964 |
|
|
return ;
|
| 965 |
|
|
}
|
| 966 |
|
|
|
| 967 |
|
|
if((istartBit.size() >= 64)||(iendBit.size() >= 64))
|
| 968 |
|
|
{
|
| 969 |
|
|
qDebug() << "EziDebug Error: the reg width string is too long !";
|
| 970 |
|
|
*startbit = 0 ;
|
| 971 |
|
|
*endbit = 0 ;
|
| 972 |
|
|
return ;
|
| 973 |
|
|
}
|
| 974 |
|
|
|
| 975 |
|
|
qstrcpy(icalRegWidth ,istartBit.toAscii().constData());
|
| 976 |
|
|
reg_scan iregCal ;
|
| 977 |
|
|
iregCal.prog = icalRegWidth ;
|
| 978 |
|
|
iregCal.EvalExp(*startbit);
|
| 979 |
|
|
|
| 980 |
|
|
memset(icalRegWidth,0,64);
|
| 981 |
|
|
qstrcpy(icalRegWidth ,iendBit.toAscii().constData());
|
| 982 |
|
|
iregCal.prog = icalRegWidth ;
|
| 983 |
|
|
iregCal.EvalExp(*endbit);
|
| 984 |
|
|
|
| 985 |
|
|
}
|
| 986 |
|
|
|
| 987 |
|
|
int EziDebugModule::constructChainRegMap(EziDebugPrj * prj ,const QStringList &cominstanceList,QString instancename)
|
| 988 |
|
|
{
|
| 989 |
|
|
int ninstanceCount = 0 ;
|
| 990 |
|
|
QStringList ichainInstanceList ;
|
| 991 |
|
|
int nmaxRegNum = prj->getMaxRegNumPerChain() ;
|
| 992 |
|
|
QMap<QString ,QVector<RegStructure*> >iinstanceRegVecMap ;
|
| 993 |
|
|
|
| 994 |
|
|
// 获取本module在扫描链中所有的例化
|
| 995 |
|
|
for(;ninstanceCount < cominstanceList.count();ninstanceCount++)
|
| 996 |
|
|
{
|
| 997 |
|
|
QString icomStr = cominstanceList.at(ninstanceCount) ;
|
| 998 |
|
|
QRegExp imoduleExp(m_imoduleName + QObject::tr(":\\w+")) ;
|
| 999 |
|
|
imoduleExp.exactMatch(icomStr) ;
|
| 1000 |
|
|
ichainInstanceList.append(icomStr.split(":").at(1));
|
| 1001 |
|
|
}
|
| 1002 |
|
|
|
| 1003 |
|
|
QStringList iinstanceList = ichainInstanceList.filter(instancename) ;
|
| 1004 |
|
|
if(!iinstanceList.count())
|
| 1005 |
|
|
{
|
| 1006 |
|
|
qDebug() << "EziDebug Error: instance name list is wrong , please check the code!";
|
| 1007 |
|
|
return 1 ;
|
| 1008 |
|
|
}
|
| 1009 |
|
|
else
|
| 1010 |
|
|
{
|
| 1011 |
|
|
iinstanceRegVecMap = m_iinstanceRegMap.value(instancename ,iinstanceRegVecMap) ;
|
| 1012 |
|
|
QMap<QString,QVector<RegStructure*> > ibakRegMap = m_iregMap ;
|
| 1013 |
|
|
QMap<QString,QVector<RegStructure*> >::const_iterator iregMapIter = m_iregMap.constBegin() ;
|
| 1014 |
|
|
while(iregMapIter != m_iregMap.constEnd())
|
| 1015 |
|
|
{
|
| 1016 |
|
|
int nRegCount = 0 ;
|
| 1017 |
|
|
QString iclock = iregMapIter.key() ;
|
| 1018 |
|
|
QVector<RegStructure*> ioriginRegVec = iregMapIter.value() ;
|
| 1019 |
|
|
QVector<RegStructure*> iinstanceRegVec = iinstanceRegVecMap.value(iclock) ;
|
| 1020 |
|
|
|
| 1021 |
|
|
if(!iinstanceRegVec.count())
|
| 1022 |
|
|
{
|
| 1023 |
|
|
qDebug() << "EziDebug Error: The instanceReg is not exist!";
|
| 1024 |
|
|
return 1 ;
|
| 1025 |
|
|
}
|
| 1026 |
|
|
|
| 1027 |
|
|
nRegCount = 0 ;
|
| 1028 |
|
|
|
| 1029 |
|
|
for(;nRegCount < ioriginRegVec.count(); nRegCount++)
|
| 1030 |
|
|
{
|
| 1031 |
|
|
RegStructure* poriginReg = ioriginRegVec.at(nRegCount) ;
|
| 1032 |
|
|
RegStructure* pinstanceReg = iinstanceRegVec.at(nRegCount) ;
|
| 1033 |
|
|
|
| 1034 |
|
|
if((poriginReg->m_eRegNumType == attributeOther)&&(poriginReg->m_eRegBitWidthType == attributeOther))
|
| 1035 |
|
|
{
|
| 1036 |
|
|
poriginReg->m_unStartNum = pinstanceReg->m_unStartNum ;
|
| 1037 |
|
|
poriginReg->m_unEndNum = pinstanceReg->m_unEndNum ;
|
| 1038 |
|
|
poriginReg->m_unRegNum = pinstanceReg->m_unRegNum ;
|
| 1039 |
|
|
poriginReg->m_unStartBit = pinstanceReg->m_unStartBit ;
|
| 1040 |
|
|
poriginReg->m_unEndBit = pinstanceReg->m_unEndBit ;
|
| 1041 |
|
|
poriginReg->m_unRegBitWidth = pinstanceReg->m_unRegBitWidth ;
|
| 1042 |
|
|
poriginReg->m_eRegNumEndian = pinstanceReg->m_eRegNumEndian ;
|
| 1043 |
|
|
poriginReg->m_eRegBitWidthEndian = pinstanceReg->m_eRegBitWidthEndian ;
|
| 1044 |
|
|
|
| 1045 |
|
|
poriginReg->m_unMaxBitWidth = (pinstanceReg->m_unRegBitWidth)*(pinstanceReg->m_unRegNum) ;
|
| 1046 |
|
|
poriginReg->m_unMaxRegNum = pinstanceReg->m_unRegNum ;
|
| 1047 |
|
|
poriginReg->m_eRegNumType = attributeStatic ;
|
| 1048 |
|
|
poriginReg->m_eRegBitWidthType = attributeStatic ;
|
| 1049 |
|
|
}
|
| 1050 |
|
|
else
|
| 1051 |
|
|
{
|
| 1052 |
|
|
if((poriginReg->m_unStartBit != pinstanceReg->m_unStartBit)\
|
| 1053 |
|
|
||(poriginReg->m_unEndBit != pinstanceReg->m_unEndBit))
|
| 1054 |
|
|
{
|
| 1055 |
|
|
poriginReg->m_eRegBitWidthType = attributeDynamic ;
|
| 1056 |
|
|
}
|
| 1057 |
|
|
|
| 1058 |
|
|
if((poriginReg->m_unStartNum != pinstanceReg->m_unStartNum)\
|
| 1059 |
|
|
||(poriginReg->m_unEndNum != pinstanceReg->m_unEndNum))
|
| 1060 |
|
|
{
|
| 1061 |
|
|
poriginReg->m_eRegNumType = attributeDynamic ;
|
| 1062 |
|
|
qDebug() << "The reg number is variable!";
|
| 1063 |
|
|
m_iregMap = ibakRegMap ;
|
| 1064 |
|
|
return 3 ;
|
| 1065 |
|
|
}
|
| 1066 |
|
|
|
| 1067 |
|
|
|
| 1068 |
|
|
if((poriginReg->m_eRegNumEndian != pinstanceReg->m_eRegNumEndian)\
|
| 1069 |
|
|
||(poriginReg->m_eRegBitWidthEndian != pinstanceReg->m_eRegBitWidthEndian))
|
| 1070 |
|
|
{
|
| 1071 |
|
|
qDebug() << "The reg number endian or bitwidth endian is variable!";
|
| 1072 |
|
|
m_iregMap = ibakRegMap ;
|
| 1073 |
|
|
return 2 ;
|
| 1074 |
|
|
}
|
| 1075 |
|
|
|
| 1076 |
|
|
// 变化位宽的 最大寄存器个数 以及 最大位宽 检测
|
| 1077 |
|
|
if(poriginReg->m_eRegBitWidthType == attributeDynamic)
|
| 1078 |
|
|
{
|
| 1079 |
|
|
int ninstanceWidth = pinstanceReg->m_unRegNum * pinstanceReg->m_unRegBitWidth ;
|
| 1080 |
|
|
if(ninstanceWidth > nmaxRegNum)
|
| 1081 |
|
|
{
|
| 1082 |
|
|
qDebug() << "The reg bitwidth sum is exceed the max regnum in the chain!";
|
| 1083 |
|
|
m_iregMap = ibakRegMap ;
|
| 1084 |
|
|
return 1 ;
|
| 1085 |
|
|
}
|
| 1086 |
|
|
else
|
| 1087 |
|
|
{
|
| 1088 |
|
|
if(ninstanceWidth > poriginReg->m_unMaxBitWidth)
|
| 1089 |
|
|
{
|
| 1090 |
|
|
poriginReg->m_unMaxBitWidth = ninstanceWidth ;
|
| 1091 |
|
|
}
|
| 1092 |
|
|
}
|
| 1093 |
|
|
}
|
| 1094 |
|
|
}
|
| 1095 |
|
|
|
| 1096 |
|
|
}
|
| 1097 |
|
|
++iregMapIter ;
|
| 1098 |
|
|
}
|
| 1099 |
|
|
}
|
| 1100 |
|
|
|
| 1101 |
|
|
}
|
| 1102 |
|
|
|