V
Veeresh
Guest
Hi all,
I am new to systemverilog and I have to write synthesizable .sv. I
have some peculiar requirement and I have thought of following pseudo
code for my requirement.
My requirement: parametrized number of registers and bit widths in
each registers. Following shows an example
reg1 [0:13]
reg2 [0:3]
..
..
..
..
..
..
reg100 [0-34]
==================================================
code
==================================================
module top ();
parameter no_of_regs = 100;
paramerer register1_width = 13;
paramerer register2_width = 3;
paramerer register3_width = 103;
paramerer register4_width = 32;
..
..
..
..
..
paramerer register100_width = 34;
genvar i,j;
for i (0 to no_of_regs)
for j (0 to register1_width)
dff DFF[no_of_regs] #(register1_width) (.clk(clk), .in(in
[register1_width]), .en(en), .out(out[register1_width]));
endfor
endfor
endmodule
module dff #(parameter register_width = 1)(clk, in, en, out);
endmodule
==================================================
My understanding with this code.
i generates 100 registers.
Instance name is DFF[0], DFF[1], DFF[2]......DFF[100]
If I want to access particular instance, I can use DFF[0], DFF[1], DFF
[2]......DFF[100]
Also en is array of lengh 100, en[0], en[1], en[2].....en[100]
I was unable to find following from the spec.
Line for j (0 to register1_width) - this line will generate only one
register.
How to vary register width for each value of i?
Also, if I declare parameters as given below.
paramerer register[0] = 13;
paramerer register[1] = 3;
paramerer register[2] = 103;
paramerer register[3] = 32;
..
..
..
..
..
paramerer register[100] = 34;
Can I use following generate statement?
genvar i,j;
for i (0 to no_of_regs)
for j (0 to register)
dff DFF[no_of_regs] (.clk(clk), .in(in[register[j]), .en(en
[j]), .out(out[register[j]]));
endfor
endfor
endmodule
Please help me.
Thanks,
Veeresh
I am new to systemverilog and I have to write synthesizable .sv. I
have some peculiar requirement and I have thought of following pseudo
code for my requirement.
My requirement: parametrized number of registers and bit widths in
each registers. Following shows an example
reg1 [0:13]
reg2 [0:3]
..
..
..
..
..
..
reg100 [0-34]
==================================================
code
==================================================
module top ();
parameter no_of_regs = 100;
paramerer register1_width = 13;
paramerer register2_width = 3;
paramerer register3_width = 103;
paramerer register4_width = 32;
..
..
..
..
..
paramerer register100_width = 34;
genvar i,j;
for i (0 to no_of_regs)
for j (0 to register1_width)
dff DFF[no_of_regs] #(register1_width) (.clk(clk), .in(in
[register1_width]), .en(en), .out(out[register1_width]));
endfor
endfor
endmodule
module dff #(parameter register_width = 1)(clk, in, en, out);
endmodule
==================================================
My understanding with this code.
i generates 100 registers.
Instance name is DFF[0], DFF[1], DFF[2]......DFF[100]
If I want to access particular instance, I can use DFF[0], DFF[1], DFF
[2]......DFF[100]
Also en is array of lengh 100, en[0], en[1], en[2].....en[100]
I was unable to find following from the spec.
Line for j (0 to register1_width) - this line will generate only one
register.
How to vary register width for each value of i?
Also, if I declare parameters as given below.
paramerer register[0] = 13;
paramerer register[1] = 3;
paramerer register[2] = 103;
paramerer register[3] = 32;
..
..
..
..
..
paramerer register[100] = 34;
Can I use following generate statement?
genvar i,j;
for i (0 to no_of_regs)
for j (0 to register)
dff DFF[no_of_regs] (.clk(clk), .in(in[register[j]), .en(en
[j]), .out(out[register[j]]));
endfor
endfor
endmodule
Please help me.
Thanks,
Veeresh