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 save a function result for infinity time?

 
Thread Tools Search this Thread
Old 09-08-2005, 07:42 AM   #1
Default How do you save a function result for infinity time?


Hi,

Suppose I have this code:
---------------------------------------
Function func_rt(
a : std_logic_vector(7 downto 0);
b : std_logic_vector(7 downto 0);
c : integer) return std_logic is
variable res : std_logic;
begin
res := a(c) and b(c)
return res;
end func_rt;
------------------------------------
----- main
..
..
Port( clock : in std_logic;
Rm : out std_logic)
..
..

Constant k1 : std_logic_vector(7 downto 0) := "10111010";
Constant k2 : std_logic_vector(7 downto 0) := "01111101";
..
..
Signal g : std_logic_vector(7 downto 0) : k1;
Signal f : std_logic_vector(7 downto 0) : k2;
Signal result : std_logic;
Signal ready : std_logic := '0';

Begin
Process(clock)
Begin
If(clock'event and clock = '1') then
If(Ready ='0') then
Result <= func_rt(g, f, 3);
Ready <= '1';
Else
Rm <= Result;
End if;
End process;
End program_behav;

-----------------------------
The problem when I run the program the upper code in the simulator can
give the result of signal 'Rm' = '1' very good. But when I use the
Quartus II syntheses tool to synthesize on the cyclone FPGA and I
assign the 'Rm' to the result the specific led gives nothing.
I think my problem that the next cycle of the process 'Result signal'
will be assigned to nothing, the Rm <= Result will get 'U' or 'Zero'.
Or anything.
The question is there any way to save the result of line:
Result <= func_rt(g, f, 3);
For infinity time, so I can use the Result Signal with newest value
anytime when the Ready signal became '1' .



a_Conan
  Reply With Quote
Old 09-08-2005, 08:00 AM   #2
ajahn
 
Posts: n/a
Default Re: How do you save a function result for infinity time?
Well....usually default values for signals are not allowed for
synthesis. What you should do is add a reset to your process and let
the ready register reset to 0.
I would also use the rm signal directly as a register, if its not a
timing critical thing (you absolutely need the Rm signal to be one
clock delayed from the Result signal).
So for a LED-control I would write something like

P_LED_ctrl: PROCESS (clock, reset)
BEGIN -- PROCESS P_LED_ctrl
IF reset = '1' THEN --
asynchronous reset (active high)
ready <= '0';
Rm <= '0';
ELSIF clock'event AND clock = '1' THEN -- rising
clock edge
IF ready = '0' THEN
Rm <= func_rt(g, f, 3);
ready <= '1';
END IF;
END IF;
END PROCESS P_LED_ctrl;

I hope that helps...
Cheers,
Andreas.



ajahn
  Reply With Quote
Old 09-08-2005, 04:39 PM   #3
Duane Clark
 
Posts: n/a
Default Re: How do you save a function result for infinity time?
a_Conan wrote:
> Hi,
>
> Suppose I have this code:
> ---------------------------------------
> Function func_rt(
> a : std_logic_vector(7 downto 0);
> b : std_logic_vector(7 downto 0);
> c : integer) return std_logic is
> variable res : std_logic;
> begin
> res := a(c) and b(c)
> return res;
> end func_rt;
> ------------------------------------
> ----- main
> .
> .
> Port( clock : in std_logic;
> Rm : out std_logic)
> .
> .
>
> Constant k1 : std_logic_vector(7 downto 0) := "10111010";
> Constant k2 : std_logic_vector(7 downto 0) := "01111101";
> .
> .
> Signal g : std_logic_vector(7 downto 0) : k1;
> Signal f : std_logic_vector(7 downto 0) : k2;
> Signal result : std_logic;
> Signal ready : std_logic := '0';
>
> Begin
> Process(clock)
> Begin
> If(clock'event and clock = '1') then
> If(Ready ='0') then
> Result <= func_rt(g, f, 3);
> Ready <= '1';
> Else
> Rm <= Result;
> End if;
> End process;
> End program_behav;
>


I am not familiar with Quartus FPGAs, so maybe this is not an issue. But
with most FPGAs, a big problem I can see here is that you need to think
about what happens when the FPGA powers up. Most FPGAs do not come out
of reset cleanly; that is, even Xilinx FPGAs have an asynchronous reset
on power up.

In your code, on coming out of reset, both Result and Ready are set on
the very first clock, and they are interdependent. That is likely to not
work right. Of course, if you don't care what the signals do at power
up, then this becomes a non issue. But that is one area where the
hardware may not be behaving like the simulation.


Duane Clark
  Reply With Quote
Old 09-08-2005, 08:37 PM   #4
a_Conan
 
Posts: n/a
Default Re: How do you save a function result for infinity time?
Thank you : ) it works



a_Conan
  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
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 PM
This is incredible! jc_ice DVD Video 1 08-13-2006 10:47 AM
fwd: Copyright law caught in its own time warp Netmask DVD Video 3 07-23-2006 02:40 AM
As growth slows, Hollywood faces a DVD standoff. Allan DVD Video 0 07-11-2005 02:10 PM
NEWS RELEASE: Leone's "Nobody" Films 1st time mastered in HD for DVD release with 240 Minutes Extras Torsten Kaiser \(TLEFilms\) DVD Video 1 06-06-2005 04:17 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