How to iterate over the unmapped registers of a bank in DML 1.4?

109 views Asked by At

I am trying to migrate some modules to DML 1.4 and I face some problems during bank content iteration. Specifically, I originally have the snippet below:

select reg in ($signals.unmapped_registers) where (reg.signal_number == signal) {
    // some statements here
} else {
    log "unimplemented", 1: "Power/Board: Signal %d is unimplemented", signal;
    return;
}

However, unmapped_registers is not valid in DML 1.4, thus leading to an unknown identifier compiler error.

How am I supposed to iterate over all the unmapped registers of a specific bank in DML 1.4 and select the one I want based on some specific criteria (i.e. the signal_number parameter)?

I've already tried swapping the select statement with foreach without success.

I've also tried to iterate over all bank registers that instantiate a specific template, but still without success.

2

There are 2 answers

3
Erik Carstensen On BEST ANSWER

You need to foreach over a template that has signal_number as type member.

When you iterate using foreach, the iteration variable is a run-time template reference, which means that not all declarations of the template can be accessed: Only parameters with a declared explicit type belong to the template type (together with all method declarations annotated with shared, and most session and saved declarations). So in your case, your problem is likely that signal_number does not have a declared type.

If you add a parameter type like this:

template register_with_signal is register {
  param signal_number : int;
  // default assignment must be a separate declaration
  param signal_number default -1;
  ...
}

then you can implement your loop like this:

method handle_signal(int signal) {
    foreach reg in (each register_with_signal in (this)) {
        if (reg.signal_number == signal) {
            // some statements here
            return;
        }
    }
    log unimpl: "signal %d is unimplemented", signal;
}
0
odenysex On

I also faced with this issue. Here is solution that i found:

foreach reg in (this._each_register) {
    if (reg.offset == unmapped_offset) { // constant unmapped_offset = 0xffff_ffff_ffff_ffff;
        <some actions for UNMAPPED regs>
    }
}