[SOLVED] ORing even & odd bits of a vector

Status
Not open for further replies.

rahdirs

Advanced Member level 1
Joined
May 22, 2013
Messages
424
Helped
93
Reputation
192
Reaction score
91
Trophy points
1,308
Location
Mordor
Activity points
4,492
Suppose, I have a vector:


Code Verilog - [expand]
1
logic [127:0] x; // one hot



I want to OR the even bits & odd bits seperately, as in x_even = x[0] | x[2] | x[4] | ...... x[126] & similarly for the odd bits. I tried the following but it's pointing a syntax error at |=

Code Verilog - [expand]
1
2
3
4
5
6
generate
  for (i=0;i<64;i++) begin
    x_even |= x[2*i];
    x_odd  |= x[2*i+1];
  end
endgenerate



Regards,
rahdirs
 

Code:
  odd = |((64){2'b01} & x);
  even  = |((64){2'b10} & x);

I'm not sure if Verilog supports |=. SystemVerilog does.

In either case, this probably can't be done in a generate due to multiple assignments to the same net.
 
Reactions: rahdirs

    rahdirs

    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…