- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
This code is a simplification of the actual code. clk is a 50Mhz clock signal, busy is an of chip signal coming from one of the pins. (GPIO on the DE2-115 developing board) busy_i is an internal signal and n is just a signal used to count clock periodes. process(clk) begin busy_i <= busy; n <= n + 1; if((busy_i = '1') and (busy = '0')) then state <= s_RD; elsif(n = 1500) then state <= s_RD; end if; end process; This code wil not always detect the falling edge on busy(the difference in busy_i and busy). That is also why i included the elsif statment, so that after a given count of clock periodes the state signal vil be forced the value of s_RD. So my question is: Is this some bad coding from me, or could it be somthing with the fact that busy is an of chip signal - maybe a combination of the two? Realy appreciate some thoughts! Maybe someone have hade a similar issue? Thanks! -electrosmithLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You forget the rising_edge(clk) !!
process(clk)
begin
if rising_edge(clk) then
busy_i <= busy;
n <= n + 1;
if((busy_i = '1') and (busy = '0')) then
state <= s_RD;
elsif(n = 1500) then
state <= s_RD;
end if;
end if;
end process;
Moreover, insert at least 2 D flip fop on your "busy" signal to prevent metastability
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
heh:P yes the missing rising_edge() is just a typo, its not missing in the actual code:) But thanks for the heads-up about metastability, wil add a couble of DFF's to my signal and see if it helps;)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page