Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - How to generate a pyramid of shift registers..?

 
Thread Tools Search this Thread
Old 01-17-2005, 03:50 PM   #1
Default How to generate a pyramid of shift registers..?


Hi all,
My problem is as follows - i need to create the following pyramid alike
design.
in my declarative part i need to declare the following signals :


signal reg1 : std_logic ;
signal reg2 :std_logic_vector (1 downto 0);
signal reg3 :std_logic_vector (2 downto 0);
...
...
signal regN :std_logic_vector (N-2 downto 0);

afterwards I need to connect them as follows :


if rising_edge (clk) then

reg1 <= in1;
reg2(0) <= in2;
reg3(0) <= in3;
....
regN(0) <= inN;

reg2 (1) <= reg2 (0);
reg3 (2 downto 1) <= reg2 (1 downto 0);
....
....
regN (N-1 downto 1) <= reg2 (N-2 downto 0);

end if;

-- outputs --
out1 <= reg1;
out2 <= reg2 (1);
out3 <= reg3 (2);
....
....
outN <= regN (N-1);


It seems to be a job for a "generate loop" but I dont know how can I
declare N signals...?

I will appreciate any help.
Thanks, Moti.



moti@terasync.net
  Reply With Quote
Old 01-17-2005, 06:48 PM   #2
Pieter Hulshoff
 
Posts: n/a
Default Re: How to generate a pyramid of shift registers..?
wrote:
> It seems to be a job for a "generate loop" but I dont know how can I
> declare N signals...?


Why not use a 2 dimensional array of Nx(N-1), and let the compiler toss out
all the un-used registers?

Regards,

Pieter Hulshoff



Pieter Hulshoff
  Reply With Quote
Old 01-18-2005, 06:18 AM   #3
zingafriend@yahoo.com
 
Posts: n/a
Default Re: How to generate a pyramid of shift registers..?
I think this: reg2 (1) <= reg2 (0); must have been reg2(1) <= reg1; If
this is the logic you need, then the ouput is only the msb's of each of
the registers, but then each registers msb gets the previous registers
msb. that being the case then your output after the pipeline is filled
will be nothing other than delayed values of the in1 bits only. But for
that you just need a n bit shift register, not a pyramid of register as
you mention.

-Neo



zingafriend@yahoo.com
  Reply With Quote
Old 01-18-2005, 09:06 AM   #4
moti@terasync.net
 
Posts: n/a
Default Re: How to generate a pyramid of shift registers..?

> Pieter Hulshoff wrote:


> Why not use a 2 dimensional array of Nx(N-1), and let the compiler

toss out
> all the un-used registers?
>
> Pieter Hulshoff


It seems like a good idea - I was just looking for some more elegant
solution like a special generate for it to be more readable..
But it looks like I have no choise.

Thanks, Moti.



moti@terasync.net
  Reply With Quote
Old 01-18-2005, 02:08 PM   #5
Egbert Molenkamp
 
Posts: n/a
Default Re: How to generate a pyramid of shift registers..?

<> wrote in message
news: ups.com...
>
> > Pieter Hulshoff wrote:

>
> > Why not use a 2 dimensional array of Nx(N-1), and let the compiler

> toss out
> > all the un-used registers?
> >
> > Pieter Hulshoff

>
> It seems like a good idea - I was just looking for some more elegant
> solution like a special generate for it to be more readable..
> But it looks like I have no choise.
>
> Thanks, Moti.

You have a choice. You can generate the length of the array IN a generate
statement.
See example beneath. The extra process with label FIRST is needed since my
synthesis tool does not like
"-1 downto 0" when I change the generate stament in:
pyramid_structure: for i in N-1 downto 0 generate

Egbert Molenkamp


library ieee;
use ieee.std_logic_1164.all;
entity pyramid is
generic (n : positive := 3);
port (a : in std_logic_vector(n-1 downto 0);
clk : in std_logic;
b : out std_logic_vector(n-1 downto 0));
end pyramid;

architecture structure of pyramid is
begin
pyramid_structure: for i in N-1 downto 1 generate
process(clk)
variable pyr : std_logic_vector(i downto 0);
begin
if rising_edge(clk) then
pyr(i downto 0) := pyr(i-1 downto 0) & a(i);
b(i)<= pyr(i);
end if;
end process;
end generate;

firstrocess(clk) -- needed because synthesis does not like "-1 downto
0".
begin
if rising_edge(clk) then
b(0)<=a(0);
end if;
end process;

end structure;




Egbert Molenkamp
  Reply With Quote
Old 01-19-2005, 05:16 PM   #6
moti@terasync.net
 
Posts: n/a
Default Re: How to generate a pyramid of shift registers..?
Hi Egbert,
Thanks for the example.
I never used a "rising_edge process" inside of a generate statement -
I will check it out..

Regards, Moti



moti@terasync.net
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate .aspx file and .cs file behind it jyoti.bannigidad@gmail.co Software 0 09-18-2008 07:54 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46