OpenCores
URL https://opencores.org/ocsvn/ezidebug/ezidebug/trunk

Subversion Repositories ezidebug

[/] [ezidebug/] [trunk/] [EziDebug_src/] [importdatadialog.cpp] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 EziDebug
#include "importdatadialog.h"
2
#include <QDialog>
3
#include <QPushButton>
4
#include <QLabel>
5
#include <QLineEdit>
6
#include <QGridLayout>
7
#include <QListWidget>
8
#include <QFileDialog>
9
#include <QDebug>
10
#include <QGroupBox>
11
#include <QComboBox>
12
#include "ezidebuginstancetreeitem.h"
13
#include "toolwindow.h"
14
#include "ezidebugmodule.h"
15
#include "ezidebugscanchain.h"
16
 
17
 
18
ImportDataDialog::ImportDataDialog(const QMap<QString,EziDebugInstanceTreeItem*> &itemmap,QWidget *parent):QDialog(parent)
19
{
20
    int ncount = 0 ;
21
    int nmaxSize = 0 ;
22
    EziDebugPrj::TOOL itool ;
23
    ToolWindow* iparentWidget = dynamic_cast<ToolWindow*>(parent) ;
24
    EziDebugPrj * pprj = const_cast<EziDebugPrj *>(iparentWidget->getCurrentProject()) ;
25
    itool = pprj->getToolType() ;
26
    m_pgroupBox = new QGroupBox("Input item setting",this) ;
27
 
28
    //m_pselectedLabel = new QLabel(this) ;
29
    //m_pselectedItemLineEdit = new QLineEdit(this) ;
30
 
31
    m_ptbFilePathLabel = new  QLabel(tr("Output directory:"),this) ;
32
    m_ptbFilePathButton = new QPushButton(tr(". . ."),this) ;
33
    m_ptbFilePathLineEdit = new QLineEdit(this) ;
34
 
35
    m_pnodeLabel = new QLabel(tr("The Scanchain Node List:"),this) ;
36
    m_pokButton = new QPushButton(tr("Gnerate TestBench"),this) ;
37
    m_pcancelButton = new QPushButton(tr("Cancel"),this) ;
38
 
39
 
40
    m_pnodeList = new QListWidget(this) ;
41
 
42
    QGridLayout *pLayout = new QGridLayout ;
43
    pLayout->addWidget(m_pnodeLabel, 0, 0);
44
    pLayout->addWidget(m_pnodeList, 1, 0,1,6);
45
 
46
    QHBoxLayout *pbuttonLayout = new QHBoxLayout ;
47
    pbuttonLayout->addWidget(m_pokButton) ;
48
    pbuttonLayout->addWidget(m_pcancelButton) ;
49
 
50
    QHBoxLayout *ptbLayout = new QHBoxLayout ;
51
 
52
 
53
    QGridLayout *pchildLayout = new QGridLayout ;
54
 
55
    //pchildLayout->addWidget(m_pselectedLabel , 0 ,0 ,1,2);
56
    //pchildLayout->addWidget(m_pselectedItemLineEdit,0,0,1,2);
57
 
58
 
59
    m_presetPortCombo = new QComboBox(this) ;
60
    m_presetPortEdgeCombo = new QComboBox(this) ;
61
 
62
    m_pportLabel = new QLabel("reset port:",this);
63
    m_pportEdgeLabel =new QLabel("reset edge:",this);
64
    m_pportOtherLabel = new QLabel("other:",this); ;
65
    m_pportOtherLineEdit = new QLineEdit(this) ;
66
    m_pportOtherLineEdit->setDisabled(true);
67
    m_ptbFilePathLineEdit->setDisabled(true);
68
 
69
    pchildLayout->addWidget(m_pportLabel,0,0,1,1,Qt::AlignLeft);
70
    pchildLayout->addWidget(m_pportEdgeLabel,1,0,1,1,Qt::AlignLeft);
71
 
72
    // ,Qt::AlignRight
73
    pchildLayout->addWidget(m_presetPortCombo,0,1,1,2);
74
    pchildLayout->addWidget(m_presetPortEdgeCombo,1,1,1,2);
75
 
76
    pchildLayout->addWidget(m_pportOtherLabel,2,0,1,2,Qt::AlignLeft);
77
    pchildLayout->addWidget(m_pportOtherLineEdit,2,1,1,2,Qt::AlignRight);
78
 
79
 
80
    m_pgroupBox1 = new QGroupBox("Input data file",this) ;
81
    QGridLayout *pchildLayout1 = new QGridLayout ;
82
 
83
    //m_pilaCombo = new QComboBox(this) ;
84
    m_pfindFileButton = new  QPushButton(tr("..."),this) ;
85
    m_pilaLine = new QLineEdit(this) ;
86
    m_pilaLine->setDisabled(true);
87
    //pchildLayout1->addWidget(m_pilaCombo,0,3,1,2);
88
    pchildLayout1->addWidget(m_pilaLine,0,0,1,2,Qt::AlignLeft);
89
    pchildLayout1->addWidget(m_pfindFileButton,0,2);
90
 
91
    m_pgroupBox1->setLayout(pchildLayout1);
92
    //
93
    pLayout->addWidget(m_pgroupBox1,3,3,1,3,Qt::AlignLeft);
94
 
95
 
96
    if(itool == EziDebugPrj::ToolQuartus)
97
    {
98
 
99
        connect(m_pfindFileButton, SIGNAL(clicked()),
100
                this, SLOT(findDataFileClicked()));
101
    }
102
    else
103
    {
104
 
105
        connect(m_pfindFileButton, SIGNAL(clicked()),
106
                this, SLOT(findDataFile()));
107
    }
108
 
109
    ptbLayout->addWidget(m_ptbFilePathLabel);
110
    ptbLayout->addWidget(m_ptbFilePathLineEdit);
111
    ptbLayout->addWidget(m_ptbFilePathButton);
112
 
113
    m_pgroupBox->setLayout(pchildLayout);
114
 
115
    //
116
    pLayout->addWidget(m_pgroupBox,3,0,1,3,Qt::AlignLeft);
117
    pLayout->addLayout(ptbLayout,4,0,1,6);
118
 
119
 
120
    pLayout->addLayout(pbuttonLayout,5,5,1,1, Qt::AlignRight);
121
    //
122
 
123
    QVBoxLayout *pmainLayout = new QVBoxLayout;
124
 
125
    pmainLayout->addLayout(pLayout);
126
 
127
    setLayout(pmainLayout);
128
 
129
    connect(m_pokButton, SIGNAL(clicked()),
130
            this, SLOT(accept()));
131
 
132
    connect(m_pcancelButton, SIGNAL(clicked()),
133
            this, SLOT(reject()));
134
 
135
 
136
 
137
    connect(m_ptbFilePathButton, SIGNAL(clicked()),
138
            this, SLOT(findSavePathClicked()));
139
 
140
    connect(m_pnodeList,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(showCurrentItem(QListWidgetItem*,QListWidgetItem*)));
141
 
142
    connect(m_presetPortCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(portSignalChange(int))) ;
143
 
144
    connect(m_presetPortEdgeCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(portOtherEdge(int))) ;
145
 
146
    m_pnodeList->setFont(QFont("Times", 10 , QFont::DemiBold));
147
    QMap<QString,EziDebugInstanceTreeItem*>::const_iterator i = itemmap.constBegin();
148
    while(i != itemmap.constEnd())
149
    {
150
        QString ichainName = i.key();
151
        EziDebugInstanceTreeItem* pitem = i.value();
152
        QString ichainItem = tr("chain: %1     Node: %2").arg(ichainName).arg(pitem->getNameData());
153
        int nsize = m_pnodeList->fontMetrics().width(ichainItem);
154
        m_pnodeList->insertItem(ncount,ichainItem);
155
        //m_pnodeList->item(ncount)->setForeground(QBrush(QColor(90,90,252)));
156
        //m_pnodeList->item(ncount)->setFont(QFont("Times", 10 , QFont::DemiBold));
157
        m_pnodeList->item(ncount)->setIcon(QIcon(":/images/ok_1.png"));
158
 
159
        if(nsize > nmaxSize)
160
        {
161
            nmaxSize = nsize ;
162
        }
163
        ncount++;
164
        ++i;
165
    }
166
 
167
    m_ptbFilePathButton->setFont(QFont("Times",10,QFont::Bold)) ;
168
    m_ptbFilePathButton->setAutoDefault(false) ;
169
    //m_pselectedItemLineEdit->setReadOnly(true) ;
170
 
171
    m_ptbFilePathButton->setEnabled(false) ;
172
    m_pokButton->setEnabled(false );
173
 
174
    setWindowTitle(tr("Chose The ScanChain and corresponding Data File")) ;
175
    m_pnodeList->setMinimumHeight(100) ;
176
    m_pnodeList->setMinimumWidth(nmaxSize + 32) ;
177
 
178
    //this->setUpdatesEnabled();
179
    this->setMaximumSize(sizeHint()) ;
180
    this->setMinimumSize(sizeHint());
181
 
182
#if 0
183
         //QGridLayout *pchildLayout2 = new QGridLayout ;
184
         //pchildLayout2->addWidget(m_presetPortCombo,0,0,1,1);
185
         //pchildLayout2->addWidget(m_presetPortEdgeCombo,0,1,1,1);
186
         //m_pgroupBox2->setLayout(pchildLayout2);
187
         //pLayout->addWidget(m_pgroupBox2,3,1,1,2,Qt::AlignRight);
188
 
189
       //m_pfile = new QLineEdit(this) ;
190
        // pLayout->addWidget(m_pilaCombo,3,1,1,1,Qt::AlignLeft);
191
        // pLayout->addWidget(m_pilaLine,3,2,1,1,Qt::AlignLeft);
192
       //QHBoxLayout *pfindFileLayout = new QHBoxLayout ;
193
       //pfindFileLayout->addWidget(m_pilaCombo);
194
       //pfindFileLayout->addWidget(m_pfindFileButton);
195
       //pfindFileLayout->addWidget(m_pilaLine);
196
       //pfindFileLayout->addWidget(m_pfile);
197
      // pLayout->addWidget(m_pilaCombo,2,1);
198
      // pLayout->addWidget(m_pilaLine,2,2);
199
 
200
       //pchildLayout->addLayout(pfindFileLayout);
201
#endif
202
}
203
 
