Added $anyseq cell type

This commit is contained in:
Clifford Wolf 2016-10-14 15:24:03 +02:00
parent 2733994aeb
commit bdc316db50
11 changed files with 40 additions and 11 deletions

View File

@ -417,7 +417,7 @@ struct Smt2Worker
return; return;
} }
if (cell->type == "$anyconst") if (cell->type.in("$anyconst", "$anyseq"))
{ {
registers.insert(cell); registers.insert(cell);
decls.push_back(stringf("; yosys-smt2-%s %s#%d %s\n", cell->type.c_str() + 1, get_id(module), idcounter, decls.push_back(stringf("; yosys-smt2-%s %s#%d %s\n", cell->type.c_str() + 1, get_id(module), idcounter,

View File

@ -1,6 +1,7 @@
// Demo for memory initialization // Demo for memory initialization
module demo7 (input [2:0] addr); module demo7;
wire [2:0] addr = $anyseq;
reg [15:0] memory [0:7]; reg [15:0] memory [0:7];
initial begin initial begin

View File

@ -762,7 +762,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
break; break;
case AST_FCALL: case AST_FCALL:
if (str == "\\$anyconst") { if (str == "\\$anyconst" || str == "\\$anyseq") {
if (GetSize(children) == 1) { if (GetSize(children) == 1) {
while (children[0]->simplify(true, false, false, 1, -1, false, true) == true) { } while (children[0]->simplify(true, false, false, 1, -1, false, true) == true) { }
if (children[0]->type != AST_CONSTANT) if (children[0]->type != AST_CONSTANT)
@ -1465,7 +1465,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
} break; } break;
case AST_FCALL: { case AST_FCALL: {
if (str == "\\$anyconst") if (str == "\\$anyconst" || str == "\\$anyseq")
{ {
string myid = stringf("%s$%d", str.c_str() + 1, autoidx++); string myid = stringf("%s$%d", str.c_str() + 1, autoidx++);
int width = width_hint; int width = width_hint;

View File

@ -1807,8 +1807,8 @@ skip_dynamic_range_lvalue_expansion:;
goto apply_newNode; goto apply_newNode;
} }
// $anyconst is mapped in AstNode::genRTLIL() // $anyconst and $anyseq are mapped in AstNode::genRTLIL()
if (str == "\\$anyconst") { if (str == "\\$anyconst" || str == "\\$anyseq") {
recursion_counter--; recursion_counter--;
return false; return false;
} }

View File

@ -1229,7 +1229,7 @@ rvalue:
$$ = new AstNode(AST_IDENTIFIER, $2); $$ = new AstNode(AST_IDENTIFIER, $2);
$$->str = *$1; $$->str = *$1;
delete $1; delete $1;
if ($2 == nullptr && formal_mode && ($$->str == "\\$initstate" || $$->str == "\\$anyconst")) if ($2 == nullptr && formal_mode && ($$->str == "\\$initstate" || $$->str == "\\$anyconst" || $$->str == "\\$anyseq"))
$$->type = AST_FCALL; $$->type = AST_FCALL;
} | } |
hierarchical_id non_opt_multirange { hierarchical_id non_opt_multirange {

View File

@ -118,6 +118,7 @@ struct CellTypes
setup_type("$assume", {A, EN}, pool<RTLIL::IdString>(), true); setup_type("$assume", {A, EN}, pool<RTLIL::IdString>(), true);
setup_type("$initstate", pool<RTLIL::IdString>(), {Y}, true); setup_type("$initstate", pool<RTLIL::IdString>(), {Y}, true);
setup_type("$anyconst", pool<RTLIL::IdString>(), {Y}, true); setup_type("$anyconst", pool<RTLIL::IdString>(), {Y}, true);
setup_type("$anyseq", pool<RTLIL::IdString>(), {Y}, true);
setup_type("$equiv", {A, B}, {Y}, true); setup_type("$equiv", {A, B}, {Y}, true);
} }

View File

@ -1037,7 +1037,7 @@ namespace {
return; return;
} }
if (cell->type == "$anyconst") { if (cell->type.in("$anyconst", "$anyseq")) {
port("\\Y", param("\\WIDTH")); port("\\Y", param("\\WIDTH"));
check_expected(); check_expected();
return; return;
@ -2009,6 +2009,15 @@ RTLIL::SigSpec RTLIL::Module::Anyconst(RTLIL::IdString name, int width)
return sig; return sig;
} }
RTLIL::SigSpec RTLIL::Module::Anyseq(RTLIL::IdString name, int width)
{
RTLIL::SigSpec sig = addWire(NEW_ID, width);
Cell *cell = addCell(name, "$anyseq");
cell->setParam("\\WIDTH", width);
cell->setPort("\\Y", sig);
return sig;
}
RTLIL::SigSpec RTLIL::Module::Initstate(RTLIL::IdString name) RTLIL::SigSpec RTLIL::Module::Initstate(RTLIL::IdString name)
{ {
RTLIL::SigSpec sig = addWire(NEW_ID); RTLIL::SigSpec sig = addWire(NEW_ID);

View File

@ -1108,6 +1108,7 @@ public:
RTLIL::SigBit Oai4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d); RTLIL::SigBit Oai4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d);
RTLIL::SigSpec Anyconst (RTLIL::IdString name, int width = 1); RTLIL::SigSpec Anyconst (RTLIL::IdString name, int width = 1);
RTLIL::SigSpec Anyseq (RTLIL::IdString name, int width = 1);
RTLIL::SigSpec Initstate (RTLIL::IdString name); RTLIL::SigSpec Initstate (RTLIL::IdString name);
}; };

View File

@ -1332,8 +1332,8 @@ struct SatGen
if (model_undef) if (model_undef)
{ {
std::vector<int> undef_d = importUndefSigSpec(cell->getPort("\\D"), timestep-1); std::vector<int> undef_d = importUndefSigSpec(cell->getPort("\\Y"), timestep-1);
std::vector<int> undef_q = importUndefSigSpec(cell->getPort("\\Q"), timestep); std::vector<int> undef_q = importUndefSigSpec(cell->getPort("\\Y"), timestep);
ez->assume(ez->vec_eq(undef_d, undef_q)); ez->assume(ez->vec_eq(undef_d, undef_q));
undefGating(q, qq, undef_q); undefGating(q, qq, undef_q);
@ -1341,6 +1341,11 @@ struct SatGen
return true; return true;
} }
if (cell->type == "$anyseq")
{
return true;
}
if (cell->type == "$_BUF_" || cell->type == "$equiv") if (cell->type == "$_BUF_" || cell->type == "$equiv")
{ {
std::vector<int> a = importDefSigSpec(cell->getPort("\\A"), timestep); std::vector<int> a = importDefSigSpec(cell->getPort("\\A"), timestep);

View File

@ -421,7 +421,7 @@ pass. The combinatorial logic cells can be mapped to physical cells from a Liber
using the {\tt abc} pass. using the {\tt abc} pass.
\begin{fixme} \begin{fixme}
Add information about {\tt \$assert}, {\tt \$assume}, {\tt \$equiv}, {\tt \$initstate}, and {\tt \$anyconst} cells. Add information about {\tt \$assert}, {\tt \$assume}, {\tt \$equiv}, {\tt \$initstate}, {\tt \$anyconst}, and {\tt \$anyseq} cells.
\end{fixme} \end{fixme}
\begin{fixme} \begin{fixme}

View File

@ -1334,6 +1334,18 @@ endmodule
// -------------------------------------------------------- // --------------------------------------------------------
module \$anyseq (Y);
parameter WIDTH = 0;
output [WIDTH-1:0] Y;
assign Y = 'bx;
endmodule
// --------------------------------------------------------
module \$equiv (A, B, Y); module \$equiv (A, B, Y);
input A, B; input A, B;