Skip to content

Commit

Permalink
Continued work on DAC support. See #32
Browse files Browse the repository at this point in the history
azonenberg committed May 23, 2017
1 parent 0a594ff commit a38304c
Showing 5 changed files with 45 additions and 6 deletions.
29 changes: 28 additions & 1 deletion src/gp4par/make_graphs.cpp
Original file line number Diff line number Diff line change
@@ -194,16 +194,41 @@ void InferExtraNodes(
auto vdd = top->GetNet("GP_VDD");
auto vddn = device->GetPowerRail(true)->GetPARNode();

//Look for IOBs driven by GP_VREF cells
//Look for DACs driven by counters and infer DCMP if one isn't already there
Greenpak4NetlistModule* module = netlist->GetTopModule();
for(auto it = module->cell_begin(); it != module->cell_end(); it ++)
{
//Skip anything but DACs
Greenpak4NetlistCell* cell = it->second;
if(cell->m_type != "GP_DAC")
continue;

//If we're driven by a power rail, skip it - input is constant
if(cell->m_connections.find("DIN") == cell->m_connections.end())
continue;
auto net = cell->m_connections["DIN"][0];
auto driver = net->m_driver;
if(driver.IsNull())
continue;
if(driver.m_cell->IsPowerRail() )
continue;
Greenpak4NetlistCell* netsrc = driver.m_cell;

//We found the source of the net!
LogVerbose("Found a DAC not driven by a power rail\n");
}

//Look for IOBs driven by GP_VREF cells
for(auto it = module->cell_begin(); it != module->cell_end(); it ++)
{
//See if we're an IOB
Greenpak4NetlistCell* cell = it->second;
if(!cell->IsIOB())
continue;

//See if we're driven by a GP_VREF
if(cell->m_connections.find("IN") == cell->m_connections.end())
continue;
auto net = cell->m_connections["IN"][0];
auto driver = net->m_driver;
if(driver.IsNull())
@@ -298,6 +323,8 @@ void InferExtraNodes(
//LogDebug("vref %s\n", cell->m_name.c_str());

//See what we drive
if(cell->m_connections.find("VOUT") == cell->m_connections.end())
continue;
auto net = cell->m_connections["VOUT"][0];
bool found_target = false;
for(int i=net->m_nodeports.size()-1; i>=0; i--)
7 changes: 6 additions & 1 deletion src/gp4par/par_main.cpp
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ bool PostPARDRC(PARGraph* netlist, Greenpak4Device* device)
}
}

//TODO: check floating inputs etc
//TODO: check floating inputs etc?

//Check invalid IOB configuration
//TODO: driving an input-only pin etc - is this possible?
@@ -220,6 +220,11 @@ bool PostPARDRC(PARGraph* netlist, Greenpak4Device* device)
//so nothing to do here
}

//Check for DACs not sharing input with DCMP1 negative, but also not a constant
//TODO: check for DACs with wrong input bit ordering or not same source for all bits

//TODO: check for DCMPs with wrong input bit ordering or not same source for all bits

//Check for multiple ACMPs using different settings of ACMP0's output mux
typedef pair<string, Greenpak4EntityOutput> spair;
switch(device->GetPart())
8 changes: 5 additions & 3 deletions src/greenpak4/Greenpak4DAC.cpp
Original file line number Diff line number Diff line change
@@ -200,11 +200,13 @@ bool Greenpak4DAC::Save(bool* bitstream)
bitstream[m_cbaseReg + i] = m_din[i].GetPowerRailValue();
}

//TODO: need to infer DCMP/PWM for this
//Input is coming from DCMP.
//Rely on the DCMP input mux for this, nothing for us to do.
//Set the input voltage to zero just so the bitstream is deterministic.
else
{
LogError("DRC: DAC input from counters etc not implemented yet\n");
return false;
for(unsigned int i=0; i<8; i++)
bitstream[m_cbaseReg + i] = false;
}

return true;
6 changes: 5 additions & 1 deletion src/greenpak4/Greenpak4NetlistCell.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***********************************************************************************************************************
* Copyright (C) 2016 Andrew Zonenberg and contributors *
* Copyright (C) 2017 Andrew Zonenberg and contributors *
* *
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General *
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) *
@@ -54,6 +54,10 @@ class Greenpak4NetlistCell : public Greenpak4NetlistEntity
bool IsIOB()
{ return (m_type == "GP_IBUF") || (m_type == "GP_IOBUF") || (m_type == "GP_OBUF") || (m_type == "GP_OBUFT"); }

//Indicates whether the cell is a power rail
bool IsPowerRail()
{ return (m_type == "GP_VDD") || (m_type == "GP_VSS"); }

std::string GetLOC();

bool HasLOC()
1 change: 1 addition & 0 deletions tests/greenpak4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ function(add_greenpak4_bitstream name part)
COMMAND gp4par "--stdout-only"
--usercode 41
--quiet
--debug
--part ${part}
${pcfargs1}
${pcfargs2}

0 comments on commit a38304c

Please sign in to comment.