shaiko
Advanced Member level 5
Hello,
I want to generate a parameterized register chain in Systemverilog.
The goal is to have both the width and depth of the chain to be overridable compile time parameters.
I aslo want the register chain to have an asynchronus reset - and the "default_value" to also be a parameter.
Is the code below correct ?
How should I define "default_value" , "number_of_regs" , "width_reg" ?
I want to generate a parameterized register chain in Systemverilog.
The goal is to have both the width and depth of the chain to be overridable compile time parameters.
I aslo want the register chain to have an asynchronus reset - and the "default_value" to also be a parameter.
Is the code below correct ?
How should I define "default_value" , "number_of_regs" , "width_reg" ?
Code:
module register_chain
#(
// default_value //
// number_of_regs //
// width_reg //
)
(
input arst ,
input clock ,
input [width_reg-1:0] in_data ,
output logic [0:number_of_regs-1] [width_reg-1:0] out_data
)
assign out_data [ 0 ] = in_data ;
always @ ( posedge clock or posedge arst )
begin
if ( arst == 1'b0 )
out_data = default_value ;
else
for ( integer index = 0 ; index < number_of_regs - 1 ; index ++ )
out_data [ index + 1 ] <= out_data [ index ] ;
end