-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
PatternGenenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Currently we cannot generate patterns for the signed/unsigned clipping instructions mainly due to their variable clipping position.
Let’s take the CoreDSL2 description we use:
CV_CLIP {
encoding: 7'b0111000 :: Iuimm5[4:0] :: rs1[4:0] :: 3'b011 :: rd[4:0] :: 7'b0101011;
assembly: {"cv.clip", "{name(rd)}, {name(rs1)}, {Iuimm5}" };
behavior: {
if (rd != 0) {
signed<32> a = (Iuimm5) ? -(1 << (Iuimm5 - 1)) : -1;
signed<32> b = (Iuimm5) ? ((1 << (Iuimm5 - 1)) - 1) : 0;
// Equivalent to: X[rd] = min(max(X[rs1], a), b);
if (X[rs1] <= a) X[rd] = a;
else if (X[rs1] >= b) X[rd] = b;
else X[rd] = X[rs1];
}
}
}
As soon as luimm5 is fixed to a specific value between 0 and 31, the behavior can be simplified drastically :
// Assume luimm5 = 8
// Equivalent to: X[rd] = min(max(X[rs1], -128), 127);
if (X[rs1] <= -128) X[rd] = -128;
else if (X[rs1] >= 127) X[rd] = 127;
else X[rd] = X[rs1];
Generating a pattern for each of the 32 possible inputs would be trivial.
Would should add a functionality to the patterngen which loops over all possible values of immediates to extract specific more simple patterns. To keep the number of generated patterns and processing overhead low, some considerations are required:
- only enable this for very small immediates (for example 5bits or less) and maybe special cases (I.e. 0b00..0 and 0b11..1)
- Require users to explicitly enable this feature either via cmdline options or instruction/operand attributes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
PatternGenenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed