Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


multidimensional array help

multidimensional array help

multidimensional array help

I'm interested in improving how I use multidimensional arrays. I've created an example design below that implements an AND-OR mux by driving all but one of five vectors to 0 (only one of SelA-SelE can assert at a time) and then ORing the five vectors together.


integer i;
  reg [63:0] pVal [4:0];

  always @(posedge PClk or posedge aReset) begin
    if (aReset) begin
      for (i=0; i<=4; i=i+1) pVal[i] <= 0;
      pValOut <= 0;
    end else begin
      pVal[0] <= SelA? SigA : 64'b0;
      pVal[1] <= SelB? SigB : 64'b0;
      pVal[2] <= SelC? SigC : 64'b0;
      pVal[3] <= SelD? SigD : 64'b0;
      pVal[4] <= SelE? SigE : 64'b0;
      pValOut <= pVal[0] | pVal[1] | pVal[2] | pVal[3] | pVal[4];

Here are my questions:
1) Can the reset assignment be done without a FOR loop? For example, in VHDL, the assignment would be
pVal <= (others => (others => '0'));

2) Can the OR of all of the array elements be done with a FOR loop so I can more easily change the number of elements? The VHDL would look like this:
MyVar := (others => '0');
for i in 0 to 7 loop
MyVar := MyVar or pVal(i);
end loop;
pValOut <= MyVar;

Can I do something similar in Verilog?

Thanks very much.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close