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

Reply

VHDL - how do you code this?

 
Thread Tools Search this Thread
Old 01-26-2007, 07:13 AM   #1
Default how do you code this?



There is a 20 bit counter,with two inputs ,on the rising edge of one
input the counter must increment and on the rising edge of the other
input the counter must decrement.
this is for a 1MB FIFO buffer using single port external SRAM,I'm using
Xilinx ISE tool.according to the xilinx tool you cannot have two
(rising_edge()) statements in a single process.

How do you code it?



aravind
  Reply With Quote
Old 01-26-2007, 11:35 AM   #2
reba256@hotmail.com
 
Posts: n/a
Default Re: how do you code this?

aravind skrev:

> There is a 20 bit counter,with two inputs ,on the rising edge of one
> input the counter must increment and on the rising edge of the other
> input the counter must decrement.
> this is for a 1MB FIFO buffer using single port external SRAM,I'm using
> Xilinx ISE tool.according to the xilinx tool you cannot have two
> (rising_edge()) statements in a single process.
>
> How do you code it?


Make two process, one for the increment and one for decrement.



reba256@hotmail.com
  Reply With Quote
Old 01-26-2007, 12:35 PM   #3
Zara
 
Posts: n/a
Default Re: how do you code this?
On 25 Jan 2007 23:13:41 -0800, "aravind" <> wrote:

>
>There is a 20 bit counter,with two inputs ,on the rising edge of one
>input the counter must increment and on the rising edge of the other
>input the counter must decrement.
>this is for a 1MB FIFO buffer using single port external SRAM,I'm using
>Xilinx ISE tool.according to the xilinx tool you cannot have two
>(rising_edge()) statements in a single process.
>
>How do you code it?



I f you have a clock available faster than the control inputs, you may
generate with it one pulse on rising_edge of one control signal,
another pulse for the other control signal, and use them as clock
enables for the fast clock

Best regards,

Zara


Zara
  Reply With Quote
Old 01-26-2007, 01:21 PM   #4
aravind
 
Posts: n/a
Default Re: how do you code this?


On Jan 26, 5:35 pm, Zara <me_z...@dea.spamcon.org> wrote:
> On 25 Jan 2007 23:13:41 -0800, "aravind" <aramos...@gmail.com> wrote:
>
>
>
> >There is a 20 bit counter,with two inputs ,on the rising edge of one
> >input the counter must increment and on the rising edge of the other
> >input the counter must decrement.
> >this is for a 1MB FIFO buffer using single port external SRAM,I'm using
> >Xilinx ISE tool.according to the xilinx tool you cannot have two
> >(rising_edge()) statements in a single process.

>
> >How do you code it?I f you have a clock available faster than the control inputs, you may

> generate with it one pulse on rising_edge of one control signal,
> another pulse for the other control signal, and use them as clock
> enables for the fast clock
>
> Best regards,
>
> Zara


thanks
I believe you are suggesting a gated clock,But a gated clock is not a
recommended design practice(i think).



aravind
  Reply With Quote
Old 01-26-2007, 02:01 PM   #5
Ben Jones
 
Posts: n/a
Default Re: how do you code this?

"aravind" <> wrote in message
news: oups.com...
> On Jan 26, 5:35 pm, Zara <me_z...@dea.spamcon.org> wrote:
>> On 25 Jan 2007 23:13:41 -0800, "aravind" <aramos...@gmail.com> wrote:
>> >There is a 20 bit counter,with two inputs ,on the rising edge of one
>> >input the counter must increment and on the rising edge of the other
>> >input the counter must decrement.


>> If you have a clock available faster than the control inputs, you may
>> generate with it one pulse on rising_edge of one control signal,
>> another pulse for the other control signal, and use them as clock
>> enables for the fast clock


> I believe you are suggesting a gated clock,But a gated clock is not a
> recommended design practice(i think).


No, what is being described is a single synchronous circuit which runs in a
clock domain that is fast enough to re-synchronize and sample the "rising
edges" you described, generating synchronous pulses to increment and
decrement the counter. This, if possible, is the cleanest solution to your
problem.

-Ben-




Ben Jones
  Reply With Quote
Old 01-26-2007, 02:49 PM   #6
Wolfgang Grafen
 
