aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/ecp5
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2019-02-28 14:46:56 -0800
committerGitHub <noreply@github.com>2019-02-28 14:46:56 -0800
commit41e5028f982b7929051d6d6ccded09cca0f2292e (patch)
tree515565d8b22a97109c5a0572df4f32976ff2df4a /techlibs/ecp5
parent6d143c9a018e5ba352a06785afeba8d50178a835 (diff)
parentfa2f595cfa240b86edb26e859449c1c54eaf49ef (diff)
downloadyosys-41e5028f982b7929051d6d6ccded09cca0f2292e.tar.gz
yosys-41e5028f982b7929051d6d6ccded09cca0f2292e.tar.bz2
yosys-41e5028f982b7929051d6d6ccded09cca0f2292e.zip
Merge pull request #794 from daveshah1/ecp5improve
ECP5 Improvements
Diffstat (limited to 'techlibs/ecp5')
-rw-r--r--techlibs/ecp5/Makefile.inc2
-rw-r--r--techlibs/ecp5/arith_map.v2
-rw-r--r--techlibs/ecp5/cells_bb.v152
-rw-r--r--techlibs/ecp5/cells_map.v3
-rw-r--r--techlibs/ecp5/cells_sim.v40
-rw-r--r--techlibs/ecp5/ecp5_ffinit.cc198
-rw-r--r--techlibs/ecp5/synth_ecp5.cc3
7 files changed, 388 insertions, 12 deletions
diff --git a/techlibs/ecp5/Makefile.inc b/techlibs/ecp5/Makefile.inc
index 8df02be5f..4db087e87 100644
--- a/techlibs/ecp5/Makefile.inc
+++ b/techlibs/ecp5/Makefile.inc
@@ -1,5 +1,5 @@
-OBJS += techlibs/ecp5/synth_ecp5.o
+OBJS += techlibs/ecp5/synth_ecp5.o techlibs/ecp5/ecp5_ffinit.o
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/cells_map.v))
$(eval $(call add_share_file,share/ecp5,techlibs/ecp5/cells_sim.v))
diff --git a/techlibs/ecp5/arith_map.v b/techlibs/ecp5/arith_map.v
index 1094c5f8a..eb7947601 100644
--- a/techlibs/ecp5/arith_map.v
+++ b/techlibs/ecp5/arith_map.v
@@ -33,7 +33,7 @@ module _80_ecp5_alu (A, B, CI, BI, X, Y, CO);
input CI, BI;
output [Y_WIDTH-1:0] CO;
- wire _TECHMAP_FAIL_ = Y_WIDTH <= 2;
+ wire _TECHMAP_FAIL_ = Y_WIDTH <= 4;
wire [Y_WIDTH-1:0] A_buf, B_buf;
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
diff --git a/techlibs/ecp5/cells_bb.v b/techlibs/ecp5/cells_bb.v
index 425d62d24..223e19b9e 100644
--- a/techlibs/ecp5/cells_bb.v
+++ b/techlibs/ecp5/cells_bb.v
@@ -156,6 +156,41 @@ module OSCG(
parameter DIV = 128;
endmodule
+(* blackbox *) (* keep *)
+module USRMCLK(
+ input USRMCLKI, USRMCLKTS,
+ output USRMCLKO
+);
+endmodule
+
+(* blackbox *) (* keep *)
+module JTAGG(
+ input TCK, TMS, TDI, JTDO2, JTDO1,
+ output TDO, JTDI, JTCK, JRTI2, JRTI1,
+ output JSHIFT, JUPDATE, JRSTN, JCE2, JCE1
+);
+parameter ER1 = "ENABLED";
+parameter ER2 = "ENABLED";
+endmodule
+
+(* blackbox *)
+module DELAYF(
+ input A, LOADN, MOVE, DIRECTION,
+ output Z, CFLAG
+);
+ parameter DEL_MODE = "USER_DEFINED";
+ parameter DEL_VALUE = 0;
+endmodule
+
+(* blackbox *)
+module DELAYG(
+ input A,
+ output Z
+);
+ parameter DEL_MODE = "USER_DEFINED";
+ parameter DEL_VALUE = 0;
+endmodule
+
(* blackbox *)
module IDDRX1F(
input D, SCLK, RST,
@@ -165,6 +200,31 @@ module IDDRX1F(
endmodule
(* blackbox *)
+module IDDRX2F(
+ input D, SCLK, ECLK, RST,
+ output Q0, Q1, Q2, Q3
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module IDDR71B(
+ input D, SCLK, ECLK, RST, ALIGNWD,
+ output Q0, Q1, Q2, Q3, Q4, Q5, Q6
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module IDDRX2DQA(
+ input D, DQSR90, ECLK, SCLK, RST,
+ input RDPNTR2, RDPNTR1, RDPNTR0, WRPNTR2, WRPNTR1, WRPNTR0,
+ output Q0, Q1, Q2, Q3, QWL
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
module ODDRX1F(
input SCLK, RST, D0, D1,
output Q
@@ -173,6 +233,91 @@ module ODDRX1F(
endmodule
(* blackbox *)
+module ODDRX2F(
+ input SCLK, ECLK, RST, D0, D1, D2, D3,
+ output Q
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module ODDR71B(
+ input SCLK, ECLK, RST, D0, D1, D2, D3, D4, D5, D6,
+ output Q
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module OSHX2A(
+ input D0, D1, RST, ECLK, SCLK,
+ output Q
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module ODDRX2DQA(
+ input D0, D1, D2, D3, RST, ECLK, SCLK, DQSW270,
+ output Q
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module ODDRX2DQSB(
+ input D0, D1, D2, D3, RST, ECLK, SCLK, DQSW,
+ output Q
+);
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module TSHX2DQA(
+ input T0, T1, SCLK, ECLK, DQSW270, RST,
+ output Q
+);
+ parameter GSR = "ENABLED";
+ parameter REGSET = "SET";
+endmodule
+
+(* blackbox *)
+module TSHX2DQSA(
+ input T0, T1, SCLK, ECLK, DQSW, RST,
+ output Q
+);
+ parameter GSR = "ENABLED";
+ parameter REGSET = "SET";
+endmodule
+
+(* blackbox *)
+module DQSBUFM(
+ input DQSI, READ1, READ0, READCLKSEL2, READCLKSEL1, READCLKSEL0, DDRDEL,
+ input ECLK, SCLK,
+ input DYNDELAY7, DYNDELAY6, DYNDELAY5, DYNDELAY4,
+ input DYNDELAY3, DYNDELAY2, DYNDELAY1, DYNDELAY0,
+ input RST, RDLOADN, RDMOVE, RDDIRECTION, WRLOADN, WRMOVE, WRDIRECTION, PAUSE,
+ output DQSR90, DQSW, DQSW270,
+ output RDPNTR2, RDPNTR1, RDPNTR0, WRPNTR2, WRPNTR1, WRPNTR0,
+ output DATAVALID, BURSTDET, RDCFLAG, WRCFLAG
+);
+ parameter DQS_LI_DEL_ADJ = "FACTORYONLY";
+ parameter DQS_LI_DEL_VAL = 0;
+ parameter DQS_LO_DEL_ADJ = "FACTORYONLY";
+ parameter DQS_LO_DEL_VAL = 0;
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
+module DDRDLLA(
+ input CLK, RST, UDDCNTLN, FREEZE,
+ output LOCK, DDRDEL, DCNTL7, DCNTL6, DCNTL5, DCNTL4, DCNTL3, DCNTL2, DCNTL1, DCNTL0
+);
+ parameter FORCE_MAX_DELAY = "NO";
+ parameter GSR = "ENABLED";
+endmodule
+
+(* blackbox *)
module CLKDIVF(
input CLKI, RST, ALIGNWD,
output CDIVX
@@ -182,6 +327,13 @@ module CLKDIVF(
endmodule
(* blackbox *)
+module ECLKSYNCB(
+ input ECLKI, STOP,
+ output ECLKO
+);
+endmodule
+
+(* blackbox *)
module DCCA(
input CLKI, CE,
output CLKO
diff --git a/techlibs/ecp5/cells_map.v b/techlibs/ecp5/cells_map.v
index 23182bdeb..6ab4b69f2 100644
--- a/techlibs/ecp5/cells_map.v
+++ b/techlibs/ecp5/cells_map.v
@@ -47,6 +47,9 @@ module \$__DFFSE_NP1 (input D, C, E, R, output Q); TRELLIS_FF #(.GSR("DISABLED"
module \$__DFFSE_PP0 (input D, C, E, R, output Q); TRELLIS_FF #(.GSR("DISABLED"), .CEMUX("CE"), .CLKMUX("CLK"), .LSRMUX("LSR"), .REGSET("RESET"), .SRMODE("LSR_OVER_CE")) _TECHMAP_REPLACE_ (.CLK(C), .CE(E), .LSR(R), .DI(D), .Q(Q)); endmodule
module \$__DFFSE_PP1 (input D, C, E, R, output Q); TRELLIS_FF #(.GSR("DISABLED"), .CEMUX("CE"), .CLKMUX("CLK"), .LSRMUX("LSR"), .REGSET("SET"), .SRMODE("LSR_OVER_CE")) _TECHMAP_REPLACE_ (.CLK(C), .CE(E), .LSR(R), .DI(D), .Q(Q)); endmodule
+// For Diamond compatibility, FIXME: add all Diamond flipflop mappings
+module FD1S3BX(input PD, D, CK, output Q); TRELLIS_FF #(.GSR("DISABLED"), .CEMUX("1"), .CLKMUX("CLK"), .LSRMUX("LSR"), .REGSET("SET"), .SRMODE("ASYNC")) _TECHMAP_REPLACE_ (.CLK(CK), .LSR(PD), .DI(D), .Q(Q)); endmodule
+
`ifndef NO_LUT
module \$lut (A, Y);
parameter WIDTH = 0;
diff --git a/techlibs/ecp5/cells_sim.v b/techlibs/ecp5/cells_sim.v
index f27540bd7..8320ee70a 100644
--- a/techlibs/ecp5/cells_sim.v
+++ b/techlibs/ecp5/cells_sim.v
@@ -203,13 +203,14 @@ endmodule
// ---------------------------------------
-module TRELLIS_FF(input CLK, LSR, CE, DI, output reg Q);
+module TRELLIS_FF(input CLK, LSR, CE, DI, M, output reg Q);
parameter GSR = "ENABLED";
parameter [127:0] CEMUX = "1";
parameter CLKMUX = "CLK";
parameter LSRMUX = "LSR";
parameter SRMODE = "LSR_OVER_CE";
parameter REGSET = "RESET";
+ parameter [127:0] LSRMODE = "LSR";
reg muxce;
always @(*)
@@ -222,8 +223,12 @@ module TRELLIS_FF(input CLK, LSR, CE, DI, output reg Q);
wire muxlsr = (LSRMUX == "INV") ? ~LSR : LSR;
wire muxclk = (CLKMUX == "INV") ? ~CLK : CLK;
-
- localparam srval = (REGSET == "SET") ? 1'b1 : 1'b0;
+ generate
+ if (LSRMODE == "PRLD")
+ wire srval = M;
+ else
+ localparam srval = (REGSET == "SET") ? 1'b1 : 1'b0;
+ endgenerate
initial Q = srval;
@@ -339,6 +344,8 @@ module TRELLIS_SLICE(
parameter REG1_SD = "0";
parameter REG0_REGSET = "RESET";
parameter REG1_REGSET = "RESET";
+ parameter REG0_LSRMODE = "LSR";
+ parameter REG1_LSRMODE = "LSR";
parameter [127:0] CCU2_INJECT1_0 = "NO";
parameter [127:0] CCU2_INJECT1_1 = "NO";
parameter WREMUX = "WRE";
@@ -428,10 +435,11 @@ module TRELLIS_SLICE(
.CLKMUX(CLKMUX),
.LSRMUX(LSRMUX),
.SRMODE(SRMODE),
- .REGSET(REG0_REGSET)
+ .REGSET(REG0_REGSET),
+ .LSRMODE(REG0_LSRMODE)
) ff_0 (
.CLK(CLK), .LSR(LSR), .CE(CE),
- .DI(muxdi0),
+ .DI(muxdi0), .M(M0),
.Q(Q0)
);
TRELLIS_FF #(
@@ -440,10 +448,11 @@ module TRELLIS_SLICE(
.CLKMUX(CLKMUX),
.LSRMUX(LSRMUX),
.SRMODE(SRMODE),
- .REGSET(REG1_REGSET)
+ .REGSET(REG1_REGSET),
+ .LSRMODE(REG1_LSRMODE)
) ff_1 (
.CLK(CLK), .LSR(LSR), .CE(CE),
- .DI(muxdi1),
+ .DI(muxdi1), .M(M1),
.Q(Q1)
);
endmodule
@@ -547,3 +556,20 @@ module DP16KD(
parameter INITVAL_3E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INITVAL_3F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
endmodule
+
+// For Diamond compatibility, FIXME: add all Diamond flipflop mappings
+module FD1S3BX(input PD, D, CK, output Q);
+ TRELLIS_FF #(
+ .GSR("DISABLED"),
+ .CEMUX("1"),
+ .CLKMUX("CLK"),
+ .LSRMUX("LSR"),
+ .REGSET("SET"),
+ .SRMODE("ASYNC")
+ ) tff_i (
+ .CLK(CK),
+ .LSR(PD),
+ .DI(D),
+ .Q(Q)
+ );
+endmodule
diff --git a/techlibs/ecp5/ecp5_ffinit.cc b/techlibs/ecp5/ecp5_ffinit.cc
new file mode 100644
index 000000000..02945fff4
--- /dev/null
+++ b/techlibs/ecp5/ecp5_ffinit.cc
@@ -0,0 +1,198 @@
+/*
+ * yosys -- Yosys Open SYnthesis Suite
+ *
+ * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
+ * Copyright (C) 2018-19 David Shah <david@symbioticeda.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 Ecp5FfinitPass : public Pass {
+ Ecp5FfinitPass() : Pass("ecp5_ffinit", "ECP5: handle FF init values") { }
+ void help() YS_OVERRIDE
+ {
+ // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
+ log("\n");
+ log(" ecp5_ffinit [options] [selection]\n");
+ log("\n");
+ log("Remove init values for FF output signals when equal to reset value.\n");
+ log("If reset is not used, set the reset value to the init value, otherwise\n");
+ log("unmap out the reset (if not an async reset).\n");
+ }
+ void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
+ {
+ log_header(design, "Executing ECP5_FFINIT pass (implement FF init values).\n");
+
+ size_t argidx;
+ for (argidx = 1; argidx < args.size(); argidx++)
+ {
+ // if (args[argidx] == "-singleton") {
+ // singleton_mode = true;
+ // continue;
+ // }
+ break;
+ }
+ extra_args(args, argidx, design);
+
+ for (auto module : design->selected_modules())
+ {
+ log("Handling FF init values in %s.\n", log_id(module));
+
+ SigMap sigmap(module);
+ pool<Wire*> init_wires;
+ dict<SigBit, State> initbits;
+ dict<SigBit, SigBit> initbit_to_wire;
+ pool<SigBit> handled_initbits;
+
+ for (auto wire : module->selected_wires())
+ {
+ if (wire->attributes.count("\\init") == 0)
+ continue;
+
+ SigSpec wirebits = sigmap(wire);
+ Const initval = wire->attributes.at("\\init");
+ init_wires.insert(wire);
+
+ for (int i = 0; i < GetSize(wirebits) && i < GetSize(initval); i++)
+ {
+ SigBit bit = wirebits[i];
+ State val = initval[i];
+
+ if (val != State::S0 && val != State::S1)
+ continue;
+
+ if (initbits.count(bit)) {
+ if (initbits.at(bit) != val)
+ log_error("Conflicting init values for signal %s (%s = %s, %s = %s).\n",
+ log_signal(bit), log_signal(SigBit(wire, i)), log_signal(val),
+ log_signal(initbit_to_wire[bit]), log_signal(initbits.at(bit)));
+ continue;
+ }
+
+ initbits[bit] = val;
+ initbit_to_wire[bit] = SigBit(wire, i);
+ }
+ }
+ for (auto cell : module->selected_cells())
+ {
+ if (cell->type != "\\TRELLIS_FF")
+ continue;
+ SigSpec sig_d = cell->getPort("\\DI");
+ SigSpec sig_q = cell->getPort("\\Q");
+ SigSpec sig_lsr = cell->getPort("\\LSR");
+
+ if (GetSize(sig_d) < 1 || GetSize(sig_q) < 1)
+ continue;
+
+ SigBit bit_d = sigmap(sig_d[0]);
+ SigBit bit_q = sigmap(sig_q[0]);
+
+ std::string regset = "RESET";
+ if (cell->hasParam("\\REGSET"))
+ regset = cell->getParam("\\REGSET").decode_string();
+ State resetState;
+ if (regset == "SET")
+ resetState = State::S1;
+ else if (regset == "RESET")
+ resetState = State::S0;
+ else
+ log_error("FF cell %s has illegal REGSET value %s.\n",
+ log_id(cell), regset.c_str());
+
+ if (!initbits.count(bit_q))
+ continue;
+
+ State val = initbits.at(bit_q);
+
+ log("FF init value for cell %s (%s): %s = %c\n", log_id(cell), log_id(cell->type),
+ log_signal(bit_q), val != State::S0 ? '1' : '0');
+ // Initval is the same as the reset state. Matches hardware, nowt more to do
+ if (val == resetState) {
+ handled_initbits.insert(bit_q);
+ continue;
+ }
+
+ if (GetSize(sig_lsr) >= 1 && sig_lsr[0] != State::S0) {
+ std::string srmode = "LSR_OVER_CE";
+ if (cell->hasParam("\\SRMODE"))
+ srmode = cell->getParam("\\SRMODE").decode_string();
+ if (srmode == "ASYNC") {
+ log("Async reset value %c for FF cell %s inconsistent with init value %c.\n",
+ resetState != State::S0 ? '1' : '0', log_id(cell), val != State::S0 ? '1' : '0');
+ } else {
+ SigBit bit_lsr = sigmap(sig_lsr[0]);
+ Wire *new_bit_d = module->addWire(NEW_ID);
+ if (resetState == State::S0) {
+ module->addAndnotGate(NEW_ID, bit_d, bit_lsr, new_bit_d);
+ } else {
+ module->addOrGate(NEW_ID, bit_d, bit_lsr, new_bit_d);
+ }
+
+ cell->setPort("\\DI", new_bit_d);
+ cell->setPort("\\LSR", State::S0);
+
+ if(cell->hasPort("\\CE")) {
+ std::string cemux = "CE";
+ if (cell->hasParam("\\CEMUX"))
+ cemux = cell->getParam("\\CEMUX").decode_string();
+ SigSpec sig_ce = cell->getPort("\\CE");
+ if (GetSize(sig_ce) >= 1) {
+ SigBit bit_ce = sigmap(sig_ce[0]);
+ Wire *new_bit_ce = module->addWire(NEW_ID);
+ if (cemux == "INV")
+ module->addAndnotGate(NEW_ID, bit_ce, bit_lsr, new_bit_ce);
+ else
+ module->addOrGate(NEW_ID, bit_ce, bit_lsr, new_bit_ce);
+ cell->setPort("\\CE", new_bit_ce);
+ }
+ }
+ cell->setParam("\\REGSET", val != State::S0 ? Const("SET") : Const("RESET"));
+ handled_initbits.insert(bit_q);
+ }
+ } else {
+ cell->setParam("\\REGSET", val != State::S0 ? Const("SET") : Const("RESET"));
+ handled_initbits.insert(bit_q);
+ }
+ }
+
+ for (auto wire : init_wires)
+ {
+ if (wire->attributes.count("\\init") == 0)
+ continue;
+
+ SigSpec wirebits = sigmap(wire);
+ Const &initval = wire->attributes.at("\\init");
+ bool remove_attribute = true;
+
+ for (int i = 0; i < GetSize(wirebits) && i < GetSize(initval); i++) {
+ if (handled_initbits.count(wirebits[i]))
+ initval[i] = State::Sx;
+ else if (initval[i] != State::Sx)
+ remove_attribute = false;
+ }
+
+ if (remove_attribute)
+ wire->attributes.erase("\\init");
+ }
+ }
+ }
+} Ecp5FfinitPass;
+
+PRIVATE_NAMESPACE_END
diff --git a/techlibs/ecp5/synth_ecp5.cc b/techlibs/ecp5/synth_ecp5.cc
index bda03d251..4b889d672 100644
--- a/techlibs/ecp5/synth_ecp5.cc
+++ b/techlibs/ecp5/synth_ecp5.cc
@@ -255,10 +255,7 @@ struct SynthEcp5Pass : public ScriptPass
run("techmap -D NO_LUT -map +/ecp5/cells_map.v");
run("opt_expr -mux_undef");
run("simplemap");
- // TODO
-#if 0
run("ecp5_ffinit");
-#endif
}
if (check_label("map_luts"))