Skip to content

Commit

Permalink
Added legacy-crowbar-import dir with copy of old libcrowbar code from…
Browse files Browse the repository at this point in the history
… Antikernel repo. Needs to get totally rewritten, just shoving it here for easy reference
azonenberg committed May 5, 2017
1 parent 0bdfb95 commit 163b1f5
Showing 58 changed files with 7,707 additions and 0 deletions.
832 changes: 832 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIDevice.cpp

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIDevice
*/
#ifndef FCCoolRunnerIIDevice_h
#define FCCoolRunnerIIDevice_h

#include <vector>

#include "FCDevice.h"
#include "FCCoolRunnerIIFunctionBlock.h"
#include "FCCoolRunnerIIProductTerm.h"
#include "FCCoolRunnerIINetlist.h"
#include "FCCoolRunnerIIZIAEntry.h"

/**
@brief A generic CoolRunner-II CPLD device
A CR-II device contains an even number of function blocks (from 2 to 32) and some other stuff (TODO)
*/
class FCCoolRunnerIIDevice : public FCDevice
{
public:
FCCoolRunnerIIDevice(std::string name);
virtual ~FCCoolRunnerIIDevice();

virtual void LoadFromBitstream(std::string fname);
virtual void SaveToBitstream(std::string fname);
virtual void SaveToBitstream(CPLDSerializer* writer);

virtual int GetTotalPinCount();

size_t GetBlockCount()
{ return m_fbs.size(); }

FCCoolRunnerIIFunctionBlock* GetFunctionBlock(size_t i)
{ return m_fbs[i]; }

FCCoolRunnerIINetSource* DecodeZIAEntry(int row, std::string muxsel);

void Fit(FCCoolRunnerIINetlist* netlist);

const std::vector<FCCoolRunnerIIZIAEntry>& GetZIAEntriesForNetSource(FCCoolRunnerIINetSource* net);

protected:
void FitMacrocells(FCCoolRunnerIINetlist* netlist);

/*
ZIA stuff
Map of FCCoolRunnerIINetSource*'s to std::vector<int> indicating legal rows
Each function block has an array of 40 FCCoolRunnerIINetSource*s
*/

protected:
//Model creation
void CreateModelXC2C32A();
void CreateModelXC2C64A();
void CreateModelXC2C128();
void CreateModelXC2C256();
void CreateModelXC2C384();
void CreateModelXC2C512();

//Initialization helpers
void AddIOBSToBank(FCCoolRunnerIIFunctionBlock* fb, FCIOBank* bank);

public:
//Print a human-readable representation to stdout
virtual void Dump();

//Print a synthesizeable RTL representation to stdout
virtual void DumpRTL();

protected:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Device properties which aren't directly included in the bitstream

///@brief Number of fuses
size_t m_fusecount;

///@brief Speed grade of the device
int m_speedgrade;

///@brief Human-readable device name
std::string m_devname;

///@brief Package ID (from XilinxCoolRunnerIIDevice::packages enum)
int m_package;

///@brief Array of function blocks
std::vector<FCCoolRunnerIIFunctionBlock*> m_fbs;

///@brief Name of bitfile we were loaded from
std::string m_bitfile;

protected:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Global config settings (included verbatim in bitstream)

///Global clock (exact bit meaning unknown)
int m_gckMux;

///Global set/reset (exact bit meaning unknown)
int m_gsrMux;

///Global output enable (exact bit meaning unknown)
int m_goeMux;

///Global termination. Toggles between keeper and pullup mode.
enum global_term_modes
{
GLOBAL_TERM_KEEPER = 0,
GLOBAL_TERM_PULLUP = 1
};
bool m_gterm;

///"Dedicated input mode". Set to 1 to terminate unused pins, 0 to float or CGND
///Maybe this is the mode of the input-only pin???
int m_dedicatedInputMode;

///Map indicating legal ZIA connections
std::map<FCCoolRunnerIINetSource*, std::vector<FCCoolRunnerIIZIAEntry> > m_legalZIAConnections;

///Converse of m_legalZIAConnections
std::map< std::pair<int, std::string> , FCCoolRunnerIINetSource*> m_ziaEntryReverseMap;
};

#endif
717 changes: 717 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIFunctionBlock.cpp

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIFunctionBlock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIFunctionBlock
*/

#ifndef FCCoolRunnerIIFunctionBlock_h
#define FCCoolRunnerIIFunctionBlock_h

#include "FCCoolRunnerIIMacrocell.h"
#include "FCCoolRunnerIIZIAEntry.h"
#include "FCCoolRunnerIIProductTerm.h"

class CPLDBitstream;
class CPLDSerializer;

#include <unordered_set>

class FCCoolRunnerIIDevice;

/**
@brief A single function block within a CoolRunner-II CPLD.
Each function block consists of the following:
* 40 input signals
* An 80x56 AND array
Input is 40 original and 40 inverted inputs
Output is 56 product terms
* An 56x16 OR array
Input is 56 product terms
Output is 16 OR terms to macrocells
* 16 macrocells
Of the 56 p-terms, some are special:
* 16 go to PTA inputs of each macrocell
* 16 go to PTB inputs of each macrocell
* 16 go to PTC inputs of each macrocell
* 1 goes to CTC (control term clock = function block level clock)
* 1 goes to CTR (control term reset = function block level FF reset)
* 1 goes to CTS (control term set = function block level FF set)
* 1 goes to CTE (control term enable = function block level OE)
This is a total of 52 special p-terms. The other 3 seem to have no specific allocation (so far).
The locations of these p-terms within the array are not yet known.
All p-terms can, if not being used for special purposes, be used for general purpose logic.
PTC can bypass the PLA OR term for a slight (300ps) speed boost if only one product term is used.
Each function block has a "ZIA" attached to the input which appears to be the AIM. In the XC2C32A this is an
8x40 block. The output is the 40 input signals going to the PLA. While the 8 input bits presumably control muxes of
some sort it's not known exactly what's going on.
Input signals to AIM (XC2C32A):
32 function block outputs
32 pin inputs
This is 64 signals total and we have 8 bits.
*/
class FCCoolRunnerIIFunctionBlock
{
public:
FCCoolRunnerIIFunctionBlock(FCCoolRunnerIIDevice* device, int blocknum, int zia_width);
virtual ~FCCoolRunnerIIFunctionBlock();

enum
{
MACROCELLS_PER_FB = 16,
INPUT_TERM_COUNT = 40,
PLA_INPUT_WIDTH = INPUT_TERM_COUNT*2,
PLA_PRODUCT_TERMS = 56
};

int GetBlockNumber();
FCCoolRunnerIIMacrocell* GetMacrocell(int i);

virtual void Dump();
virtual void DumpIOBRTL();
virtual void DumpRTL();
virtual void GetTopLevelNetNames(std::unordered_set<std::string>& names);

int LoadFromBitstream(bool* bitstream, int start_address);
virtual void SaveToBitstream(CPLDSerializer* writer);

bool IsOrTermUsed(int macrocell);
bool IsProductTermUsed(int pterm);
bool IsMacrocellOutputUsed(int macrocell);

void Fit();

int GetZiaWidth()
{ return m_ziaWidth; }

protected:
FCCoolRunnerIIDevice* m_device;

void GlobalRouting(std::map<FCCoolRunnerIINetSource*, FCCoolRunnerIIZIAEntry>& net_assignments);
void FitProductTerms(std::map<FCCoolRunnerIIProductTerm*, int>& pterm_assignments);

///Number of this function block within the parent device (one based as per datasheet)
int m_blocknum;

///The macrocells
std::vector<FCCoolRunnerIIMacrocell*> m_macrocells;

/**
@brief The PLA AND array.
Generates 56 product terms from 40 true and 40 inverted inputs.
The convention used here is that a "true" value means the idle, or unprogrammed state (no connection) and a
"false" value means the active, or programmed state (connection present).
This is the same convention used in the actual EEPROM image and was chosen for consistency with the physical
device, although it may be somewhat counterintuitive.
*/
bool m_plaAnd[PLA_PRODUCT_TERMS][PLA_INPUT_WIDTH];

/**
@brief The PLA OR array.
Generates 16 output terms from 56 product terms.
The convention used here is that a "true" value means the idle, or unprogrammed state (no connection) and a
"false" value means the active, or programmed state (connection present).
This is the same convention used in the actual EEPROM image and was chosen for consistency with the physical
device, although it may be somewhat counterintuitive.
*/
bool m_plaOr[PLA_PRODUCT_TERMS][MACROCELLS_PER_FB];

/**
@brief The ZIA (input switch)
Exact structure is not known at this time.
*/
bool* m_zia[INPUT_TERM_COUNT];

int m_ziaWidth;
};

#endif
329 changes: 329 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIIOB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIIIOB
*/

#include "crowbar.h"
#include "FCCoolRunnerIIFunctionBlock.h"
#include "FCCoolRunnerIIIOB.h"
#include "FCCoolRunnerIIMacrocell.h"
#include "FCCoolRunnerIIIOBank.h"

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

FCCoolRunnerIIIOB::FCCoolRunnerIIIOB(FCCoolRunnerIIMacrocell* parent)
: m_bSchmittTriggerEnabled(true)
, m_outmode(OUTPUT_DIRECT)
, m_iostandard(UNCONSTRAINED)
, m_oe(OE_FLOAT)
, m_inz(INZ_FLOAT)
, m_macrocell(parent)
, m_slewRate(SLEW_FAST)
, m_termMode(TERM_ACTIVE)
{
}

FCCoolRunnerIIIOB::~FCCoolRunnerIIIOB()
{

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

string FCCoolRunnerIIIOB::GetNamePrefix()
{
return m_macrocell->GetNamePrefix();
}

string FCCoolRunnerIIIOB::GetIOStandardText()
{
switch(m_iostandard)
{
case UNCONSTRAINED:
return "UNCONSTRAINED";
case LVTTL:
return "LVTTL";
case LVCMOS33:
return "LVCMOS33";
case LVCMOS25:
return "LVCMOS25";
case LVCMOS18:
return "LVCMOS18";
case LVCMOS15:
return "LVCMOS15";
case HSTL_1:
return "HSTL_1";
case SSTL2_1:
return "SSTL2_1";
case SSTL3_1:
return "SSTL3_1";
default:
throw JtagExceptionWrapper(
"Invalid I/O standard",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
}

bool FCCoolRunnerIIIOB::GetSlewRate()
{
return m_slewRate;
}

void FCCoolRunnerIIIOB::SetSlewRate(bool rate)
{
m_slewRate = rate;
}

bool FCCoolRunnerIIIOB::GetTerminationMode()
{
return m_termMode;
}

void FCCoolRunnerIIIOB::SetTerminationMode(bool mode)
{
m_termMode = mode;
}

void FCCoolRunnerIIIOB::SetInZ(int z)
{
switch(z)
{
case INZ_INPUT:
case INZ_FLOAT:
m_inz = z;
break;
default:
throw JtagExceptionWrapper(
"Invalid InZ",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
}

int FCCoolRunnerIIIOB::GetInZ()
{
return m_inz;
}

std::string FCCoolRunnerIIIOB::GetInZText()
{
switch(m_inz)
{
case INZ_INPUT:
return "Input";
case INZ_FLOAT:
return "Float";
default:
throw JtagExceptionWrapper(
"Invalid InZ",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
}

void FCCoolRunnerIIIOB::SetOE(int oe)
{
switch(oe)
{
case OE_OUTPUT:
case OE_OPENDRAIN:
case OE_CGND:
case OE_TRISTATE:
case OE_FLOAT:
m_oe = oe;
break;
default:
throw JtagExceptionWrapper(
"Invalid OE",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
}

int FCCoolRunnerIIIOB::GetOE()
{
return m_oe;
}

std::string FCCoolRunnerIIIOB::GetOEText()
{
switch(m_oe)
{
case OE_OUTPUT:
return "Output";
case OE_OPENDRAIN:
return "Open drain";
case OE_CGND:
return "CGND";
case OE_FLOAT:
return "Float";
case OE_TRISTATE:
return "Tristate";
default:
throw JtagExceptionWrapper(
"Invalid OE",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
}

string FCCoolRunnerIIIOB::GetConstraints()
{
//Location
char buf[128];
snprintf(buf, sizeof(buf), "(* LOC=\"FB%d_%d\" *)",
m_macrocell->GetFunctionBlock()->GetBlockNumber(), m_macrocell->GetCellNumber());
string s(buf);

//I/O standard
//Use the bank's I/O standard for now
FCCoolRunnerIIIOBank* bank = dynamic_cast<FCCoolRunnerIIIOBank*>(m_bank);
if(bank != NULL)
{
bool ivolt = bank->GetIVoltage();
bool ovolt = bank->GetOVoltage();

bool volt = ovolt;
if(GetInZ() == INZ_INPUT)
volt = ivolt;

else if(volt == FCCoolRunnerIIIOBank::HIGH_VOLTAGE)
s += " (* IOSTANDARD = \"LVCMOS33\" *) ";
else if(volt == FCCoolRunnerIIIOBank::LOW_VOLTAGE)
s += " (* IOSTANDARD = \"LVCMOS18\" *) ";
}

//Slew rate
if(m_slewRate == SLEW_FAST)
s += " (* SLEW = \"FAST\" *)";
else
s += " (* SLEW = \"SLOW\" *)";

//Schmitt trigger
if(m_bSchmittTriggerEnabled)
s += " (* SCHMITT_TRIGGER = \"yes\" *)";

//TODO: Keeper / pullup

return s;
}

std::string FCCoolRunnerIIIOB::GetTopLevelNetName()
{
char buf[128] = "";
switch(m_oe)
{
case OE_OUTPUT:
case OE_OPENDRAIN:
snprintf(buf, sizeof(buf), "%s_obuf", GetNamePrefix().c_str());
break;

case OE_TRISTATE:
snprintf(buf, sizeof(buf), "%s_iobuf", GetNamePrefix().c_str());
break;

case OE_CGND:
//CGND
break;

case OE_FLOAT:
//Output driver not connnected... is input buffer connected?
switch(m_inz)
{
case INZ_INPUT:
snprintf(buf, sizeof(buf), "%s", GetNamePrefix().c_str());
break;
case INZ_FLOAT:
break;
default:
printf(" // WARNING: Don't know what InZ value %d for %s IOB means\n", m_inz, GetNamePrefix().c_str());
break;
}
break;

default:
printf(" // WARNING: Don't know what OE value %d for %s IOB means\n", m_oe, GetNamePrefix().c_str());
break;
}
return buf;
}

void FCCoolRunnerIIIOB::DumpRTL()
{
switch(m_oe)
{
case OE_OUTPUT:
case OE_OPENDRAIN:
printf(" %s\n output wire %s_obuf;\n", GetConstraints().c_str(), GetNamePrefix().c_str());
printf(" wire %s_output;\n", GetNamePrefix().c_str());
printf(" OBUF obuf_%s_inst(.O(%s_obuf), .I(%s_output));\n",
GetNamePrefix().c_str(), GetNamePrefix().c_str(), GetNamePrefix().c_str());
break;

case OE_TRISTATE:
printf(" %s\n inout wire %s_iobuf;\n", GetConstraints().c_str(), GetNamePrefix().c_str());
printf(" // WARNING: Generation of tristate buffers not implemented yet\n");
break;

case OE_CGND:
printf(" // %s IOB is CGND\n", GetNamePrefix().c_str());
break;

case OE_FLOAT:
//Output driver not connnected... is input buffer connected?
switch(m_inz)
{
case INZ_INPUT:
printf(" %s\n input wire %s;\n", GetConstraints().c_str(), GetNamePrefix().c_str());
printf(" wire %s_ibuf;\n", GetNamePrefix().c_str());
printf(" IBUF ibuf_%s_inst(.O(%s), .I(%s_ibuf));\n",
GetNamePrefix().c_str(), GetNamePrefix().c_str(), GetNamePrefix().c_str());
break;
case INZ_FLOAT:
break;
default:
printf(" // WARNING: Don't know what InZ value %d for %s IOB means\n", m_inz, GetNamePrefix().c_str());
break;
}
break;

default:
printf(" // WARNING: Don't know what OE value %d for %s IOB means\n", m_oe, GetNamePrefix().c_str());
break;
}
}
156 changes: 156 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIIOB.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIIOB
*/

#ifndef FCCoolRunnerIIIOB_h
#define FCCoolRunnerIIIOB_h

#include "FCIOB.h"
#include "FCCoolRunnerIINetSource.h"

class FCCoolRunnerIIMacrocell;

/**
@brief A single I/O buffer
Output enable is either dedicated product term PTB or control term CTE
*/
class FCCoolRunnerIIIOB : public FCIOB
, public FCCoolRunnerIINetSource
{
public:
FCCoolRunnerIIIOB(FCCoolRunnerIIMacrocell* parent);
virtual ~FCCoolRunnerIIIOB();

enum iostandard
{
UNCONSTRAINED,
LVTTL,
LVCMOS33,
LVCMOS25,
LVCMOS18,
LVCMOS15,
HSTL_1,
SSTL2_1,
SSTL3_1
};

std::string GetIOStandardText();

enum SlewRate
{
SLEW_FAST = 0,
SLEW_SLOW = 1
};
bool GetSlewRate();
void SetSlewRate(bool rate);

enum TerminationMode
{
TERM_FLOAT = 0,
TERM_ACTIVE = 1
};
bool GetTerminationMode();
void SetTerminationMode(bool mode);

///Schmitt trigger enable flag
bool m_bSchmittTriggerEnabled;

enum OutputMode
{
OUTPUT_REGISTER = 0,
OUTPUT_DIRECT = 1
};

///Registered / combinatorial output
bool m_outmode;

//TODO: Separate flag for keeper/float/active/ground etc

enum InZ
{
INZ_INPUT = 0,
//values 1 and 2 not seen yet
INZ_FLOAT = 3
};

void SetInZ(int z);
int GetInZ();
std::string GetInZText();

enum OE
{
OE_OUTPUT = 0,
OE_OPENDRAIN = 1,
OE_TRISTATE = 8,
OE_CGND = 14,
OE_FLOAT = 15
};

void SetOE(int oe);
int GetOE();
std::string GetOEText();

void DumpRTL();

std::string GetTopLevelNetName();

std::string GetNamePrefix();

///I/O standard of this IOB
iostandard m_iostandard;

FCCoolRunnerIIMacrocell* GetMacrocell()
{ return m_macrocell; }

protected:

std::string GetConstraints();

int m_oe;

///Input mode (see InZ)
int m_inz;

///The macrocell we're associated with
FCCoolRunnerIIMacrocell* m_macrocell;

///Slew rate
bool m_slewRate;

///Termination mode
bool m_termMode;
};

#endif
179 changes: 179 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIIOBank.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIIIOBank
*/

#include "crowbar.h"
#include "FCCoolRunnerIIIOBank.h"
#include "FCCoolRunnerIIIOB.h"
#include "../jtaghal/JEDFileWriter.h"

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

FCCoolRunnerIIIOBank::FCCoolRunnerIIIOBank(int banknum)
: FCIOBank(banknum)
, m_ivoltage(true)
, m_ovoltage(true)
{

}

FCCoolRunnerIIIOBank::~FCCoolRunnerIIIOBank()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

void FCCoolRunnerIIIOBank::SetVoltages(bool ivoltage, bool ovoltage)
{
m_ivoltage = ivoltage;
m_ovoltage = ovoltage;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Debug output

void FCCoolRunnerIIIOBank::Dump()
{
const char* ranges[] =
{
"HIGH",
"LOW"
};
const char* iostandards[] =
{
"LVTTL/LVCMOS33/LVCMOS25",
"LVCMOS18/LVCMOS15"
};
printf(" %4d %15s %30s %15s %30s\n",
m_banknum,
ranges[m_ovoltage],
iostandards[m_ovoltage],
ranges[m_ivoltage],
iostandards[m_ivoltage]);
}

void FCCoolRunnerIIIOBank::DumpHeader()
{
printf("\n %4s %15s %30s %15s %30s\n",
"Bank",
"Output range",
"Allowed output std",
"Input range",
"Allowed input std");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Output

void FCCoolRunnerIIIOBank::SaveToBitstream(CPLDSerializer* writer)
{
char buf[32];

snprintf(buf, sizeof(buf), "Bank %d Vcci", m_banknum);
writer->AddBodyBlankLine();
writer->AddBodyComment(buf);
writer->AddBodyFuseData(&m_ivoltage, 1);

snprintf(buf, sizeof(buf), "Bank %d Vcco", m_banknum);
writer->AddBodyBlankLine();
writer->AddBodyComment(buf);
writer->AddBodyFuseData(&m_ovoltage, 1);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fitting

void FCCoolRunnerIIIOBank::Fit()
{
//DRC: Verify all pins are compatible I/O standards

//Default to high voltage if not specified
m_ivoltage = HIGH_VOLTAGE;
m_ovoltage = HIGH_VOLTAGE;
bool highRequested = false;

for(size_t i=0; i<m_iobs.size(); i++)
{
FCCoolRunnerIIIOB* iob = static_cast<FCCoolRunnerIIIOB*>(m_iobs[i]);

switch(iob->m_iostandard)
{

//No constraints? Use default
case FCCoolRunnerIIIOB::UNCONSTRAINED:
break;

//High voltage
case FCCoolRunnerIIIOB::LVTTL:
case FCCoolRunnerIIIOB::LVCMOS33:
case FCCoolRunnerIIIOB::LVCMOS25:
if(m_ivoltage == LOW_VOLTAGE)
{
throw JtagExceptionWrapper(
"DRC error: Cannot mix high and low voltage I/O standards in the same bank",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
highRequested = true;
break;

//Low voltage
case FCCoolRunnerIIIOB::LVCMOS18:
case FCCoolRunnerIIIOB::LVCMOS15:
if(highRequested)
{
throw JtagExceptionWrapper(
"DRC error: Cannot mix high and low voltage I/O standards in the same bank",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}

m_ivoltage = LOW_VOLTAGE;
m_ovoltage = LOW_VOLTAGE;
break;

//Reference-oriented
case FCCoolRunnerIIIOB::HSTL_1:
case FCCoolRunnerIIIOB::SSTL2_1:
case FCCoolRunnerIIIOB::SSTL3_1:
throw JtagExceptionWrapper(
"HSTL/SSTL I/O standards not implemented yet",
"",
JtagException::EXCEPTION_TYPE_UNIMPLEMENTED);
break;
}
}
}
82 changes: 82 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIIOBank.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIIOBank
*/

#ifndef FCCoolRunnerIIIOBank_h
#define FCCoolRunnerIIIOBank_h

#include "FCIOBank.h"

class CPLDSerializer;

/**
@brief An I/O bank
*/
class FCCoolRunnerIIIOBank : public FCIOBank
{
public:
FCCoolRunnerIIIOBank(int banknum);
virtual ~FCCoolRunnerIIIOBank();

enum voltagemodes
{
///LVTTL, LVCMOS33, or LVCMOS25
HIGH_VOLTAGE = 0,

///LVCMOS18, LVCMOS15
LOW_VOLTAGE = 1
};

bool GetIVoltage()
{ return m_ivoltage; }

bool GetOVoltage()
{ return m_ovoltage; }

void SetVoltages(bool ivoltage, bool ovoltage);

virtual void Dump();
virtual void DumpHeader();

void SaveToBitstream(CPLDSerializer* writer);

void Fit();

protected:

bool m_ivoltage;
bool m_ovoltage;
};

#endif
435 changes: 435 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIMacrocell.cpp

Large diffs are not rendered by default.

216 changes: 216 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIMacrocell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIMacrocell
*/

#ifndef FCCoolRunnerIIMacrocell_h
#define FCCoolRunnerIIMacrocell_h

#include "FCCoolRunnerIIIOB.h"

class CPLDSerializer;
class FCCoolRunnerIINetlistMacrocell;
class FCCoolRunnerIIFunctionBlock;

/**
@brief A single CoolRunner-II macrocell.
Each macrocell takes the OR term from the PLA and XORs it with one of the following:
* One product term expression PTA (hard-wired to a specific row)
* A constant "1" (to invert the term)
* A constant "0" (to leave it unchanged)
The macrocell also contains a flipflop. The flipflop's data input may come from the output of the XOR gate or
directly from the IOB.
The flipflop's clock enable is hard-wired to the PTC input of the macrocell.
The clock input to the flipflop may come from one of the following sources:
* CTC (control term clock, a product term shared by all macrocells)
* PTC (product term clock, hard-wired to a specific row)
* GCK0 (global clock net)
* GCK1 (global clock net)
* GCK2 (global clock net)
The clock may optionally be inverted before reaching the flipflop.
The set/reset input to the flipflop may come from one of the following sources:
* PTA
* CTR (control term reset, a product term shared by all macrocells)
* CTS (control term set, a product term shared by all macrocells)
* GSR (global set/reset)
* Constant '0'
The output of the flipflop, as well as that of the XOR gate, are fed back to the AIM as well as to the macrocell's
associated IOB.
*/
class FCCoolRunnerIIMacrocell : public FCCoolRunnerIINetSource
{
public:
FCCoolRunnerIIMacrocell(FCCoolRunnerIIFunctionBlock* fb, int n);
~FCCoolRunnerIIMacrocell();

FCCoolRunnerIIIOB m_iob;

FCCoolRunnerIIFunctionBlock* GetFunctionBlock();
int GetCellNumber();

void DumpHeader();
void Dump();
void DumpFooter();

void DumpRTL();

void DumpIOBRTL()
{ m_iob.DumpRTL(); }

std::string GetTopLevelNetName();

void SaveToBitstream(CPLDSerializer* writer);

int LoadFromBitstream(bool* bitstream, int start_address);

enum ClockSources
{
CLK_GCK0 = 0,
CLK_GCK1 = 2,
CLK_GCK2 = 1,
CLK_PTC = 3
};
std::string GetClockSourceText();

enum ClockEdges
{
CLK_EDGE_RISING = 0,
CLK_EDGE_FALLING = 1,
CLK_EDGE_DDR = 2
};

std::string GetClockEdgeText();

enum RegisterModes
{
///The register is a D flipflop
REG_MODE_DFF = 0,

///The register is a transparent latch
REG_MODE_LATCH = 1,

///The register is a T flipflop
REG_MODE_TFF = 2,

///The register is a D flipflop with clock enable
REG_MODE_DFFCE = 3
};
std::string GetRegModeText();

enum InregModes
{
INREG_IOB = 0,
INREG_XOR = 1
};

/**
@brief XOR mux
Product term C for macrocell N (zero based) is product term (10 + 3n).
*/
enum XorinModes
{
//Hard-wired 0 (zero ^ unused OR term = zero)
XORIN_ZERO = 0,

//~PTC
XORIN_NPTC = 1,

//PTC
XORIN_PTC = 2,

//Hard-wired 1 (one ^ unused OR term = 1)
XORIN_ONE = 3
} m_xorin;

std::string GetXorinText();

/// @brief Returns the zero-based product term index of product term C
int GetPtermCIndex()
{ return (3 * (m_cellnum - 1)) + 10; }

std::string GetNamePrefix();

FCCoolRunnerIINetlistMacrocell* m_netlistcell;

protected:
///Index of this macrocell within the FB (one based as per datasheet)
int m_cellnum;

///The function block we belong to
FCCoolRunnerIIFunctionBlock* m_fb;

///unknown
bool m_aclk;

///@brief Clock source
int m_clk;

///@brief Clock edge (combination of clkop and clkfreq bits)
int m_clkEdge;

///unknown
int m_r;

///unknown
int m_p;

///@brief Register mode (see RegisterModes enum)
int m_regmod;

/**
@brief Unknown value
Observed in several different values but not yet known what the conditions are.
*/
int m_fbval;

///@brief Controls whether FF D input comes from IOB or XOR output (see InregModes enum)
bool m_inreg;

/**
@brief Flipflop power-up value
This is the logical value (true = 1'b1, false = 1'b0). The value in the bitstream is complemented for
some reason.
*/
bool m_ffResetState;
};

#endif
42 changes: 42 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIINetSource.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIINetSource
*/

#include "crowbar.h"
#include "FCCoolRunnerIINetSource.h"

FCCoolRunnerIINetSource::~FCCoolRunnerIINetSource()
{

}
47 changes: 47 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIINetSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIINetSource
*/

#ifndef FCCoolRunnerIINetSource_h
#define FCCoolRunnerIINetSource_h

class FCCoolRunnerIINetSource
{
public:
virtual ~FCCoolRunnerIINetSource();

virtual std::string GetTopLevelNetName() =0;
};

#endif
56 changes: 56 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIINetlist.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIINetlist
*/

#include "crowbar.h"
#include "FCCoolRunnerIINetlist.h"

FCCoolRunnerIINetlist::FCCoolRunnerIINetlist(FCCoolRunnerIIDevice* /*device*/)
{
}

FCCoolRunnerIINetlist::~FCCoolRunnerIINetlist()
{
for(size_t i=0; i<m_macrocells.size(); i++)
delete m_macrocells[i];
m_macrocells.clear();

for(size_t i=0; i<m_orterms.size(); i++)
delete m_orterms[i];
m_orterms.clear();

for(size_t i=0; i<m_pterms.size(); i++)
delete m_pterms[i];
m_pterms.clear();
}
82 changes: 82 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIINetlist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIINetlist
*/

#ifndef FCCoolRunnerIINetlist_h
#define FCCoolRunnerIINetlist_h

class FCCoolRunnerIIDevice;

#include "FCCoolRunnerIIOrTerm.h"
#include "FCCoolRunnerIIProductTerm.h"
#include "FCCoolRunnerIINetlistMacrocell.h"

/**
@brief A technology-dependent, mapped, netlist
*/
class FCCoolRunnerIINetlist
{
public:
FCCoolRunnerIINetlist(FCCoolRunnerIIDevice* device);

virtual ~FCCoolRunnerIINetlist();

FCCoolRunnerIIProductTerm* CreateProductTerm()
{
FCCoolRunnerIIProductTerm* pterm = new FCCoolRunnerIIProductTerm;
m_pterms.push_back(pterm);
return pterm;
}

FCCoolRunnerIIOrTerm* CreateOrTerm()
{
FCCoolRunnerIIOrTerm* oterm = new FCCoolRunnerIIOrTerm;
m_orterms.push_back(oterm);
return oterm;
}

FCCoolRunnerIINetlistMacrocell* CreateMacrocell(FCCoolRunnerIIOrTerm* orterm, FCCoolRunnerIIIOB* iob)
{
FCCoolRunnerIINetlistMacrocell* cell = new FCCoolRunnerIINetlistMacrocell(orterm, iob);
m_macrocells.push_back(cell);
return cell;
}

std::vector<FCCoolRunnerIIProductTerm*> m_pterms;
std::vector<FCCoolRunnerIIOrTerm*> m_orterms;
std::vector<FCCoolRunnerIINetlistMacrocell*> m_macrocells;
};

#endif

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIINetlistMacrocell
*/

#include "crowbar.h"
#include "../jtaghal/jtaghal.h"
#include "FCCoolRunnerIINetlistMacrocell.h"

using namespace std;

FCCoolRunnerIINetlistMacrocell::FCCoolRunnerIINetlistMacrocell(FCCoolRunnerIIOrTerm* orterm, FCCoolRunnerIIIOB* iob)
: m_xorin(FCCoolRunnerIIMacrocell::XORIN_ZERO)
, m_orterm(orterm)
, m_iob(iob)
, m_macrocell(NULL)
{
if(iob != NULL)
SetMacrocell(iob->GetMacrocell());
}

FCCoolRunnerIINetlistMacrocell::~FCCoolRunnerIINetlistMacrocell()
{

}

string FCCoolRunnerIINetlistMacrocell::GetTopLevelNetName()
{
throw JtagExceptionWrapper(
"Not implemented",
"",
JtagException::EXCEPTION_TYPE_UNIMPLEMENTED);
}

/**
@brief Write config from the netlist to the device
*/
void FCCoolRunnerIINetlistMacrocell::WriteConfig()
{
if(!m_macrocell)
{
throw JtagExceptionWrapper(
"Can't write macrocell config to a null pointer",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}

m_macrocell->m_xorin = m_xorin;
}
82 changes: 82 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIINetlistMacrocell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIINetlistMacrocell
*/

#ifndef FCCoolRunnerIINetlistMacrocell_h
#define FCCoolRunnerIINetlistMacrocell_h

#include "FCCoolRunnerIINetSource.h"
#include "FCCoolRunnerIIOrTerm.h"
#include "FCCoolRunnerIIMacrocell.h"
#include "FCCoolRunnerIIIOB.h"

/**
@brief An unplaced macrocell.
During fitting, a FCCoolRunnerIINetlistMacrocell is paired up with a FCCoolRunnerIIMacrocell.
*/
class FCCoolRunnerIINetlistMacrocell : public FCCoolRunnerIINetSource
{
public:
FCCoolRunnerIINetlistMacrocell(FCCoolRunnerIIOrTerm* orterm, FCCoolRunnerIIIOB* iob);
virtual ~FCCoolRunnerIINetlistMacrocell();

FCCoolRunnerIIOrTerm* GetOrTerm()
{ return m_orterm; }

FCCoolRunnerIIMacrocell* GetMacrocell()
{ return m_macrocell; }

void SetMacrocell(FCCoolRunnerIIMacrocell* macrocell)
{
m_macrocell = macrocell;
m_iob = &macrocell->m_iob;
macrocell->m_netlistcell = this;
}

virtual std::string GetTopLevelNetName();

FCCoolRunnerIIMacrocell::XorinModes m_xorin;

void WriteConfig();

//TODO: Support product-term-C path

protected:
FCCoolRunnerIIOrTerm* m_orterm;
FCCoolRunnerIIIOB* m_iob;
FCCoolRunnerIIMacrocell* m_macrocell;
};

#endif
43 changes: 43 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIOrTerm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIIOrTerm
*/

#include "crowbar.h"
#include "FCCoolRunnerIIOrTerm.h"

FCCoolRunnerIIOrTerm::~FCCoolRunnerIIOrTerm()
{

}

52 changes: 52 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIOrTerm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIOrTerm
*/

#ifndef FCCoolRunnerIIOrTerm_h
#define FCCoolRunnerIIOrTerm_h

#include "FCCoolRunnerIIProductTerm.h"

/**
@brief A single OR term, potentially unplaced.
*/
class FCCoolRunnerIIOrTerm
{
public:
virtual ~FCCoolRunnerIIOrTerm();

std::vector<FCCoolRunnerIIProductTerm*> m_pterms;
};

#endif
43 changes: 43 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIProductTerm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIIProductTerm
*/

#include "crowbar.h"
#include "FCCoolRunnerIIProductTerm.h"

FCCoolRunnerIIProductTerm::~FCCoolRunnerIIProductTerm()
{

}

59 changes: 59 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIProductTerm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIProductTerm
*/

#ifndef FCCoolRunnerIIProductTerm_h
#define FCCoolRunnerIIProductTerm_h

#include "FCCoolRunnerIINetSource.h"

/**
@brief A single product term, potentially unplaced.
*/
class FCCoolRunnerIIProductTerm
{
public:
virtual ~FCCoolRunnerIIProductTerm();

void AddInput(FCCoolRunnerIINetSource* net, bool invert)
{
m_inputs.push_back(net);
m_inputInvert.push_back(invert);
}

std::vector<FCCoolRunnerIINetSource*> m_inputs;
std::vector<bool> m_inputInvert;
};

#endif
73 changes: 73 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIZIAEntry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCCoolRunnerIIZIAEntry
*/

#include "crowbar.h"
#include "FCCoolRunnerIIZIAEntry.h"

using namespace std;

FCCoolRunnerIIZIAEntry::FCCoolRunnerIIZIAEntry(int row, string muxsel_hex, int zia_bits)
: m_row(row)
, m_muxsel_str(muxsel_hex)
{
//Dummy for containers, never used
if(zia_bits == 0)
return;

//Read bytes, right to left
if(zia_bits != 8)
{
throw JtagExceptionWrapper(
"Not implemented",
"",
JtagException::EXCEPTION_TYPE_UNIMPLEMENTED);
}

//Temporary easy code for width=8
int val;
sscanf(muxsel_hex.c_str(), "%2x", &val);
m_muxsel.push_back((val >> 7) & 1);
m_muxsel.push_back((val >> 6) & 1);
m_muxsel.push_back((val >> 5) & 1);
m_muxsel.push_back((val >> 4) & 1);
m_muxsel.push_back((val >> 3) & 1);
m_muxsel.push_back((val >> 2) & 1);
m_muxsel.push_back((val >> 1) & 1);
m_muxsel.push_back((val >> 0) & 1);
}

FCCoolRunnerIIZIAEntry::~FCCoolRunnerIIZIAEntry()
{
}
50 changes: 50 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCCoolRunnerIIZIAEntry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCCoolRunnerIIZIAEntry
*/

#ifndef FCCoolRunnerIIZIAEntry_h
#define FCCoolRunnerIIZIAEntry_h

class FCCoolRunnerIIZIAEntry
{
public:
FCCoolRunnerIIZIAEntry(int row=0, std::string muxsel_hex="", int zia_bits=0);
virtual ~FCCoolRunnerIIZIAEntry();

int m_row;
std::vector<bool> m_muxsel;
std::string m_muxsel_str;
};

#endif
86 changes: 86 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCDevice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FCDevice
*/

#include "crowbar.h"
#include "FCDevice.h"
#include "FCCoolRunnerIIDevice.h"
#include "FCIOBank.h"

using namespace std;

FCDevice::~FCDevice()
{
//Do not delete IOBs since the macrocells etc may own them

//Clean up I/O banks
for(size_t i=0; i<m_banks.size(); i++)
delete m_banks[i];
m_banks.clear();
}

/**
@brief Creates a device given a name
*/
FCDevice* FCDevice::CreateDevice(string name)
{
//String match the part number
if(name.find("xc2c") != string::npos)
return new FCCoolRunnerIIDevice(name);

//Out of ideas, give up
throw JtagExceptionWrapper(
"Invalid device name (does not match a known part)",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}

/**
@brief Gets the IOB for a given pin
TODO: Build a hash table or something, O(n) is silly
*/
FCIOB* FCDevice::GetIOBForPin(string name)
{
for(size_t i=0; i<m_iobs.size(); i++)
{
if(m_iobs[i]->GetPin() == name)
return m_iobs[i];
}

throw JtagExceptionWrapper(
"Invalid IOB name",
"",
JtagException::EXCEPTION_TYPE_GIGO);
}
65 changes: 65 additions & 0 deletions src/legacy-crowbar-import/crowbar/FCDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FCDevice
*/

#ifndef FCDevice_h
#define FCDevice_h

class FCIOB;
class FCIOBank;

/**
@brief A generic programmable logic device
*/
class FCDevice
{
public:
virtual ~FCDevice();

static FCDevice* CreateDevice(std::string name);

virtual void LoadFromBitstream(std::string fname)=0;
virtual void SaveToBitstream(std::string fname)=0;

virtual void Dump()=0;
virtual void DumpRTL()=0;

FCIOB* GetIOBForPin(std::string name);

protected:
std::vector<FCIOB*> m_iobs;
std::vector<FCIOBank*> m_banks;
};

#endif
Loading

0 comments on commit 163b1f5

Please sign in to comment.