Skip to content

Commit

Permalink
Implemented bitstream loading for MuxedClockBuffer, RCOscillator, SPI
Browse files Browse the repository at this point in the history
azonenberg committed Jul 20, 2017
1 parent fb63552 commit 47c3e85
Showing 4 changed files with 59 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/greenpak4/Greenpak4Counter.cpp
Original file line number Diff line number Diff line change
@@ -515,8 +515,8 @@ bool Greenpak4Counter::Save(bool* bitstream)
// FSM input data source

//NVM data (FSM data = max count)
//NB: on SLG4662x, FSM0 and FSM1 encoding for this register does not match
//this one bit value is the same for both though
//WARNING: on SLG4662x, FSM0 and FSM1 encoding for this register are not the same!
//This one case uses the same encoding for both so we're OK until we support the other modes
bitstream[nbase + 0] = false;
bitstream[nbase + 1] = false;

16 changes: 12 additions & 4 deletions src/greenpak4/Greenpak4MuxedClockBuffer.cpp
Original file line number Diff line number Diff line change
@@ -41,11 +41,19 @@ Greenpak4MuxedClockBuffer::~Greenpak4MuxedClockBuffer()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization

bool Greenpak4MuxedClockBuffer::Load(bool* /*bitstream*/)
bool Greenpak4MuxedClockBuffer::Load(bool* bitstream)
{
//TODO: Do our inputs
LogError("Unimplemented\n");
return false;
unsigned int muxsel = (bitstream[m_configBase + 1] << 1) | bitstream[m_configBase + 0];
for(auto it : m_inputs)
{
if(it.second == muxsel)
{
m_input = it.first;
break;
}
}

return true;
}

bool Greenpak4MuxedClockBuffer::Save(bool* bitstream)
32 changes: 28 additions & 4 deletions src/greenpak4/Greenpak4RCOscillator.cpp
Original file line number Diff line number Diff line change
@@ -164,10 +164,34 @@ bool Greenpak4RCOscillator::CommitChanges()
return true;
}

bool Greenpak4RCOscillator::Load(bool* /*bitstream*/)
bool Greenpak4RCOscillator::Load(bool* bitstream)
{
LogError("Unimplemented\n");
return false;
//Load PWRDN
ReadMatrixSelector(bitstream, m_inputBaseWord, m_matrix, m_powerDown);

//If output is disabled, force us to be powered down
if(!bitstream[m_configBase + 0])
m_powerDown = m_device->GetPower();

//Ignore power-down enable

//Read other status bits
m_autoPowerDown = !bitstream[m_configBase + 7];
m_fastClock = bitstream[m_configBase + 8];

//TODO: bypass

//Output pre-divider
int prediv = bitstream[m_configBase + 1] | (bitstream[m_configBase + 2] << 1);
int predivs[4] = {1, 2, 4, 8};
m_preDiv = predivs[prediv];

//Output post-divider
int postdiv = bitstream[m_configBase + 3] | (bitstream[m_configBase + 4] << 1) | (bitstream[m_configBase + 5] << 2);
int postdivs[8] = {1, 2, 4, 3, 8, 12, 24, 64};
m_postDiv = postdivs[postdiv];

return true;
}

bool Greenpak4RCOscillator::Save(bool* bitstream)
@@ -209,7 +233,7 @@ bool Greenpak4RCOscillator::Save(bool* bitstream)
//Frequency selection
bitstream[m_configBase + 8] = m_fastClock;

//Bypass RC oscillator (TODO: what does this do??) matrix_out1_73
//Bypass RC oscillator (feed external clock to our output) matrix_out1_73
bitstream[m_configBase + 9] = false;

//Output pre-divider
21 changes: 17 additions & 4 deletions src/greenpak4/Greenpak4SPI.cpp
Original file line number Diff line number Diff line change
@@ -144,11 +144,24 @@ bool Greenpak4SPI::CommitChanges()
return true;
}

bool Greenpak4SPI::Load(bool* /*bitstream*/)
bool Greenpak4SPI::Load(bool* bitstream)
{
//TODO: Do our inputs
LogError("Unimplemented\n");
return false;
//Read the chip select
ReadMatrixSelector(bitstream, m_inputBaseWord, m_matrix, m_csn);

//TODO: set other ports for MOSI/MISO/SCK?

//Read configuration
m_useAsBuffer = bitstream[m_configBase + 0];
//TODO: bit 1 = input source
m_cpha = bitstream[m_configBase + 2];
m_cpol = bitstream[m_configBase + 3];
m_width8Bits = bitstream[m_configBase + 4];
m_dirIsOutput = bitstream[m_configBase + 5];
m_parallelOutputToFabric = bitstream[m_configBase + 6];
//TODO: SDIO mux selector

return true;
}

bool Greenpak4SPI::Save(bool* bitstream)

0 comments on commit 47c3e85

Please sign in to comment.