mirror of
https://github.com/YosysHQ/yosys
synced 2026-04-26 13:53:34 +00:00
xilinx_dsp: signorm compatibility
This commit is contained in:
parent
26a1839fb7
commit
5bff8b4068
2 changed files with 54 additions and 7 deletions
|
|
@ -64,18 +64,61 @@ static Cell* addDsp(Module *module) {
|
|||
return cell;
|
||||
}
|
||||
|
||||
SigPool simd_signals(Module *module, SigMap* sigmap)
|
||||
{
|
||||
SigPool simd_signals;
|
||||
// Mark representatives of wires that have the attribute
|
||||
for (auto wire : module->wires()) {
|
||||
SigSpec reps = (*sigmap)(wire);
|
||||
log_assert(reps.size() == wire->width);
|
||||
for (int i = 0; i < reps.size(); i++) {
|
||||
auto bit = reps[i];
|
||||
auto src_bit = SigBit(wire, i);
|
||||
if (src_bit.is_wire() && src_bit.wire->has_attribute(ID::use_dsp)) {
|
||||
if (src_bit.wire->get_strpool_attribute(ID::use_dsp).count("simd")) {
|
||||
simd_signals.add(bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Also mark all aliases of those representatives
|
||||
for (auto wire : module->wires()) {
|
||||
SigSpec reps = (*sigmap)(wire);
|
||||
log_assert(reps.size() == wire->width);
|
||||
for (int i = 0; i < reps.size(); i++) {
|
||||
auto bit = reps[i];
|
||||
auto src_bit = SigBit(wire, i);
|
||||
if (simd_signals.check(bit)) {
|
||||
simd_signals.add(src_bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// This seems silly, but that's generalized RTLIL for you!
|
||||
return simd_signals;
|
||||
}
|
||||
|
||||
bool is_allowed(SigSpec& sig, SigPool& allowed_bits)
|
||||
{
|
||||
for (auto bit : sig.bits()) {
|
||||
if (!allowed_bits.check(bit)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void xilinx_simd_pack(Module *module, SigMap* sigmap, const std::vector<Cell*> &selected_cells)
|
||||
{
|
||||
std::deque<Cell*> simd12_add, simd12_sub;
|
||||
std::deque<Cell*> simd24_add, simd24_sub;
|
||||
|
||||
SigPool simds = simd_signals(module, sigmap);
|
||||
|
||||
for (auto cell : selected_cells) {
|
||||
if (!cell->type.in(ID($add), ID($sub)))
|
||||
continue;
|
||||
SigSpec Y = cell->getPort(ID::Y);
|
||||
if (!Y.is_chunk())
|
||||
continue;
|
||||
if (!Y.as_chunk().wire->get_strpool_attribute(ID(use_dsp)).count("simd"))
|
||||
if (!is_allowed(Y, simds))
|
||||
continue;
|
||||
if (GetSize(Y) > 25)
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue