Skip to content

Commit 5f47939

Browse files
committedJun 5, 2017
Various optimizations to LUT delay characterization
1 parent 517fb32 commit 5f47939

File tree

4 files changed

+76
-26
lines changed

4 files changed

+76
-26
lines changed
 

Diff for: ‎src/gp4tchar/main.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ int main(int argc, char* argv[])
129129
return 1;
130130

131131
//Measure delay through each element
132-
//if(!MeasurePinToPinDelays(sock, hdev))
133-
// return 1;
134-
//if(!MeasureCrossConnectionDelays(sock, hdev))
135-
// return 1;
132+
if(!MeasurePinToPinDelays(sock, hdev))
133+
return 1;
134+
if(!MeasureCrossConnectionDelays(sock, hdev))
135+
return 1;
136136
if(!MeasureLUTDelays(sock, hdev))
137137
return 1;
138138

Diff for: ‎src/gp4tchar/measurements.cpp

+66-22
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool MeasureLUTDelay(
6262
int nlut,
6363
int ninput,
6464
PTVCorner corner,
65-
float& delay);
65+
map<PTVCorner, CombinatorialDelay>& delays);
6666

6767
bool ProgramAndMeasureDelay(
6868
Socket& sock,
@@ -73,6 +73,16 @@ bool ProgramAndMeasureDelay(
7373
int voltage_mv,
7474
float& delay);
7575

76+
bool ProgramAndMeasureDelayAcrossVoltageCorners(
77+
Socket& sock,
78+
hdevice hdev,
79+
vector<uint8_t>& bitstream,
80+
int src,
81+
int dst,
82+
PTVCorner corner,
83+
bool subtractPadDelay,
84+
map<PTVCorner, CombinatorialDelay>& delays);
85+
7686
float GetRoundTripDelayWith2x(
7787
int src,
7888
int dst,
@@ -273,6 +283,47 @@ bool ProgramAndMeasureDelay(
273283
return MeasureDelay(sock, src, dst, delay);
274284
}
275285

286+
bool ProgramAndMeasureDelayAcrossVoltageCorners(
287+
Socket& sock,
288+
hdevice hdev,
289+
vector<uint8_t>& bitstream,
290+
int src,
291+
int dst,
292+
PTVCorner corner,
293+
bool subtractPadDelay,
294+
map<PTVCorner, CombinatorialDelay>& delays)
295+
{
296+
//Emulate the device
297+
LogVerbose("Loading new bitstream\n");
298+
if(!DownloadBitstream(hdev, bitstream, DownloadMode::EMULATION))
299+
return false;
300+
301+
for(auto v : g_testVoltages)
302+
{
303+
corner.SetVoltage(v);
304+
if(!PostProgramSetup(hdev, v))
305+
return false;
306+
307+
//wait a bit to let voltages stabilize
308+
usleep (1000 * 50);
309+
310+
float delay;
311+
if(!MeasureDelay(sock, src, dst, delay))
312+
return false;
313+
314+
//Remove off-die delays if requested
315+
if(subtractPadDelay)
316+
{
317+
//Subtract PCB trace and IO buffer delays
318+
delay -= GetRoundTripDelayWith2x(src, dst, corner);
319+
}
320+
321+
delays[corner] = CombinatorialDelay(delay, -1);
322+
}
323+
324+
return true;
325+
}
326+
276327
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
277328
// Characterize I/O buffers
278329

@@ -588,28 +639,26 @@ bool MeasureLUTDelays(Socket& sock, hdevice hdev)
588639

589640
//Characterize each LUT
590641
//Don't forget to only measure pins it actually has!
591-
float delay;
592642
for(unsigned int nlut = 0; nlut < g_calDevice.GetLUTCount(); nlut++)
593643
{
594644
auto baselut = g_calDevice.GetLUT(nlut);
595645
auto lut = GetRealLUT(baselut);
596-
597-
//Try various voltages
598-
for(auto voltage : g_testVoltages)
646+
for(unsigned int npin = 0; npin < lut->GetOrder(); npin ++)
599647
{
600648
//Test conditions (TODO: pass this in from somewhere?)
601-
PTVCorner corner(PTVCorner::SPEED_TYPICAL, 25, voltage);
602-
603-
for(unsigned int npin = 0; npin < lut->GetOrder(); npin ++)
604-
{
605-
if(!MeasureLUTDelay(sock, hdev, nlut, npin, corner, delay))
606-
return false;
649+
PTVCorner corner(PTVCorner::SPEED_TYPICAL, 25, 3300);
650+
651+
map<PTVCorner, CombinatorialDelay> delays;
652+
if(!MeasureLUTDelay(sock, hdev, nlut, npin, corner, delays))
653+
return false;
607654

608-
//For now, the parent (in case of a muxed lut etc) stores all timing data
609-
//TODO: does this make the most sense?
655+
//For now, the parent (in case of a muxed lut etc) stores all timing data
656+
//TODO: does this make the most sense?
657+
for(auto it : delays)
658+
{
610659
char portname[] = "IN0";
611660
portname[2] += npin;
612-
baselut->AddCombinatorialDelay(portname, "OUT", corner, CombinatorialDelay(delay, -1));
661+
baselut->AddCombinatorialDelay(portname, "OUT", it.first, it.second);
613662
}
614663
}
615664
}
@@ -623,10 +672,8 @@ bool MeasureLUTDelay(
623672
int nlut,
624673
int ninput,
625674
PTVCorner corner,
626-
float& delay)
675+
map<PTVCorner, CombinatorialDelay>& delays)
627676
{
628-
delay = -1;
629-
630677
//Create the device object
631678
Greenpak4Device device(part, unused_pull, unused_drive);
632679
device.SetIOPrecharge(false);
@@ -675,12 +722,9 @@ bool MeasureLUTDelay(
675722
device.WriteToBuffer(bitstream, 0, false);
676723
//device.WriteToFile("/tmp/test.txt", 0, false); //for debug in case of failure
677724

678-
//Get the delay
679-
if(!ProgramAndMeasureDelay(sock, hdev, bitstream, src, dst, corner.GetVoltage(), delay))
725+
//Get the delays
726+
if(!ProgramAndMeasureDelayAcrossVoltageCorners(sock, hdev, bitstream, src, dst, corner, true, delays))
680727
return false;
681728

682-
//Subtract PCB trace and IO buffer delays
683-
delay -= GetRoundTripDelayWith2x(src, dst, corner);
684-
685729
return true;
686730
}

Diff for: ‎src/gp4tchar/setup.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ using namespace std;
2525

2626
bool PostProgramSetup(hdevice hdev, int voltage_mv)
2727
{
28+
SetStatusLED(hdev, 1);
29+
2830
//Clear I/Os from programming mode
2931
if(!IOReset(hdev))
3032
return false;

Diff for: ‎src/xbpar/PTVCorner.h

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ class PTVCorner
5151
int GetVoltage() const
5252
{ return m_voltage; }
5353

54+
//TODO: verify within legal limits
55+
void SetVoltage(int v)
56+
{ m_voltage = v; }
57+
5458
std::string toString() const;
5559

5660
//Comparison operator for STL collections

0 commit comments

Comments
 (0)
Please sign in to comment.