Posts: n/a
Default Re: how do you code this?
aravind wrote:
> There is a 20 bit counter,with two inputs ,on the rising edge of one
> input the counter must increment and on the rising edge of the other
> input the counter must decrement.
> this is for a 1MB FIFO buffer using single port external SRAM,I'm using
> Xilinx ISE tool.according to the xilinx tool you cannot have two
> (rising_edge()) statements in a single process.
>
> How do you code it?
>

Two ideas


Idea a:
=======
1. Assure both inputs are synchronised to the counter's clock

2. If you have to synchronise your inputs choose the counter's clock frequency
according to following formula:
fcnt > 1/(2 * (min(thmin(i1), tlmin(i2)), min(thmin(i2), tlmin(i2)))
with
i1 and i2: designating the two inputs
thmin: minimum high time
tlmin: minimum low time

3. The counter's code:

signal cnt20 : unsigned(19 downto 0);
signal i1, i2 : std_ulogic; -- inputs 1, 2
signal i1_old, i2_old : std_ulogic -- differentiated inputs 1, 2

p_cnt20 : process (clk,reset)
begin
if reset = ActiveResetLevel then
cnt20 <= (others => '0');
i1_old <= '1';
i2_old <= '1';

elsif (clk'event and clk = '1') then
if i1_old = '0' and i1 = '1' and -- rising edge of i1
i2_old = '0' and i2 = '1' then -- rising edge of i2
NULL;

elsif i1_old = '0' and i1 = '1' then -- rising edge of i1
cnt20 <= cnt20 + 1;

elsif i2_old = '0' and i2 = '1' then -- rising edge of i2
cnt20 <= cnt20 - 1;

end if;
end if;
end process;

Idea b:
=======
1. use one 20 bit counter for each clock domain and
(1a. eventually encode with Gray code for only one bit changes)
2. synchronise both counter outputs for the result clock domain
(2a. decode the Gray encoded counter values if Gray encoded)
3. substract one result from the other for the SRAM address.

Cheers

Wolfgang





Wolfgang Grafen
  Reply With Quote
Old 01-26-2007, 02:56 PM   #7
Wolfgang Grafen
 
Posts: n/a
Default Re: how do you code this?
Upps,

code unverified but just realised I forgot to assign i1_old and i2_old

Wolfgang Grafen wrote:
> aravind wrote:
>> There is a 20 bit counter,with two inputs ,on the rising edge of one
>> input the counter must increment and on the rising edge of the other
>> input the counter must decrement.
>> this is for a 1MB FIFO buffer using single port external SRAM,I'm using
>> Xilinx ISE tool.according to the xilinx tool you cannot have two
>> (rising_edge()) statements in a single process.
>>
>> How do you code it?
>>

> Two ideas
>
>
> Idea a:
> =======
> 1. Assure both inputs are synchronised to the counter's clock
>
> 2. If you have to synchronise your inputs choose the counter's clock
> frequency
> according to following formula:
> fcnt > 1/(2 * (min(thmin(i1), tlmin(i2)), min(thmin(i2), tlmin(i2)))
> with
> i1 and i2: designating the two inputs
> thmin: minimum high time
> tlmin: minimum low time
>
> 3. The counter's code:
>
> signal cnt20 : unsigned(19 downto 0);
> signal i1, i2 : std_ulogic; -- inputs 1, 2
> signal i1_old, i2_old : std_ulogic -- differentiated inputs 1, 2
>
> p_cnt20 : process (clk,reset)
> begin
> if reset = ActiveResetLevel then
> cnt20 <= (others => '0');
> i1_old <= '1';
> i2_old <= '1';
>
> elsif (clk'event and clk = '1') then

i1_old <= i1;
i2_old <= i2;
> if i1_old = '0' and i1 = '1' and -- rising edge of i1
> i2_old = '0' and i2 = '1' then -- rising edge of i2
> NULL;
>
> elsif i1_old = '0' and i1 = '1' then -- rising edge of i1
> cnt20 <= cnt20 + 1;
>
> elsif i2_old = '0' and i2 = '1' then -- rising edge of i2
> cnt20 <= cnt20 - 1;
>
> end if;
> end if;
> end process;
>
> Idea b:
> =======
> 1. use one 20 bit counter for each clock domain and
> (1a. eventually encode with Gray code for only one bit changes)
> 2. synchronise both counter outputs for the result clock domain
> (2a. decode the Gray encoded counter values if Gray encoded)
> 3. substract one result from the other for the SRAM address.
>
> Cheers
>
> Wolfgang
>
>
>



Wolfgang Grafen
  Reply With Quote
Old 01-27-2007, 06:38 PM   #8
Andy
 
Posts: n/a
Default Re: how do you code this?
Xilinx has a very good app note on designing a synchronous, two clock
fifo with BRAM. It wouldn't be hard to adapt it to external sram. I
don't recall the appnote number. It is based along the lines of
Wofgang's idea B, but you do not subtract one counter from the other
for the SRAM address, you do that to figure out full/empty/neither
(some extra logic is required to tell full from empty). The counter
being incrmented on the write clock is the address for writing. The
counter incremented on the read clock is the address for reading.

Andy

On Jan 26, 8:56 am, Wolfgang Grafen <wolfgang.gra...@marconi.com>
wrote:
> Upps,
>
> code unverified but just realised I forgot to assign i1_old and i2_old
>
>
>
> Wolfgang Grafen wrote:
> > aravind wrote:
> >> There is a 20 bit counter,with two inputs ,on the rising edge of one
> >> input the counter must increment and on the rising edge of the other
> >> input the counter must decrement.
> >> this is for a 1MB FIFO buffer using single port external SRAM,I'm using
> >> Xilinx ISE tool.according to the xilinx tool you cannot have two
> >> (rising_edge()) statements in a single process.

>
> >> How do you code it?

>
> > Two ideas

>
> > Idea a:
> > =======
> > 1. Assure both inputs are synchronised to the counter's clock

>
> > 2. If you have to synchronise your inputs choose the counter's clock
> > frequency
> > according to following formula:
> > fcnt > 1/(2 * (min(thmin(i1), tlmin(i2)), min(thmin(i2), tlmin(i2)))
> > with
> > i1 and i2: designating the two inputs
> > thmin: minimum high time
> > tlmin: minimum low time

>
> > 3. The counter's code:

>
> > signal cnt20 : unsigned(19 downto 0);
> > signal i1, i2 : std_ulogic; -- inputs 1, 2
> > signal i1_old, i2_old : std_ulogic -- differentiated inputs 1, 2

>
> > p_cnt20 : process (clk,reset)
> > begin
> > if reset = ActiveResetLevel then
> > cnt20 <= (others => '0');
> > i1_old <= '1';
> > i2_old <= '1';

>
> > elsif (clk'event and clk = '1') then i1_old <= i1;

> i2_old <= i2;
>
> > if i1_old = '0' and i1 = '1' and -- rising edge of i1
> > i2_old = '0' and i2 = '1' then -- rising edge of i2
> > NULL;

>
> > elsif i1_old = '0' and i1 = '1' then -- rising edge of i1
> > cnt20 <= cnt20 + 1;

>
> > elsif i2_old = '0' and i2 = '1' then -- rising edge of i2
> > cnt20 <= cnt20 - 1;

>
> > end if;
> > end if;
> > end process;

>
> > Idea b:
> > =======
> > 1. use one 20 bit counter for each clock domain and
> > (1a. eventually encode with Gray code for only one bit changes)
> > 2. synchronise both counter outputs for the result clock domain
> > (2a. decode the Gray encoded counter values if Gray encoded)
> > 3. substract one result from the other for the SRAM address.

>
> > Cheers

>
> > Wolfgang




Andy
  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
How To Access HTML elements in code behind??? nedums_b Software 1 02-07-2008 07:15 PM
Circumvent Region Code hufaunder@yahoo.com DVD Video 11 01-29-2007 09:51 PM
Deep Discount DVD 20% Off Super Sale: Additional Code Words? Jaime M. de Castellvi DVD Video 4 11-11-2006 02:53 PM
.avi files giving region code error Craig Cameron DVD Video 2 03-07-2006 02:49 PM
Change region code and PAL to NTSC? Aloke Prasad DVD Video 0 02-26-2004 01:54 PM




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