FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2009, 01:56 PM
Charly
Guest
 
Posts: n/a
Default reverse 16 bits

Hi,

I have a parallel driver in verilog generate by a wizard tool in
Quartus II.
So i must reverse the 16 first bits in the parallel port (because the
16 first bits correspond to a data bus and it is inverted)

Here is the code: http://pastebin.com/f196e46c9

I tried a lot of changes, but without result.
I am bad in verilog and VHDL barely better, so I ask your help.

thanks.

(ps: sorry for my english but I'm french.)
Reply With Quote
  #2 (permalink)  
Old 06-17-2009, 07:36 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: reverse 16 bits

Charly wrote:
> Hi,
>
> I have a parallel driver in verilog generate by a wizard tool in
> Quartus II.
> So i must reverse the 16 first bits in the parallel port (because the
> 16 first bits correspond to a data bus and it is inverted)
>
> Here is the code: http://pastebin.com/f196e46c9
>
> I tried a lot of changes, but without result.
> I am bad in verilog and VHDL barely better, so I ask your help.
>
> thanks.



Maybe a verilog function would do the trick.
Here's how I do it in vhdl:

function reverse (arg : unsigned)
return unsigned is
variable rev_v : unsigned(arg'reverse_range);
begin
for i in arg'range loop
rev_v(i) := arg(i);
end loop;
return rev_v;
end function;

-- Mike Treseler

(ps: sorry for my french and english but I'm north american)
Reply With Quote
  #3 (permalink)  
Old 06-17-2009, 08:32 PM
pallav
Guest
 
Posts: n/a
Default Re: reverse 16 bits

On Jun 17, 1:36*pm, Mike Treseler <mtrese...@gmail.com> wrote:
> Charly wrote:
> > Hi,

>
> > I have a parallel driver in verilog generate by a wizard tool in
> > Quartus II.
> > So i must reverse the 16 first bits in the parallel port (because the
> > 16 first bits correspond to a data bus and it is inverted)

>
> > Here is the code:http://pastebin.com/f196e46c9

>
> > I tried a lot of changes, but without result.
> > I am bad in verilog and VHDL barely better, so I ask your help.

>
> > thanks.

>
> Maybe a verilog function would do the trick.
> Here's how I do it in vhdl:
>
> * *function reverse (arg : unsigned)
> * * * return unsigned is
> * * * variable rev_v : unsigned(arg'reverse_range);
> * *begin
> * * * for i in arg'range loop
> * * * * *rev_v(i) := arg(i);
> * * * end loop;
> * * * return rev_v;
> * *end function;
>
> * * * -- Mike Treseler
>
> (ps: sorry for my french and english but I'm north american)


Charly,

Here is how you can reverse bits in verilog. You can make a function/
task out of this:

module reverse();
parameter WIDTH = 4;

reg [WIDTH-1:0] rev, data;
integer i;

initial
begin
data=4'b1110;

for (i=WIDTH-1; i >= 0; i=i-1)
rev[WIDTH-1-i]=data[i];

$display("data %b\t tmp %b",data,rev);

#5 $finish;
end
endmodule


Also I find that http://www.pastebin.cz/ has good syntax
highlighter for Verilog/VHDL for pasting so you may
want to use that in the future.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can change UART data port from 8 bits to 16 bits? Zhi VHDL 2 10-09-2007 06:23 AM
reverse engineering ? binaryboy FPGA 33 05-18-2006 06:08 AM
truncate 20 bits to 10 bits mmt1 Verilog 1 02-18-2006 06:31 PM
Reverse of SACD? Curious DSP 8 06-28-2004 12:52 AM
Altera Stratix 80: How to divide a bits stream to even bits streamand odd bits stream zhao FPGA 1 12-16-2003 06:45 PM


All times are GMT +1. The time now is 01:31 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved