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

Address space accesses in load/store instructions are too narrow #4

Open
jopperm opened this issue Jun 24, 2022 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@jopperm
Copy link
Contributor

jopperm commented Jun 24, 2022

Problem

We currently define the main memory address space as:

extern char MEM[1<<XLEN];

Then, a single index expression like in here:

LW {
encoding: imm[11:0] :: rs1[4:0] :: 3'b010 :: rd[4:0] :: 7'b0000011;
assembly: "{name(rd)}, {imm}({name(rs1)})";
behavior: {
unsigned<XLEN> load_address = X[rs1%RFS] + (signed<12>)imm;
signed<32> res = (signed<32>)MEM[load_address];
if((rd%RFS)!=0) X[rd%RFS]=(unsigned<32>)res;
}
}

... would only yield a char result (as declared), which is then wrongly sign-extended to 32-bits.

Possible solutions

  1. Make multiple loads and concatenation explicit.
X[rd] = MEM[base + 3] :: MEM[base + 2] :: MEM[base + 1] :: MEM[base + 0];
  1. Introduce a ranged index operator for CoreDSL (currently, this is only supported for bit ranges, and with constant indices!)
X[rd] = MEM[base+3:base];
  1. Make loads as wide as the assignment target, and stores as wide as the value to be written. This would be the first context-sensitive type rule in the language, and hence doesn't fit well into the overall semantics.
@jopperm jopperm added the bug Something isn't working label Jun 24, 2022
@jopperm jopperm changed the title Address spaces accesses in load/store instruction are too narrow Address space accesses in load/store instructions are too narrow Jun 24, 2022
@wysiwyng
Copy link
Contributor

wysiwyng commented Jul 8, 2022

in the case of M2-ISA-R, 3) is (and always was) done implicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants