Verilog: Is it possible to define array in generate block?
up vote
1
down vote
favorite
How can I define an array of "register_bank" in a "generate" block and use them?
I mean something like this:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
register[i][addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= register[i][addr];
end
end
end
endgenerate
verilog
add a comment |
up vote
1
down vote
favorite
How can I define an array of "register_bank" in a "generate" block and use them?
I mean something like this:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
register[i][addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= register[i][addr];
end
end
end
endgenerate
verilog
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
How can I define an array of "register_bank" in a "generate" block and use them?
I mean something like this:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
register[i][addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= register[i][addr];
end
end
end
endgenerate
verilog
How can I define an array of "register_bank" in a "generate" block and use them?
I mean something like this:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
register[i][addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= register[i][addr];
end
end
end
endgenerate
verilog
verilog
edited Nov 8 at 17:16
asked Nov 8 at 15:49
M A
341214
341214
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I just found the answer. We can do that using the name of the block. Just like the following code:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being : my_reg_bank
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
my_reg_bank[i].register[addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= my_reg_bank[i].register[addr];
end
end
end
endgenerate
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I just found the answer. We can do that using the name of the block. Just like the following code:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being : my_reg_bank
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
my_reg_bank[i].register[addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= my_reg_bank[i].register[addr];
end
end
end
endgenerate
add a comment |
up vote
0
down vote
I just found the answer. We can do that using the name of the block. Just like the following code:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being : my_reg_bank
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
my_reg_bank[i].register[addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= my_reg_bank[i].register[addr];
end
end
end
endgenerate
add a comment |
up vote
0
down vote
up vote
0
down vote
I just found the answer. We can do that using the name of the block. Just like the following code:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being : my_reg_bank
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
my_reg_bank[i].register[addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= my_reg_bank[i].register[addr];
end
end
end
endgenerate
I just found the answer. We can do that using the name of the block. Just like the following code:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being : my_reg_bank
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
my_reg_bank[i].register[addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= my_reg_bank[i].register[addr];
end
end
end
endgenerate
answered Nov 8 at 17:15
M A
341214
341214
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53211340%2fverilog-is-it-possible-to-define-array-in-generate-block%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown