Skip to content

Commit

Permalink
Added bitstream reading support for abuf, flipflop, pwrdet, POR
Browse files Browse the repository at this point in the history
azonenberg committed Jul 13, 2017
1 parent ffaddc0 commit 353707d
Showing 5 changed files with 67 additions and 15 deletions.
35 changes: 31 additions & 4 deletions src/greenpak4/Greenpak4Abuf.cpp
Original file line number Diff line number Diff line change
@@ -96,11 +96,38 @@ bool Greenpak4Abuf::CommitChanges()
return true;
}

bool Greenpak4Abuf::Load(bool* /*bitstream*/)
bool Greenpak4Abuf::Load(bool* bitstream)
{
//TODO: Do our inputs
LogError("Unimplemented\n");
return false;
//TODO: set input as coming from the one pin it can come from?

//Input buffer bandwidth
int bw = 0;
if(bitstream[m_configBase + 0])
bw |= 1;
if(bitstream[m_configBase + 1])
bw |= 2;

switch(bw)
{
case 0:
m_bufferBandwidth = 1;
break;

case 1:
m_bufferBandwidth = 5;
break;

case 2:
m_bufferBandwidth = 20;
break;

case 3:
default:
m_bufferBandwidth = 50;
break;
}

return true;
}

bool Greenpak4Abuf::Save(bool* bitstream)
4 changes: 1 addition & 3 deletions src/greenpak4/Greenpak4BitstreamEntity.cpp
Original file line number Diff line number Diff line change
@@ -217,8 +217,6 @@ void Greenpak4BitstreamEntity::ReadMatrixSelector(
netnum |= (1 << i);
}

LogVerbose("Got netnum %d\n", netnum);

//Convert the net number back to an EntityOutput
//For now, do this exhaustively (TODO be smart about it?)
int nhits = 0;
@@ -237,7 +235,7 @@ void Greenpak4BitstreamEntity::ReadMatrixSelector(
//TODO: Properly handle configuration if the primitive has multiple ports mapping to one net (e.g. Q/nQ)
if(output.GetMatrix() == matrix || output.HasDual() )
{
LogVerbose("Source: %s\n", output.GetOutputName().c_str());
LogVerbose("Source for netnum %d: %s\n", netnum, output.GetOutputName().c_str());
signal = output;
nhits ++;
}
29 changes: 26 additions & 3 deletions src/greenpak4/Greenpak4Flipflop.cpp
Original file line number Diff line number Diff line change
@@ -150,10 +150,33 @@ bool Greenpak4Flipflop::CommitChanges()
return true;
}

bool Greenpak4Flipflop::Load(bool* /*bitstream*/)
bool Greenpak4Flipflop::Load(bool* bitstream)
{
LogError("Unimplemented\n");
return false;
//Read inputs (set/reset comes first, if present)
int ibase = m_inputBaseWord;
if(m_hasSR)
{
ReadMatrixSelector(bitstream, ibase + 0, m_matrix, m_nsr);
ibase ++;
}
else
m_nsr = m_device->GetPower();
ReadMatrixSelector(bitstream, ibase + 0, m_matrix, m_input);
ReadMatrixSelector(bitstream, ibase + 1, m_matrix, m_clock);

//Read configuration
m_latchMode = bitstream[m_configBase + 0];
m_outputInvert = bitstream[m_configBase + 1];

if(m_hasSR)
{
m_srmode = bitstream[m_configBase + 2];
m_initValue = bitstream[m_configBase + 3];
}
else
m_initValue = bitstream[m_configBase + 2];

return true;
}

bool Greenpak4Flipflop::Save(bool* bitstream)
4 changes: 2 additions & 2 deletions src/greenpak4/Greenpak4PowerDetector.cpp
Original file line number Diff line number Diff line change
@@ -89,8 +89,8 @@ bool Greenpak4PowerDetector::CommitChanges()

bool Greenpak4PowerDetector::Load(bool* /*bitstream*/)
{
LogError("Unimplemented\n");
return false;
//no configuration - output only
return true;
}

bool Greenpak4PowerDetector::Save(bool* /*bitstream*/)
10 changes: 7 additions & 3 deletions src/greenpak4/Greenpak4PowerOnReset.cpp
Original file line number Diff line number Diff line change
@@ -112,10 +112,14 @@ bool Greenpak4PowerOnReset::CommitChanges()
return true;
}

bool Greenpak4PowerOnReset::Load(bool* /*bitstream*/)
bool Greenpak4PowerOnReset::Load(bool* bitstream)
{
LogError("Unimplemented\n");
return false;
if(bitstream[m_configBase])
m_resetDelay = true;
else
m_resetDelay = false;

return true;
}

bool Greenpak4PowerOnReset::Save(bool* bitstream)

0 comments on commit 353707d

Please sign in to comment.