aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2016-10-12 01:18:39 +0200
committerClifford Wolf <clifford@clifford.at>2016-10-12 01:18:39 +0200
commit8ebba8a35f0a5dbf3a044ab84575edfc46c99d77 (patch)
tree180fce8de63b6908d00ccefb59a6f9a3a930b5a4 /kernel
parent4a981a3bd81836cd15059db56f01b60b11068742 (diff)
downloadyosys-8ebba8a35f0a5dbf3a044ab84575edfc46c99d77.tar.gz
yosys-8ebba8a35f0a5dbf3a044ab84575edfc46c99d77.tar.bz2
yosys-8ebba8a35f0a5dbf3a044ab84575edfc46c99d77.zip
Added $ff and $_FF_ cell types
Diffstat (limited to 'kernel')
-rw-r--r--kernel/celltypes.h3
-rw-r--r--kernel/rtlil.cc25
-rw-r--r--kernel/rtlil.h2
-rw-r--r--kernel/satgen.h2
4 files changed, 31 insertions, 1 deletions
diff --git a/kernel/celltypes.h b/kernel/celltypes.h
index 900c12d01..8e3f86f69 100644
--- a/kernel/celltypes.h
+++ b/kernel/celltypes.h
@@ -130,6 +130,7 @@ struct CellTypes
IdString CTRL_IN = "\\CTRL_IN", CTRL_OUT = "\\CTRL_OUT";
setup_type("$sr", {SET, CLR}, {Q});
+ setup_type("$ff", {D}, {Q});
setup_type("$dff", {CLK, D}, {Q});
setup_type("$dffe", {CLK, EN, D}, {Q});
setup_type("$dffsr", {CLK, SET, CLR, D}, {Q});
@@ -184,6 +185,8 @@ struct CellTypes
for (auto c2 : list_np)
setup_type(stringf("$_SR_%c%c_", c1, c2), {S, R}, {Q});
+ setup_type("$_FF_", {D}, {Q});
+
for (auto c1 : list_np)
setup_type(stringf("$_DFF_%c_", c1), {C, D}, {Q});
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index 32efe4f0d..b0cda67b4 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -866,6 +866,13 @@ namespace {
return;
}
+ if (cell->type == "$ff") {
+ port("\\D", param("\\WIDTH"));
+ port("\\Q", param("\\WIDTH"));
+ check_expected();
+ return;
+ }
+
if (cell->type == "$dff") {
param_bool("\\CLK_POLARITY");
port("\\CLK", 1);
@@ -1069,6 +1076,7 @@ namespace {
if (cell->type == "$_SR_PN_") { check_gate("SRQ"); return; }
if (cell->type == "$_SR_PP_") { check_gate("SRQ"); return; }
+ if (cell->type == "$_FF_") { check_gate("DQ"); return; }
if (cell->type == "$_DFF_N_") { check_gate("DQC"); return; }
if (cell->type == "$_DFF_P_") { check_gate("DQC"); return; }
@@ -1830,6 +1838,15 @@ RTLIL::Cell* RTLIL::Module::addSr(RTLIL::IdString name, RTLIL::SigSpec sig_set,
return cell;
}
+RTLIL::Cell* RTLIL::Module::addFf(RTLIL::IdString name, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q)
+{
+ RTLIL::Cell *cell = addCell(name, "$ff");
+ cell->parameters["\\WIDTH"] = sig_q.size();
+ cell->setPort("\\D", sig_d);
+ cell->setPort("\\Q", sig_q);
+ return cell;
+}
+
RTLIL::Cell* RTLIL::Module::addDff(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity)
{
RTLIL::Cell *cell = addCell(name, "$dff");
@@ -1912,6 +1929,14 @@ RTLIL::Cell* RTLIL::Module::addDlatchsr(RTLIL::IdString name, RTLIL::SigSpec sig
return cell;
}
+RTLIL::Cell* RTLIL::Module::addFfGate(RTLIL::IdString name, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q)
+{
+ RTLIL::Cell *cell = addCell(name, "$_FF_");
+ cell->setPort("\\D", sig_d);
+ cell->setPort("\\Q", sig_q);
+ return cell;
+}
+
RTLIL::Cell* RTLIL::Module::addDffGate(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity)
{
RTLIL::Cell *cell = addCell(name, stringf("$_DFF_%c_", clk_polarity ? 'P' : 'N'));
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index a426e0bdd..058f6acf4 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -1008,6 +1008,7 @@ public:
RTLIL::Cell* addEquiv (RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, RTLIL::SigSpec sig_y);
RTLIL::Cell* addSr (RTLIL::IdString name, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr, RTLIL::SigSpec sig_q, bool set_polarity = true, bool clr_polarity = true);
+ RTLIL::Cell* addFf (RTLIL::IdString name, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q);
RTLIL::Cell* addDff (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true);
RTLIL::Cell* addDffe (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, bool en_polarity = true);
RTLIL::Cell* addDffsr (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr,
@@ -1032,6 +1033,7 @@ public:
RTLIL::Cell* addAoi4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d, RTLIL::SigBit sig_y);
RTLIL::Cell* addOai4Gate (RTLIL::IdString name, RTLIL::SigBit sig_a, RTLIL::SigBit sig_b, RTLIL::SigBit sig_c, RTLIL::SigBit sig_d, RTLIL::SigBit sig_y);
+ RTLIL::Cell* addFfGate (RTLIL::IdString name, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q);
RTLIL::Cell* addDffGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true);
RTLIL::Cell* addDffeGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity = true, bool en_polarity = true);
RTLIL::Cell* addDffsrGate (RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_set, RTLIL::SigSpec sig_clr,
diff --git a/kernel/satgen.h b/kernel/satgen.h
index 0a65b490c..792bb3ed7 100644
--- a/kernel/satgen.h
+++ b/kernel/satgen.h
@@ -1293,7 +1293,7 @@ struct SatGen
return true;
}
- if (timestep > 0 && (cell->type == "$dff" || cell->type == "$_DFF_N_" || cell->type == "$_DFF_P_"))
+ if (timestep > 0 && cell->type.in("$ff", "$dff", "$_FF_", "$_DFF_N_", "$_DFF_P_"))
{
if (timestep == 1)
{