Sep 6, 2020 #1 S 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 ?
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 ?
Sep 7, 2020 #2 dpaul Advanced Member level 5 Joined Jan 16, 2008 Messages 1,804 Helped 317 Reputation 635 Reaction score 346 Trophy points 1,373 Location Germany Activity points 13,104 I am not a Verilog guy..... But can't you assign each elements of the array inside a double-loop?
Sep 7, 2020 #3 S 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 I can, but I'm looking for a single liner - like VHDL's : Code: some_array <= ( others => ( others => '1' ) ) ;
I can, but I'm looking for a single liner - like VHDL's : Code: some_array <= ( others => ( others => '1' ) ) ;
Sep 8, 2020 #4 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,822 Reputation 3,654 Reaction score 1,808 Trophy points 1,393 Location USA Activity points 60,207 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 Sep 8, 2020 --- If you had defined it using an unpacked array format then you would use a for loop to set each element.
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 Sep 8, 2020 --- If you had defined it using an unpacked array format then you would use a for loop to set each element.