204
const QString &ImportDataDialog::getDataFileName(void) const
205
{
206
    return m_idataFileName ;
207
}
208
const QString &ImportDataDialog::getChainName(void) const
209
{
210
    return m_ichainName ;
211
}
212
 
213
const QString &ImportDataDialog::getOutputDirectory(void) const
214
{
215
    return m_isavePath ;
216
}
217
const QMap<int,QString> &ImportDataDialog::getFileIndexMap(void) const
218
{
219
    return iindexFileMap ;
220
}
221
 
222
void  ImportDataDialog::getResetSig(QString &resetsig,EDGE_TYPE &resetedgetype,QString &otherresetedge)
223
{
224
    resetsig = m_iresetSig ;
225
    resetedgetype = m_eresetEdge ;
226
    otherresetedge = m_iresetEdge ;
227
}
228
 
229
void ImportDataDialog::accept()
230
{
231
    if(m_presetPortCombo->currentText() != "No Reset")
232
    {
233
        m_iresetSig = m_presetPortCombo->currentText() ;
234
    }
235
 
236
    if(m_presetPortEdgeCombo->currentText() == "posedge")
237
    {
238
        m_eresetEdge = edgeTypePosEdge ;
239
    }
240
    else if(m_presetPortEdgeCombo->currentText() == "negedge")
241
    {
242
        m_eresetEdge = edgeTypeNegEdge ;
243
    }
244
    else if(m_presetPortEdgeCombo->currentText() == "other")
245
    {
246
        m_eresetEdge = edgeTypeOtherEdge ;
247
        m_iresetEdge = m_pportOtherLineEdit->text();
248
    }
249
 
250
    QDialog::accept();
251
}
252
 
