Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register field ordering is broken. #69

Open
sjalloq opened this issue Jul 2, 2019 · 2 comments
Open

Register field ordering is broken. #69

sjalloq opened this issue Jul 2, 2019 · 2 comments

Comments

@sjalloq
Copy link

sjalloq commented Jul 2, 2019

The RDL spec shows how fields are packed in a register on p.44 of the v1.0 spec. In the case of LSB ordering, the following should hold:

lsb0;
reg {
field {} A; // Single bit from 0 to 0
field {} B[3]; // 3 bits from 3:1
// 4 bits from 7 to 4 are reserved and unused
field {} C[15:8]; // 8 Bits from 15 to 8
field {} C[5]; // 5 Bits from 20 to 16
};

However, this doesn't appear to be the case with Ordt. My understanding from the above example is that the following register:

reg irq_reg_6 { 
    regwidth = 16 ;
    interrupt _init_done ;
    interrupt _tc_ready ;
    interrupt _temp_low_warn[4:4] ;
    interrupt _temp_high_warn ;
    interrupt _temp_low_alarm ;
    interrupt _temp_high_alarm ;
};

should result in a packed register of the form:

Bit 0 : init_done
Bit 1: tc_ready
Bit 2 : reserved
Bit 3 : reserved
Bit 4 : temp_low_warn
Bit 5 : temp_high_warn
Bit 6 : temp_low_alarm
Bit 7 : temp_high_alarm

Ordt is outputting the following:

Bit 0 : init done
Bit 1: tc_ready
Bit 2 : temp_high_warn
Bit 3 : temp_low_alarm
Bit 4 : temp_low_warn
Bit 5 : temp_high_alarm

@sdnellen
Copy link
Contributor

sdnellen commented Jul 2, 2019

Yes, ordt will pack fields with no assigned offset in first available space in the reg starting from lsb. Spec was somewhat ambiguous here so implementation may differ from other compilers - given volume of code out there, default behavior will not be changed. Might be worth adding a switch at some point, but solution for now is to use bit offsets when instancing fields.

@sdnellen
Copy link
Contributor

Kamino cloned this issue to sdnellen/open-register-design-tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants