Replies: 1 comment
-
|
Currently we must allow all types for index access. If it cannot be statically determined (eventually with constraint annotations), that the index is in a valid range, a dynamic check has to be added in simulator and hardware either manually or from the generators, e.g. for In the long run I want to support subrange types. Then again it would be possible to statically check the correctness. Furthermore, it would be possible to use the relation notation for register file specification:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I think we haven't discussed the typechecking semantics for accessing multidimensional types yet.
Consider the following example:
Register
Xhas two dimensions, with an index dimension of size5. This size can’t be represented by a concrete type as it is no power of2.Now the question is how to check access to such a register.
t1-3are functions with different index access types:t1has an index type ofBits<5>, which may also contain values up to 31.t2has an index type ofBits<2>, with a maximum value of 3, so it is always in range.t3has an index type ofBits<3>, with a maximum value of 7. This is the next fitting type that can hold all values that can be used to access the index dimension. However, it may also hold values 5-7 which are out of range.I think
t2must be definitely valid.t3must also be valid; otherwise, there would be no way to access the outermost dimension4.IMO
t1should be valid as well, because it doesn’t differ fromt3which could also be out of range. Additionally, the user didn’t specify any concrete type for the index, so a type error would be pretty confusing.This leaves us in a state where out-of-range access isn’t statically prevented, which causes undefined behavior. In the case of registers, the user could specify annotations that define the behavior on out-of-range accesses (read and write), e.g. raising an exception or returning some computed value.
However, it is hard to specify such behavior for generic multi-dimensional types (other than registers).
@AndreasKrall, @flofriday, @benedikt-l-huber, @kper What are your thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions