-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSbwSimulationDataGenerator.cpp
135 lines (109 loc) · 3.79 KB
/
SbwSimulationDataGenerator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* sbwlogic
*
* Copyright (C) 2013 Fredrik Ahlberg
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <cstdlib> // for rand
#include "SbwSimulationDataGenerator.h"
#include "SbwAnalyzerSettings.h"
SbwSimulationDataGenerator::SbwSimulationDataGenerator()
{
}
SbwSimulationDataGenerator::~SbwSimulationDataGenerator()
{
}
void SbwSimulationDataGenerator::Initialize(U32 simulation_sample_rate, SbwAnalyzerSettings* settings)
{
#if 0
mSimulationSampleRateHz = simulation_sample_rate;
mSettings = settings;
mClockGenerator.Init(simulation_sample_rate / 10, simulation_sample_rate);
mTCK = mJtagSimulationChannels.Add(settings->mTCKChannel, mSimulationSampleRateHz, BIT_LOW);
mTMS = mJtagSimulationChannels.Add(settings->mTMSChannel, mSimulationSampleRateHz, BIT_LOW);
mTDI = mJtagSimulationChannels.Add(settings->mTDIChannel, mSimulationSampleRateHz, BIT_LOW);
mTDO = mJtagSimulationChannels.Add(settings->mTDOChannel, mSimulationSampleRateHz, BIT_LOW);
if (settings->mTRSTChannel != UNDEFINED_CHANNEL) {
mTRST = mJtagSimulationChannels.Add(settings->mTRSTChannel, mSimulationSampleRateHz, BIT_LOW);
} else {
mTRST = NULL;
}
mJtagSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod(10.0));
#endif
}
U32 SbwSimulationDataGenerator::GenerateSimulationData(U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels)
{
#if 0
U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample(largest_sample_requested, sample_rate, mSimulationSampleRateHz);
while (mTCK->GetCurrentSampleNumber() < adjusted_largest_sample_requested) {
CreateJtagTransaction();
mJtagSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod((rand() % 10) * 10.0));
}
*simulation_channels = mJtagSimulationChannels.GetArray();
return mJtagSimulationChannels.GetCount();
#endif
}
void SbwSimulationDataGenerator::CreateJtagTransaction()
{
#if 0
switch (rand() % 2) {
case 0:
MoveState("0100"); // SelectDR
Scan(rand(), rand(), rand() % 24 + 1);
MoveState("1111"); // Reset
break;
case 1:
MoveState("0110"); // SelectIR
Scan(rand(), rand(), rand() % 24 + 1);
MoveState("1111"); // Reset
break;
}
#endif
}
void SbwSimulationDataGenerator::MoveState(const char *tms)
{
#if 0
mTDI->TransitionIfNeeded(BIT_LOW);
mTDO->TransitionIfNeeded(BIT_LOW);
while (*tms) {
mTMS->TransitionIfNeeded(static_cast<BitState>(*tms++ == '1'));
mJtagSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod(.5));
mTCK->Transition();
mJtagSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod(.5));
mTCK->Transition();
}
#endif
}
void SbwSimulationDataGenerator::Scan(U32 in, U32 out, U32 bits)
{
#if 0
mTMS->TransitionIfNeeded(BIT_LOW);
while (bits--) {
mTDI->TransitionIfNeeded(static_cast<BitState>(in & 1));
mTDO->TransitionIfNeeded(static_cast<BitState>(out & 1));
in >>= 1;
out >>= 1;
if (bits == 0) {
mTMS->Transition();
}
mJtagSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod(.5));
mTCK->Transition();
mJtagSimulationChannels.AdvanceAll(mClockGenerator.AdvanceByHalfPeriod(.5));
mTCK->Transition();
}
#endif
}