SystemRDL/systemrdl-compiler

regfile inside addrmap does not compile

joecrop opened this issue · 1 comments

I am trying to compile an RDL file that has a regfile inside an addrmap, and I am getting the error defined here.

error: Address map 'top' must contain at least one reg, regfile, mem, or addrmap.

I have tried several permutations of this, all with the same error. I also tried to compile an example from the SystemRDL book (5.1.2.5 : Example 1):

addrmap top {
  regfile example {
    reg some_reg { field {} a; };
    some_reg a @0x0;
    some_reg b @0x4;
    some_reg c; // Implies address of 8
    // Address 0xC is not implemented or specified
    some_reg d @0x10;
  };
};

I have noticed that if I add a reg at the top level, I can get past this error:

addrmap top {
  regfile example {
    reg some_reg { field {} a; };
    some_reg a @0x0;
    some_reg b @0x4;
    some_reg c; // Implies address of 8
    // Address 0xC is not implemented or specified
    some_reg d @0x10;
  };
  reg { field {} a; } reg1 @ 0x04; // adding this removes the error
};

This is actually a typo in the SystemRDL spec. Their examples have a lot of issues: https://systemrdl-compiler.readthedocs.io/en/stable/dev_notes/rdl_spec_errata.html#compilation-issues-in-examples

The issue is that although they create a declaration of the regfile example, they fail to actually instantiate it in their example.
5.1.2.5 : Example 1 should have been:

addrmap top {
  regfile example {
    reg some_reg { field {} a; };
    some_reg a @0x0;
    some_reg b @0x4;
    some_reg c; // Implies address of 8
    // Address 0xC is not implemented or specified
    some_reg d @0x10;
  } example_inst @ 0x00; // <-------- Add missing instance
};