Replies: 4 comments
-
|
Okay, so my conclusion so far is that it's not gonna be nice at all. To implement fully procedural generic resolution we'll need ordering of assignments, int n;
int k = 1;
if (k > 4) {n = 11;} else {n = 12;} // (1)
int m = n; // (2)
// cannot reorder (1) and (2)Impact on codegen
function hirn_generic_n$(int k);
int n;
if (k > 4)
n = 11;
else
n = 12;
return n;
endfunction
function hirn_generic_k$();
int k;
k = 1;
return k;
endfunction
function hirn_generic_m$(int n);
int m;
m = n;
return m;
endfunction
// Ordering based on dependencies
localparam k = hirn_generic_k$();
localparam n = hirn_generic_n$(k);
localparam m = hirn_generic_m$(n);This strange approach is a result of SV's The benefitsGenerating SV functions opens many new doors for us. One example would be parameter up-propagation. Currently module X {
input int x;
output int y;
}
impl X {
y = x + 17;
}could result in following SV output: function X_generic_out_y(int x);
return x + 17;
endfunction
module #(parameter x = 'x) X;
endmoduleand then, we could compile code such as: int x = 14;
int y;
X xmod {x, y};to localparam x = 14;
localparam y = X_generic_out_y(x);
X #(.x(x)) xmod; // forgive the lack of intermediate varsThis isn't anything revolutionary since we already support generic expressions in module interfaces but seems like a nice supplement. Compromise approachThe following assumptions make it possible for us to implement generic based on the current signal-like semantics and then smoothly transition to procedural-like approach without breaking backwards compatibility:
Moreover, these assumptions make implementing function-free SV codegen. The only ugly side-effect is that |
Beta Was this translation helpful? Give feedback.
-
|
module a {}
impl a {
int n, k;
k = 16;
n = k;
}module a;
localparam logic[63:0] n = k;
localparam logic[63:0] k = 64'h10;
endmoduleIt even compiles in SV, but I'm not sure if I want to know why. (oh god it even works) |
Beta Was this translation helpful? Give feedback.
-
|
I agree with the conclusions, not much to be added here. Hirl already implements the first two assumptions. |
Beta Was this translation helpful? Give feedback.
-
|
From my side, all needed checks are introduced in nearest PR #242 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions