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.

bit mirroring in verilog...

Status
Not open for further replies.

davorin

Advanced Member level 3
Advanced Member level 3
Joined
Jun 7, 2003
Messages
901
Helped
11
Reputation
22
Reaction score
4
Trophy points
1,298
Location
Switzerland
Activity points
7,349
Is there an easy way of mirroring a bus signal in Verilog instead of using:

Code:
assign data_out = {data[0],data[1],data[2],data[3],.......};
 

In Verilog 2001 you can do this, but it's still not pretty:
Code:
module bitreverse (data, data_out);
  parameter bits = 16;
  input  [bits-1:0] data;
  output [bits-1:0] data_out;
  genvar g;

  generate for (g=0; g<bits; g=g+1) begin:bit
    assign data_out[g] = data[bits-1-g];
  end endgenerate
endmodule
 

reg[width-1:0] data_out;
always@(data) begin:reverse_bit
integer i;
for(i=0; i<width;i=i+1)
data_out = data[width-1-i];
end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top