Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > if/elsif problem

Reply
Thread Tools

if/elsif problem

 
 
karlwijk karlwijk is offline
Junior Member
Join Date: Apr 2007
Posts: 2
 
      04-16-2007
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?
 
Reply With Quote
 
 
 
 
quantum_dot quantum_dot is offline
Member
Join Date: Nov 2006
Posts: 32
 
      04-17-2007
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;
 
Reply With Quote
 
 
 
 
karlwijk karlwijk is offline
Junior Member
Join Date: Apr 2007
Posts: 2
 
      04-17-2007
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;
 
Reply With Quote
 
quantum_dot quantum_dot is offline
Member
Join Date: Nov 2006
Posts: 32
 
      04-18-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments