Skip to content

Commit

Permalink
Now loading LF/ring oscillator bitstreams
Browse files Browse the repository at this point in the history
azonenberg committed Jul 21, 2017
1 parent 47c3e85 commit c79bb87
Showing 2 changed files with 44 additions and 6 deletions.
20 changes: 17 additions & 3 deletions src/greenpak4/Greenpak4LFOscillator.cpp
Original file line number Diff line number Diff line change
@@ -133,10 +133,24 @@ bool Greenpak4LFOscillator::CommitChanges()
return true;
}

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

//If powerdown isn't enabled, tie powerdown off
if(!bitstream[m_configBase + 0])
m_powerDown = m_device->GetGround();

//Read other config
m_autoPowerDown = !bitstream[m_configBase + 1];

//Read clock dividers
int clkdiv = (bitstream[m_cbaseClkdiv + 1] << 1) | bitstream[m_cbaseClkdiv + 0];
int clkdivs[4] = {1, 2, 4, 16};
m_outDiv = clkdivs[clkdiv];

return true;
}

bool Greenpak4LFOscillator::Save(bool* bitstream)
30 changes: 27 additions & 3 deletions src/greenpak4/Greenpak4RingOscillator.cpp
Original file line number Diff line number Diff line change
@@ -147,10 +147,34 @@ bool Greenpak4RingOscillator::CommitChanges()
return true;
}

bool Greenpak4RingOscillator::Load(bool* /*bitstream*/)
bool Greenpak4RingOscillator::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 + 7])
m_powerDown = m_device->GetPower();

//If powerdown isn't enabled, tie powerdown off
else if(!bitstream[m_configBase + 8])
m_powerDown = m-device->GetGround();

//Read other config
m_autoPowerDown = !bitstream[m_configBase + 10];

//Read clock dividers
int prediv = (bitstream[m_configBase + 6] << 1) | bitstream[m_configBase + 5];
int predivs[4] = {1, 4, 8, 16};
m_preDiv = predivs[prediv];

int postdiv = (bitstream[m_configBase + 2] << 2) |
(bitstream[m_configBase + 1] << 1) |
bitstream[m_configBase + 0];
int postdivs[8] = {1, 2, 4, 3, 8, 12, 24, 64};
m_postDiv = postdivs[postdiv];

return true;
}

bool Greenpak4RingOscillator::Save(bool* bitstream)

0 comments on commit c79bb87

Please sign in to comment.