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

Reply

VHDL - if/elsif problem

 
Thread Tools Search this Thread
Old 04-16-2007, 03:07 PM   #1
Default if/elsif problem


Hello, I have a problem with the following construct:

process(clk, reset_n)
begin
if (reset_n = '0') then
out <= '0';
elsif (clk'event and clk = '1') then
if (clear = '1') then
out <= '0';
elsif (set = '1') then
out <= '1';
end if;
end if;
end process;

I have synthesized this for a xilinx. Although the signal "set" is observed to be completely fixed at '0' (in logic analyzer), I get a transition from 0 to 1 on "out". Could it be a glitch on "set" ? Is this a problematic construction for some reason?


karlwijk
karlwijk is offline   Reply With Quote
Old 04-17-2007, 05:22 AM   #2
quantum_dot
Member
 
Join Date: Nov 2006
Posts: 32
Default if/elsif statement !
Well, this coding is similar to C programming, and may create a problem in actual hardware. You have not specified all the possible conditions for set/clear. May be you can give this a try :

process(clk, reset_n)
begin
if (reset_n = '0') then
out <= '0';
elsif (clk'event and clk = '1') then
if (clear = '1' and set = '0') then
out <= '0';
elsif (clear = '0' and set = '1') then
out <= '1';
end if;
end if;
end process;


quantum_dot
quantum_dot is offline   Reply With Quote
Old 04-17-2007, 06:17 AM   #3
karlwijk
Junior Member
 
Join Date: Apr 2007
Posts: 2
Default
Hi, thanks. Can you explain why my solution creates a problem? Under what signal conditions? Is it, for instance, if you get clear='1' and set='1' at the same time?

Kind regards,
Karl

Quote:
Originally Posted by quantum_dot
Well, this coding is similar to C programming, and may create a problem in actual hardware. You have not specified all the possible conditions for set/clear. May be you can give this a try :

process(clk, reset_n)
begin
if (reset_n = '0') then
out <= '0';
elsif (clk'event and clk = '1') then
if (clear = '1' and set = '0') then
out <= '0';
elsif (clear = '0' and set = '1') then
out <= '1';
end if;
end if;
end process;


karlwijk
karlwijk is offline   Reply With Quote
Old 04-18-2007, 06:52 AM   #4
quantum_dot
Member
 
Join Date: Nov 2006
Posts: 32
Default if/elsif problem
Not specifying all the conditions for "clear" or "set" results in a latch condition, which you are not aiming for. This may result in a unpredicted metastable state, which is causing the problem.


quantum_dot
quantum_dot is offline   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
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Pioneer DVR3100S problem with Satellite receiver Samsung DCR 9500 Fredrik Bengtsson DVD Video 0 12-12-2003 02:32 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 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