Thursday, March 14, 2013

Reversing the Bits

 This program is to reverse a bit stream. In this example I have taken a 4 bit no. If you give an input like 0011, the output will be 1100.


module rev_mod(
input [WIDTH:0]in,
output reg [WIDTH:0] y
);
 

parameter WIDTH=3;
integer i;

always@(*)
begin
for(i=0; i<=WIDTH; i=i+1)
begin
y [WIDTH-i] = in[i];
end
#200  $display("y %b\t in %b",y,in);
end
endmodule 
  

No comments: