Assigning to a parameterized 2d Verilog array

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
Hello,

I have a Verilog array defined as :
logic [0:num_elements-1] [element_width] some_array ;

I want to assign every array element with a vector that is all ones: "11...1".
I tried this but I get an error:
Code:
some_array <= { num_elements { element_width { 1'b1 } } } ;
What's the correct syntax ?
 

I am not a Verilog guy.....

But can't you assign each elements of the array inside a double-loop?
 

I can, but I'm looking for a single liner - like VHDL's :
Code:
some_array <= ( others => ( others => '1' ) ) ;
 

Just assign it directly as you defined it as a packed array format


Code Verilog - [expand]
1
some_array <= {num_elements*element_width{1'b1}};


--- Updated ---

If you had defined it using an unpacked array format then you would use a for loop to set each element.
 
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…