@@ -482,31 +482,40 @@ void MemMapping::dump_config(MemConfig &cfg) {
482
482
}
483
483
484
484
std::pair<bool , Const> search_for_attribute (Mem mem, IdString attr) {
485
+ // priority of attributes:
486
+ // 1. attributes on memory itself
487
+ // 2. attributes on a read or write port
488
+ // 3. attributes on data signal of a read or write port
489
+ // 4. attributes on address signal of a read or write port
490
+
485
491
if (mem.has_attribute (attr))
486
492
return std::make_pair (true , mem.attributes .at (attr));
487
- for (auto &port: mem.rd_ports ){
493
+
494
+ for (auto &port: mem.rd_ports )
495
+ if (port.has_attribute (attr))
496
+ return std::make_pair (true , port.attributes .at (attr));
497
+ for (auto &port: mem.wr_ports )
488
498
if (port.has_attribute (attr))
489
499
return std::make_pair (true , port.attributes .at (attr));
490
- log_debug (" looking for attribute %s on signal %s\n " , log_id (attr), log_signal (port.data ));
500
+
501
+ for (auto &port: mem.rd_ports )
491
502
for (SigBit bit: port.data )
492
503
if (bit.is_wire () && bit.wire ->has_attribute (attr))
493
504
return std::make_pair (true , bit.wire ->attributes .at (attr));
494
- log_debug ( " looking for attribute %s on signal %s \n " , log_id (attr), log_signal ( port. data ));
495
- for (SigBit bit: port.addr )
505
+ for ( auto & port: mem. wr_ports )
506
+ for (SigBit bit: port.data )
496
507
if (bit.is_wire () && bit.wire ->has_attribute (attr))
497
508
return std::make_pair (true , bit.wire ->attributes .at (attr));
498
- }
499
- for (auto &port: mem.wr_ports ){
500
- if (port.has_attribute (attr))
501
- return std::make_pair (true , port.attributes .at (attr));
502
- log_debug (" looking for attribute %s on signal %s\n " , log_id (attr), log_signal (port.data ));
503
- for (SigBit bit: port.data )
509
+
510
+ for (auto &port: mem.rd_ports )
511
+ for (SigBit bit: port.addr )
504
512
if (bit.is_wire () && bit.wire ->has_attribute (attr))
505
513
return std::make_pair (true , bit.wire ->attributes .at (attr));
514
+ for (auto &port: mem.wr_ports )
506
515
for (SigBit bit: port.addr )
507
516
if (bit.is_wire () && bit.wire ->has_attribute (attr))
508
517
return std::make_pair (true , bit.wire ->attributes .at (attr));
509
- }
518
+
510
519
return std::make_pair (false , Const ());
511
520
}
512
521
0 commit comments