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.

Is there an elegant way to generate a pattern of statements?

Status
Not open for further replies.

houyh

Newbie level 1
Newbie level 1
Joined
Apr 9, 2014
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
0
Activity points
0
Sometimes we want to do this in Verilog HDL:

Code:
assign outBus[0] = (inBus == 8'h00); 
assign outBus[1] = (inBus == 8'h01); 
assign outBus[2] = (inBus == 8'h02); 
..................................
assign outBus[255] = (inBus == 8'hff);

Or this:

Code:
case (State)
    6'd0 : A[0] <= 1; 
    6'd1 : A[1] <= 1; 
    .............
    6'd63 : A[63] <= 1; 
endcase

For both examples, it would be very tedious to repeat every line manually.

For instantiating multiple components, we do have generate statement to simplify the implementation. But it seems not helpful for the examples above.

Indeed, we can use PERL or another script language to generate such a pattern externally. However, the HDL code itself will still be very lengthy.

So, is there a more elegant way to implement the functionality of such a code block without actually using a huge block of codes? Any response will be appreciated.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top