![]() |
|
|
|||||||
![]() |
VHDL - How do you save a function result for infinity time? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
Thank you : ) it works
a_Conan |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |