Jump to content

SystemRDL for I2C peripheral device registers


Recommended Posts

I want to use SystemRDL to define some registers for a peripheral I2C device. I tried the following spec:

regfile eTACHS {
    name = "TACH registers";

    reg {
        name = "Read tach";

        field {
            desc = "Checksum-byte  0xFF means not ready";
        } CHECK[7:0] = 0;
        field {
            desc = "All 16bits should be 0x0000";
        } ZEROS[15:8] = 0;
        field {
            desc = "Value with the RPM";
        } TACH[24:16] = 0;
        field {
            desc = "Rest of the buffer is discarded";
        } RESERVED[31:25] = 0;
    } READ_TACH0 @ 0x0a;

    reg {
        name = "Read tach";

        field {
            desc = "Checksum-byte  0xFF means not ready";
        } CHECK[7:0] = 0;
        field {
            desc = "All 16bits should be 0x0000";
        } ZEROS[15:8] = 0;
        field {
            desc = "Value with the RPM";
        } TACH[24:16] = 0;
        field {
            desc = "Rest of the buffer is discarded";
        } RESERVED[31:25] = 0;
    } READ_TACH1 @ 0x0b;

};

addrmap fan {
    name = "FAN registers";

    eTACHS TACHS;

};

The data size for each I2C command is 32 bits.

The above rdl when I tried to `dump` it, I got the following result:

peakrdl dump fan_i2c.rdl
fan_i2c.rdl:36:7: error: Instance 'READ_TACH1' at offset +0xB:0xE overlaps with 'READ_TACH0' at offset +0xA:0xD
    } READ_TACH1 @ 0x0b;
      ^^^^^^^^^^
fatal: Elaborate aborted due to previous errors

My I2C peripheral device is a set of commands like:

READ_TACH0 = 0x0a
READ_TACH1 = 0x0b
....

The are many commands like that.

With SystemRDL, would it be possible to define a RDL for I2C slave register map ? Maybe some way to avoid overlaps errors ?

Well, I could find a RDL example for I2C specification. 

 

Thanks

 

 

Link to comment
Share on other sites

It would appear that you are trying to use register numbers or word addresses to specify byte addresses.  The registers seem to be 32-bits or 4 bytes wide. Left shift the register number or word address by at least 2 bits to get a byte address that avoids the overlap.  Example:

  } READ_TACH0 @ (0x0a << 2);
  } READ_TACH1 @ (0x0b << 2);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...