Skip to content

Commit a38304c

Browse files
committedMay 23, 2017
Continued work on DAC support. See #32
1 parent 0a594ff commit a38304c

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed
 

‎src/gp4par/make_graphs.cpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,41 @@ void InferExtraNodes(
194194
auto vdd = top->GetNet("GP_VDD");
195195
auto vddn = device->GetPowerRail(true)->GetPARNode();
196196

197-
//Look for IOBs driven by GP_VREF cells
197+
//Look for DACs driven by counters and infer DCMP if one isn't already there
198198
Greenpak4NetlistModule* module = netlist->GetTopModule();
199199
for(auto it = module->cell_begin(); it != module->cell_end(); it ++)
200+
{
201+
//Skip anything but DACs
202+
Greenpak4NetlistCell* cell = it->second;
203+
if(cell->m_type != "GP_DAC")
204+
continue;
205+
206+
//If we're driven by a power rail, skip it - input is constant
207+
if(cell->m_connections.find("DIN") == cell->m_connections.end())
208+
continue;
209+
auto net = cell->m_connections["DIN"][0];
210+
auto driver = net->m_driver;
211+
if(driver.IsNull())
212+
continue;
213+
if(driver.m_cell->IsPowerRail() )
214+
continue;
215+
Greenpak4NetlistCell* netsrc = driver.m_cell;
216+
217+
//We found the source of the net!
218+
LogVerbose("Found a DAC not driven by a power rail\n");
219+
}
220+
221+
//Look for IOBs driven by GP_VREF cells
222+
for(auto it = module->cell_begin(); it != module->cell_end(); it ++)
200223
{
201224
//See if we're an IOB
202225
Greenpak4NetlistCell* cell = it->second;
203226
if(!cell->IsIOB())
204227
continue;
205228

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

300325
//See what we drive
326+
if(cell->m_connections.find("VOUT") == cell->m_connections.end())
327+
continue;
301328
auto net = cell->m_connections["VOUT"][0];
302329
bool found_target = false;
303330
for(int i=net->m_nodeports.size()-1; i>=0; i--)

‎src/gp4par/par_main.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool PostPARDRC(PARGraph* netlist, Greenpak4Device* device)
161161
}
162162
}
163163

164-
//TODO: check floating inputs etc
164+
//TODO: check floating inputs etc?
165165

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

223+
//Check for DACs not sharing input with DCMP1 negative, but also not a constant
224+
//TODO: check for DACs with wrong input bit ordering or not same source for all bits
225+
226+
//TODO: check for DCMPs with wrong input bit ordering or not same source for all bits
227+
223228
//Check for multiple ACMPs using different settings of ACMP0's output mux
224229
typedef pair<string, Greenpak4EntityOutput> spair;
225230
switch(device->GetPart())

‎src/greenpak4/Greenpak4DAC.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ bool Greenpak4DAC::Save(bool* bitstream)
200200
bitstream[m_cbaseReg + i] = m_din[i].GetPowerRailValue();
201201
}
202202

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

210212
return true;

‎src/greenpak4/Greenpak4NetlistCell.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************************************************************************
2-
* Copyright (C) 2016 Andrew Zonenberg and contributors *
2+
* Copyright (C) 2017 Andrew Zonenberg and contributors *
33
* *
44
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General *
55
* 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
5454
bool IsIOB()
5555
{ return (m_type == "GP_IBUF") || (m_type == "GP_IOBUF") || (m_type == "GP_OBUF") || (m_type == "GP_OBUFT"); }
5656

57+
//Indicates whether the cell is a power rail
58+
bool IsPowerRail()
59+
{ return (m_type == "GP_VDD") || (m_type == "GP_VSS"); }
60+
5761
std::string GetLOC();
5862

5963
bool HasLOC()

‎tests/greenpak4/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function(add_greenpak4_bitstream name part)
7878
COMMAND gp4par "--stdout-only"
7979
--usercode 41
8080
--quiet
81+
--debug
8182
--part ${part}
8283
${pcfargs1}
8384
${pcfargs2}

0 commit comments

Comments
 (0)
Please sign in to comment.