Skip to content

Commit 7d42afd

Browse files
committedSep 14, 2017
Fixed bug where counter extraction on non-GreenPAK devices incorrectly handled parallel counter output
1 parent a55f425 commit 7d42afd

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed
 

Diff for: ‎passes/techmap/extract_counter.cc

+27-32
Original file line numberDiff line numberDiff line change
@@ -281,44 +281,34 @@ int counter_tryextract(
281281
max_loads = 3;
282282
if(cnout_loads.size() > max_loads)
283283
{
284-
//If we specified a limited set of cells for parallel output, check that we only drive them
285-
if(!parallel_cells.empty())
284+
for(auto c : cnout_loads)
286285
{
287-
for(auto c : cnout_loads)
288-
{
289-
if(c == underflow_inv)
290-
continue;
291-
if(c == cell)
292-
continue;
293-
if(c == muxload)
294-
continue;
286+
if(c == underflow_inv)
287+
continue;
288+
if(c == cell)
289+
continue;
290+
if(c == muxload)
291+
continue;
295292

293+
//If we specified a limited set of cells for parallel output, check that we only drive them
294+
if(!parallel_cells.empty())
295+
{
296296
//Make sure we're in the whitelist
297297
if( parallel_cells.find(c->type) == parallel_cells.end())
298298
return 17;
299+
}
299300

300-
//Figure out what port(s) are driven by it
301-
//TODO: this can probably be done more efficiently w/o multiple iterations over our whole net?
302-
RTLIL::IdString portname;
303-
for(auto b : qport)
301+
//Figure out what port(s) are driven by it
302+
//TODO: this can probably be done more efficiently w/o multiple iterations over our whole net?
303+
for(auto b : qport)
304+
{
305+
pool<ModIndex::PortInfo> ports = index.query_ports(b);
306+
for(auto x : ports)
304307
{
305-
pool<ModIndex::PortInfo> ports = index.query_ports(b);
306-
for(auto x : ports)
307-
{
308-
if(x.cell != c)
309-
continue;
310-
if(portname == "")
311-
portname = x.port;
312-
313-
//somehow our counter output is going to multiple ports
314-
//this makes no sense, don't allow inference
315-
else if(portname != x.port)
316-
return 17;
317-
}
308+
if(x.cell != c)
309+
continue;
310+
extract.pouts.insert(ModIndex::PortInfo(c, x.port, 0));
318311
}
319-
320-
//Save the other loads
321-
extract.pouts.insert(ModIndex::PortInfo(c, portname, 0));
322312
}
323313
}
324314
}
@@ -529,10 +519,15 @@ void counter_worker(
529519
string reset_type = "non-resettable";
530520
if(extract.has_reset)
531521
{
522+
if(extract.rst_inverted)
523+
reset_type = "negative";
524+
else
525+
reset_type = "positive";
526+
532527
//TODO: support other kind of reset
533-
reset_type = "async resettable";
528+
reset_type += " async resettable";
534529
}
535-
log(" Found %d-bit %s down counter %s (counting from %d) for register %s declared at %s\n",
530+
log(" Found %d-bit (%s) down counter %s (counting from %d) for register %s, declared at %s\n",
536531
extract.width,
537532
reset_type.c_str(),
538533
countname.c_str(),

0 commit comments

Comments
 (0)
Please sign in to comment.