253
 
254
void ImportDataDialog::findDataFileClicked()
255
{
256
    QString ifileType ;
257
    ToolWindow *parent = dynamic_cast<ToolWindow *>(this->parentWidget()) ;
258
    if(parent)
259
    {
260
        const EziDebugPrj *prj = parent->getCurrentProject();
261
        if(prj)
262
        {
263
            ifileType = "*.txt" ;
264
        }
265
    }
266
 
267
    m_idataFileName   = QFileDialog::getOpenFileName(this,tr("Chose Data file"),QString(),ifileType);
268
    m_idataFileName   = QDir::fromNativeSeparators(m_idataFileName);
269
 
270
    if (!m_idataFileName.isEmpty())
271
    {
272
       QString file = m_idataFileName.split("/").last();
273
       m_pfileLineEdit->setText(file);
274
       m_ptbFilePathButton->setEnabled(true);
275
    }
276
}
277
 
278
void ImportDataDialog::findDataFile()
279
{
280
    int nindex =  iindexFileMap.count() ;
281
    QString ifileType ;
282
    ToolWindow *parent = dynamic_cast<ToolWindow *>(this->parentWidget()) ;
283
    if(parent)
284
    {
285
        const EziDebugPrj *prj = parent->getCurrentProject();
286
        if(prj)
287
        {
288
            ifileType = "*.prn" ;
289
        }
290
    }
291
 
292
    m_idataFileName   = QFileDialog::getOpenFileName(this,tr("Chose Data file"),QString(),ifileType);
293
    m_idataFileName   = QDir::fromNativeSeparators(m_idataFileName);
294
 
295
    if (!m_idataFileName.isEmpty())
296
    {
297
       QString file = m_idataFileName.split("/").last();
298
       iindexFileMap.insert(nindex ,m_idataFileName) ;
299
       m_pilaLine->setText(file);
300
       m_ptbFilePathButton->setEnabled(true);
301
       m_ptbFilePathLineEdit->setEnabled(true);
302
    }
303
 
304
#if 0
305
    if(iindexFileMap.count() == m_pilaCombo->count())
306
    {
307
        m_ptbFilePathButton->setEnabled(true);
308
    }
309
#endif
310
}
311
 
