You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// module definitionmoduleModuleA#(
param ParamA: u32 =10,
const ParamB: u32 =10, // trailing comma is allowed
) (
i_clk :input clock ,
i_rst :input reset ,
i_sel :inputlogic ,
i_data:inputlogic<ParamA> [2], // `[]` means unpacked array
o_data: output logic<ParamA> , // `<>` means packed array
) {// const parameter declaration// `param` is not allowed in moduleconst ParamC: u32 =10;
// variable declaration var r_data0: logic<ParamA>;
var r_data1: logic<ParamA>;
// value binding
let _w_data2: logic<ParamA>= i_data;
// always_ff statement with reset// `always_ff` can take a mandatory clock and a optional reset// `if_reset` means `if (i_rst)`. This conceals reset porality// `()` of `if` is not required// `=` in `always_ff` is non-blocking assignmentalways_ff (i_clk, i_rst) {
if_reset {
r_data0 =0;
}elseif i_sel {
r_data0 = i_data[0];
}else{
r_data0 = i_data[1];
}}// always_ff statement without resetalways_ff (i_clk) {
r_data1 = r_data0;
}assign o_data = r_data1;
}
All the statements below contain errors, but they can still compile successfully. let _w_data2: logic<ParamA> = i_data; let _w_data2: logic<ParamA> = i_data[2]; let _w_data2: logic<ParamA> = i_sel; let _w_data2: logic<ParamA> = i_sel[2];
The text was updated successfully, but these errors were encountered:
Example from playground:
All the statements below contain errors, but they can still compile successfully.
let _w_data2: logic<ParamA> = i_data;
let _w_data2: logic<ParamA> = i_data[2];
let _w_data2: logic<ParamA> = i_sel;
let _w_data2: logic<ParamA> = i_sel[2];
The text was updated successfully, but these errors were encountered: