Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

if else inside generate statement

Status
Not open for further replies.

shainky

Junior Member level 1
Joined
Apr 18, 2009
Messages
17
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,281
Activity points
1,414
hi,
can i use if else inside generate statement?

Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
generate
      for (i = 0; i < my_size; i = i + 1)
    begin : size
                    u_mux(.in(index[i]),
                  .sel(idx_int[i]),
                  .out(side[4*i +: 4]));
           if (i == 'd0)
           assign my_data[64*i +: 64] = {{56{1'b0}},data[8*i +: 8]}; 
       else if (i == 'd1) 
            assign my_data[64*i +: 64] = (datasize == 1'b1) ? {{48{1'b0}}, data[8*i +: 16]} : 
                        {{56{1'b0}},data[8*i +: 8]}; 
       else  
            assign my_data[64*i +: 64] = {{56{1'b0}},data[((8*i)+8) +: 8]}; 
 
end 
   endgenerate



I think we cannot use assign statement with if statement.
But the moment i am removing assign statement i am getting spyglass lint errors.
Is this code synthesizable?
 
Last edited by a moderator:

A generate if can be used in this place, because the if condition is static, only depending on generate var i.

Regular if statements can be only used inside a sequential block or function.
 

The if is used to select how the least significant 64-bit words are assigned to the my_data bus. As the if is used to conditionally assign 64-bits it is required, otherwise the three assigns would conflict with each other.

It should have no problen synthesizing.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top