mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #1130 from YosysHQ/eddie/fix710
memory_dff: walk through more than one mux for computing read enable
This commit is contained in:
commit
add2d415fc
|
@ -182,11 +182,17 @@ struct MemoryDffWorker
|
||||||
|
|
||||||
if (mux_cells_a.count(sig_data) || mux_cells_b.count(sig_data))
|
if (mux_cells_a.count(sig_data) || mux_cells_b.count(sig_data))
|
||||||
{
|
{
|
||||||
|
RTLIL::SigSpec en;
|
||||||
|
RTLIL::SigSpec check_q;
|
||||||
|
|
||||||
|
do {
|
||||||
bool enable_invert = mux_cells_a.count(sig_data) != 0;
|
bool enable_invert = mux_cells_a.count(sig_data) != 0;
|
||||||
Cell *mux = enable_invert ? mux_cells_a.at(sig_data) : mux_cells_b.at(sig_data);
|
Cell *mux = enable_invert ? mux_cells_a.at(sig_data) : mux_cells_b.at(sig_data);
|
||||||
SigSpec check_q = sigmap(mux->getPort(enable_invert ? "\\B" : "\\A"));
|
check_q = sigmap(mux->getPort(enable_invert ? "\\B" : "\\A"));
|
||||||
|
|
||||||
sig_data = sigmap(mux->getPort("\\Y"));
|
sig_data = sigmap(mux->getPort("\\Y"));
|
||||||
|
en.append(enable_invert ? module->LogicNot(NEW_ID, mux->getPort("\\S")) : mux->getPort("\\S"));
|
||||||
|
} while (mux_cells_a.count(sig_data) || mux_cells_b.count(sig_data));
|
||||||
|
|
||||||
for (auto bit : sig_data)
|
for (auto bit : sig_data)
|
||||||
if (sigbit_users_count[bit] > 1)
|
if (sigbit_users_count[bit] > 1)
|
||||||
goto skip_ff_after_read_merging;
|
goto skip_ff_after_read_merging;
|
||||||
|
@ -195,7 +201,7 @@ struct MemoryDffWorker
|
||||||
{
|
{
|
||||||
disconnect_dff(sig_data);
|
disconnect_dff(sig_data);
|
||||||
cell->setPort("\\CLK", clk_data);
|
cell->setPort("\\CLK", clk_data);
|
||||||
cell->setPort("\\EN", enable_invert ? module->LogicNot(NEW_ID, mux->getPort("\\S")) : mux->getPort("\\S"));
|
cell->setPort("\\EN", en.size() > 1 ? module->ReduceAnd(NEW_ID, en) : en);
|
||||||
cell->setPort("\\DATA", sig_data);
|
cell->setPort("\\DATA", sig_data);
|
||||||
cell->parameters["\\CLK_ENABLE"] = RTLIL::Const(1);
|
cell->parameters["\\CLK_ENABLE"] = RTLIL::Const(1);
|
||||||
cell->parameters["\\CLK_POLARITY"] = RTLIL::Const(clk_polarity);
|
cell->parameters["\\CLK_POLARITY"] = RTLIL::Const(clk_polarity);
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// expect-wr-ports 1
|
||||||
|
// expect-rd-ports 1
|
||||||
|
// expect-rd-clk \clk
|
||||||
|
|
||||||
|
module top(input clk, input we, re, reset, input [7:0] addr, wdata, output reg [7:0] rdata);
|
||||||
|
|
||||||
|
reg [7:0] bram[0:255];
|
||||||
|
(* keep *) reg dummy;
|
||||||
|
|
||||||
|
always @(posedge clk)
|
||||||
|
if (reset)
|
||||||
|
dummy <= 1'b0;
|
||||||
|
else if (re)
|
||||||
|
rdata <= bram[addr];
|
||||||
|
else if (we)
|
||||||
|
bram[addr] <= wdata;
|
||||||
|
endmodule
|
|
@ -14,7 +14,7 @@ shift "$((OPTIND-1))"
|
||||||
|
|
||||||
bash ../tools/autotest.sh $seed -G *.v
|
bash ../tools/autotest.sh $seed -G *.v
|
||||||
|
|
||||||
for f in `egrep -l 'expect-(wr|rd)-ports' *.v`; do
|
for f in `egrep -l 'expect-(wr-ports|rd-ports|rd-clk)' *.v`; do
|
||||||
echo -n "Testing expectations for $f .."
|
echo -n "Testing expectations for $f .."
|
||||||
../../yosys -qp "proc; opt; memory -nomap;; dump -outfile ${f%.v}.dmp t:\$mem" $f
|
../../yosys -qp "proc; opt; memory -nomap;; dump -outfile ${f%.v}.dmp t:\$mem" $f
|
||||||
if grep -q expect-wr-ports $f; then
|
if grep -q expect-wr-ports $f; then
|
||||||
|
@ -25,6 +25,10 @@ for f in `egrep -l 'expect-(wr|rd)-ports' *.v`; do
|
||||||
grep -q "parameter \\\\RD_PORTS $(gawk '/expect-rd-ports/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
grep -q "parameter \\\\RD_PORTS $(gawk '/expect-rd-ports/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||||
{ echo " ERROR: Unexpected number of read ports."; false; }
|
{ echo " ERROR: Unexpected number of read ports."; false; }
|
||||||
fi
|
fi
|
||||||
|
if grep -q expect-rd-clk $f; then
|
||||||
|
grep -q "connect \\\\RD_CLK \\$(gawk '/expect-rd-clk/ { print $3; }' $f)\$" ${f%.v}.dmp ||
|
||||||
|
{ echo " ERROR: Unexpected read clock."; false; }
|
||||||
|
fi
|
||||||
echo " ok."
|
echo " ok."
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue