Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:17:09+00:00 2026-06-01T17:17:09+00:00

I am designing some hardware in Verilog, but in an effort to keep things

  • 0

I am designing some hardware in Verilog, but in an effort to keep things flexible, I am using parameters to set widths so that I can modify widths as needed without modifying code. One problem I have run into is in a section of code where I want to be able to do a parallel write into multiple cells.

parameter DATA_WIDTH = 16;
parameter BUFFER_SIZE = 16;
parameter LOAD_WIDTH = DATA_WIDTH*BUFFER_SIZE;

input [LOAD_WIDTH-1:0] i_load_data;

reg [DATA_WIDTH-1:0]    r_data_buf[BUFFER_SIZE-1:0];

...

always@(posedge clk) begin
....
    else if (i_load_flag) begin
        for(i = 0; i < BUFFER_SIZE; i = i + 1)
            r_data_buf[i] <= i_load_data[i * BUFFER_SIZE + BUFFER_SIZE - 1:i * BUFFER_SIZE];
    end
end

I need to keep r_data_buf as an array because of the way the data has to be read. It is also not clear to me why verilog doesn’t like this code since everything is a constant at compile time or how I can fix it and still get the behavior I want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:17:11+00:00Added an answer on June 1, 2026 at 5:17 pm

    The Verilog compiler is unhappy because it sees i_load_data[x:y] where both x and y depend on parameters so it is worried that this might result in a changing width (although in your case it is impossible).

    There are a couple of easy ways to fix this:

    1. Use the +: operator to specify the width. (I’ve also changed BUFFER_SIZE to DATA_WIDTH because that looked like a typo.) In this form you give the index of the LSB and the width of the data you wish to select.

      r_data_buf[i] <= i_load_data[i * DATA_WIDTH  +: DATA_WIDTH];
      
    2. Use an additional for loop to set each bit individually

      for(i = 0; i < BUFFER_SIZE; i = i + 1)
      begin
          for(j = 0; j < DATA_WIDTH; j = j + 1)
          begin
              r_data_buf[i][j] <= i_load_data[i * DATA_WIDTH  + j];
          end
      end
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing some complex classes in VB.net (but you can write your answer in
I am designing some immutable classes but I have to have some variables like
I am using Sinatra and I am in the middle of designing some models.
I'm designing a database which will store information about some artists. These artists can
I'm designing an application that will allow me to draw some functions on a
Looking for some reference material where i can get some OO designing problems and
I'm designing a method for storing some values in a SharedPreferences that relate to
I am designing a REST API where some resources can be filtered through query
Can anyone suggest some guidance for designing and implementing good Properties? I am concerned
(Let me give you some context) I am currently designing an application that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.