312
void ImportDataDialog::findSavePathClicked()
313
{
314
    m_isavePath = QFileDialog::getExistingDirectory(this,tr("Choose TestBench file output directory"));
315
    if (!m_isavePath.isEmpty())
316
    {
317
       m_ptbFilePathLineEdit->setText(m_isavePath);
318
       m_pokButton->setEnabled(true);
319
    }
320
}
321
 
322
void ImportDataDialog::showCurrentItem(QListWidgetItem* currentitem,QListWidgetItem* previousitem)
323
{
324
    EziDebugInstanceTreeItem *pitem = NULL ;
325
    EziDebugModule *pmodule = NULL ;
326
    EziDebugScanChain *pchain = NULL ;
327
    //int nunitCount = 0 ;
328
    int nportCount = 0 ;
329
    //int nbitCount = 0 ;
330
    QString imoduleName ;
331
    previousitem = previousitem ;
332
    if(currentitem)
333
    {
334
        QString inode = currentitem->text() ;
335
        //QString inodeName = inode.split(QRegExp(tr("\\s+"))).at(3);
336
        //m_pselectedItemLineEdit->setText(inodeName);
337
        m_ichainName = inode.split(QRegExp(tr("\\s+"))).at(1);
338
 
339
 
340
        // 根据节点 以及 扫描链 统计 创建 cdc 文件 的 信号个数
341
        ToolWindow* iparentWidget = dynamic_cast<ToolWindow*>(this->parentWidget()) ;
342
        EziDebugPrj * pprj = const_cast<EziDebugPrj *>(iparentWidget->getCurrentProject()) ;
343
        //if(pprj->getToolType() == EziDebugPrj::ToolIse)
344
        //{
345
            pitem = pprj->getChainTreeItemMap().value(m_ichainName,pitem);
346
            imoduleName = pitem->getModuleName() ;
347
            pmodule = pprj->getPrjModuleMap().value(imoduleName,pmodule) ;
348
            QVector<EziDebugModule::PortStructure*> iportVec = pmodule->getPort(pprj,pitem->getInstanceName()) ;
349
            nportCount = 0 ;
350
 
351
            m_presetPortCombo->clear();
352
 
353
            for(;nportCount < iportVec.count() ; nportCount++)
354
            {
355
                EziDebugModule::PortStructure* pport = iportVec.at(nportCount) ;
356
                QString iportName = QString::fromAscii(pport->m_pPortName) ;
357
                m_presetPortCombo->addItem(iportName);
358
            }
359
            m_presetPortCombo->addItem(tr("No Reset"));
360
 
361
 
362
        //}
363
 
364
 
365
        if(m_pfindFileButton)
366
        {
367
            m_pfindFileButton->setEnabled(true);
368
            m_pilaLine->setEnabled(true);
369
        }
370
    }
371
}
372
 
373
void ImportDataDialog::portSignalChange(int index)
374
{
375
    if(m_presetPortCombo->itemText(index) == "No Reset")
376
    {
377
        m_presetPortEdgeCombo->clear();
378
        m_pportOtherLineEdit->setDisabled(true);
379
    }
380
    else
381
    {
382
        if(!m_presetPortCombo->itemText(index).isEmpty())
383
        {
384
            m_presetPortEdgeCombo->clear();
385
            m_presetPortEdgeCombo->addItem("posedge");
386
            m_presetPortEdgeCombo->addItem("negedge");
387
            m_presetPortEdgeCombo->addItem("other");
388
        }
389
    }
390
}
391
 
392
void ImportDataDialog::portOtherEdge(int index)
393
{
394
    if(m_presetPortEdgeCombo->itemText(index) == "other")
395
    {
396
        m_pportOtherLineEdit->setEnabled(true);
397
    }
398
    else
399
    {
400
        m_pportOtherLineEdit->setDisabled(true);
401
    }
402
}
403
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.