English 中文(简体)
借方物选择使用方言中的方略参数
原标题:Using parameters with for loop in verilog for bit selection

我正在Verilog设计一些硬件,但为了保持灵活性,我正在使用参数来设定宽度,以便我能够根据需要修改宽度,而不修改代码。 我陷入的一个问题是,在法典中,我想能够同时在多个囚室书写。

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

由于必须读取数据的方式,我需要把数据_成阵列。 我也不清楚的是,为什么真话象这一法典,因为所有东西都是在汇编时间时常有的,或者我如何确定,并且仍然得到我想要的行为。

最佳回答

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).

解决这一问题有两种容易的方法:

  1. 使用+:操作者具体说明宽度。 (I ve also change BUFFER_SIZE to DATA_WIDTH, which look as a打字) 您以这种形式提供LSB指数和希望选择的数据。

    r_data_buf[i] <= i_load_data[i * DATA_WIDTH  +: DATA_WIDTH];
    
  2. 单独设定每一比目

    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
    
问题回答

暂无回答




相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Elegant way building url request with parameters

There must me a more elegant way to build a URL with parameters in .NET then for example Response.Write("<a href=HeadOfMarketView.aspx"+Session["HOM"] != null ? Session["HOM"]+">Head of Market&...

Can you pass by reference in Java?

Sorry if this sounds like a newbie question, but the other day a Java developer mentioned about passing a paramter by reference (by which it was ment just pass a Reference object) From a C# ...

How to name a method that has an out parameter?

What is the common preference to name a method that has an out parameter inside? Usually I use Get as a prefix to mention that the method returns a value (like GetMyBusiness). But what if there is ...

How to create program startup parameters in python

I m just beginning to learn python and the program I m writing requires parameters for it to run with a specific task. For example (programs name is Samtho) samtho -i Mozilla_Firefox How can I do ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

using parameter in SQL with LIKE keyword

from my C#-programm, I access a SQL Server 2008 Database. I have a table with a fulltextindex and want to search for an indexed entry: SELECT page_id FROM page_categories WHERE page_title LIKE @title ...

采用网路服务方法

我撰写了一个网络服务,期望一个参数(所谓的“hlink”)成为一种ur。 在使用网络服务之前,URLEncode 所涉参数(“hlink”)。 然后我打电话......。

热门标签