-- Well known name table entries. -- Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold -- -- GHDL is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation; either version 2, or (at your option) any later -- version. -- -- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- for more details. -- -- You should have received a copy of the GNU General Public License -- along with GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with Name_Table; with Ada.Exceptions; package body Std_Names is procedure Std_Names_Initialize is procedure Def (S : String; Id : Name_Id) is begin if Name_Table.Get_Identifier (S) /= Id then Ada.Exceptions.Raise_Exception (Program_Error'Identity, "wrong name_id for " & S); end if; end Def; begin Def ("mod", Name_Mod); Def ("rem", Name_Rem); Def ("and", Name_And); Def ("or", Name_Or); Def ("xor", Name_Xor); Def ("nand", Name_Nand); Def ("nor", Name_Nor); Def ("abs", Name_Abs); Def ("not", Name_Not); Def ("access", Name_Access); Def ("after", Name_After); Def ("alias", Name_Alias); Def ("all", Name_All); Def ("architecture", Name_Architecture); Def ("array", Name_Array); Def ("assert", Name_Assert); Def ("attribute", Name_Attribute); Def ("begin", Name_Begin); Def ("block", Name_Block); Def ("body", Name_Body); Def ("buffer", Name_Buffer); Def ("bus", Name_Bus); Def ("case", Name_Case); Def ("component", Name_Component); Def ("configuration", Name_Configuration); Def ("constant", Name_Constant); Def ("disconnect", Name_Disconnect); Def ("downto", Name_Downto); Def ("else", Name_Else); Def ("elsif", Name_Elsif); Def ("end", Name_End); Def ("entity", Name_Entity); Def ("exit", Name_Exit); Def ("file", Name_File); Def ("for", Name_For); Def ("function", Name_Function); Def ("generate", Name_Generate); Def ("generic", Name_Generic); Def ("guarded", Name_Guarded); Def ("if", Name_If); Def ("in", Name_In); Def ("inout", Name_Inout); Def ("is", Name_Is); Def ("label", Name_Label); Def ("library", Name_Library); Def ("linkage", Name_Linkage); Def ("loop", Name_Loop); Def ("map", Name_Map); Def ("new", Name_New); Def ("next", Name_Next); Def ("null", Name_Null); Def ("of", Name_Of); Def ("on", Name_On); Def ("open", Name_Open); Def ("others", Name_Others); Def ("out", Name_Out); Def ("package", Name_Package); Def ("port", Name_Port); Def ("procedure", Name_Procedure); Def ("process", Name_Process); Def ("range", Name_Range); Def ("record", Name_Record); Def ("register", Name_Register); Def ("report", Name_Report); Def ("return", Name_Return); Def ("select", Name_Select); Def ("severity", Name_Severity); Def ("signal", Name_Signal); Def ("subtype", Name_Subtype); Def ("then", Name_Then); Def ("to", Name_To); Def ("transport", Name_Transport); Def ("type", Name_Type); Def ("units", Name_Units); Def ("until", Name_Until); Def ("use", Name_Use); Def ("variable", Name_Variable); Def ("wait", Name_Wait); Def ("when", Name_When); Def ("while", Name_While); Def ("with", Name_With); -- VHDL93 reserved words. Def ("xnor", Name_Xnor); Def ("group", Name_Group); Def ("impure", Name_Impure); Def ("inertial", Name_Inertial); Def ("literal", Name_Literal); Def ("postponed", Name_Postponed); Def ("pure", Name_Pure); Def ("reject", Name_Reject); Def ("shared", Name_Shared); Def ("unaffected", Name_Unaffected); Def ("sll", Name_Sll); Def ("sla", Name_Sla); Def ("sra", Name_Sra); Def ("srl", Name_Srl); Def ("rol", Name_Rol); Def ("ror", Name_Ror); Def ("protected", Name_Protected); Def ("context", Name_Context); Def ("parameter", Name_Parameter); Def ("across", Name_Across); Def ("break", Name_Break); Def ("limit", Name_Limit); Def ("nature", Name_Nature); Def ("noise", Name_Noise); Def ("procedural", Name_Procedural); Def ("quantity", Name_Quantity); Def ("reference", Name_Reference); Def ("spectrum", Name_Spectrum); Def ("subnature", Name_Subnature); Def ("terminal", Name_Terminal); Def ("through", Name_Through); Def ("tolerance", Name_Tolerance); -- Create operators. Def ("=", Name_Op_Equality); Def ("/=", Name_Op_Inequality); Def ("<", Name_Op_Less); Def ("<=", Name_Op_Less_Equal); Def (">", Name_Op_Greater); Def (">=", Name_Op_Greater_Equal); Def ("+", Name_Op_Plus); Def ("-", Name_Op_Minus); Def ("*", Name_Op_Mul); Def ("/", Name_Op_Div); Def ("**", Name_Op_Exp); Def ("&", Name_Op_Concatenation); Def ("??", Name_Op_Condition); Def ("?=", Name_Op_Match_Equality); Def ("?/=", Name_Op_Match_Inequality); Def ("?<", Name_Op_Match_Less); Def ("?<=", Name_Op_Match_Less_Equal); Def ("?>", Name_Op_Match_Greater); Def ("?>=", Name_Op_Match_Greater_Equal); -- Create Attributes. Def ("base", Name_Base); Def ("left", Name_Left); Def ("right", Name_Right); Def ("high", Name_High); Def ("low", Name_Low); Def ("pos", Name_Pos); Def ("val", Name_Val); Def ("succ", Name_Succ); Def ("pred", Name_Pred); Def ("leftof", Name_Leftof); Def ("rightof", Name_Rightof); Def ("reverse_range", Name_Reverse_Range); Def ("length", Name_Length); Def ("delayed", Name_Delayed); Def ("stable", Name_Stable); Def ("quiet", Name_Quiet); Def ("transaction", Name_Transaction); Def ("event", Name_Event); Def ("active", Name_Active); Def ("last_event",
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#include "kernel/yosys.h"
#include "kernel/sigtools.h"
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
struct AnlogicEqnPass : public Pass {
AnlogicEqnPass() : Pass("anlogic_eqn", "Anlogic: Calculate equations for luts") { }
void help() override
{
log("\n");
log(" anlogic_eqn [selection]\n");
log("\n");
log("Calculate equations for luts since bitstream generator depends on it.\n");
log("\n");
}
Const init2eqn(Const init, int inputs)
{
std::string init_bits = init.as_string();
const char* names[] = { "A" , "B", "C", "D", "E", "F" };
std::string eqn;
int width = (int)pow(2,inputs);
for(int i=0;i<width;i++)
{
if (init_bits[width-1-i]=='1')
{
eqn += "(";
for(int j=0;j<inputs;j++)
{
if (i & (1<<j))
eqn += names[j];
else
eqn += std::string("~") + names[j];
if (j!=(inputs-1)) eqn += "*";
}
eqn += ")+";
}
}
if (eqn.empty()) return Const("0");
eqn = eqn.substr(0, eqn.length()-1);
return Const(eqn);
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
log_header(design, "Executing ANLOGIC_EQN pass (calculate equations for luts).\n");
extra_args(args, args.size(), design);
int cnt = 0;
for (auto module : design->selected_modules())
{
for (auto cell : module->selected_cells())
{
if (cell->type == ID(AL_MAP_LUT1))
{
cell->setParam(ID(EQN), init2eqn(cell->getParam(ID::INIT),1));
cnt++;
}
if (cell->type == ID(AL_MAP_LUT2))
{
cell->setParam(ID(EQN), init2eqn(cell->getParam(ID::INIT),2));
cnt++;
}
if (cell->type == ID(AL_MAP_LUT3))
{
cell->setParam(ID(EQN), init2eqn(cell->getParam(ID::INIT),3));
cnt++;
}
if (cell->type == ID(AL_MAP_LUT4))
{
cell->setParam(ID(EQN), init2eqn(cell->getParam(ID::INIT),4));
cnt++;
}
if (cell->type == ID(AL_MAP_LUT5))
{
cell->setParam(ID(EQN), init2eqn(cell->getParam(ID::INIT),5));
cnt++;
}
if (cell->type == ID(AL_MAP_LUT6))
{
cell->setParam(ID(EQN), init2eqn(cell->getParam(ID::INIT),6));
cnt++;
}
}
}
log_header(design, "Updated %d of AL_MAP_LUT* elements with equation.\n", cnt);
}
} AnlogicEqnPass;
PRIVATE_NAMESPACE_END