More toggles than expected.

Guest #5535185
Rate this post
• ▲ useful
▼ not useful
I have a process in my VHDL code that I want to advance a counter on a 
rising edge if an input(GPIO_READDATA(6) an encoder output much slower 
than 50 MHz. All entities are std_logic. cntr[32] and READ_DATA[7]are 
vectors.

My code is as follows:

  Catch_Rising_Edge: process(CLK)
  begin

  if rising_edge(CLK) then -- 50MHz clk
    r0_input <= GPIO_READDATA(6); --reading GPIO_READDATA(6)
    r1_input <= r0_input;
    ENC(1) <= GPIO_READDATA(6); -- ENC(1) drives a single LED

    if  (r1_input <= '0') and (r0_input <= '1')then
      cntr <= cntr+ 1; -- cntr(22 downto 15) drives a string of 8 LEDs

    end if;
  end if;

  end process;
My understanding is on a rising CLK, the first 4 lines occur 
simultaneously. The 5th line being a condition of the 4th also should 
occur simultaneously.
On the rising edge transition of GPIO_READDATA(6), r0 goes to '1' and r1 
stays at '0' because it reads r1 before r0 transitions. In the start of 
the next CLK cycle, r0 = '1' and r1 = '0' so the cntr advances.
However, that is not what is happening. When ENC(1) is low, cntr(22) is 
flashing at about 1 Hz making my cntr count at 50MHz. When ENC(1) is 
high, cntr stops. I am trying to understand ModelSim to further solve 
the issue. Please help me find the error in my code.

Thank you
Guest #5535369
Rate this post
• ▲ useful
▼ not useful
I just tried that and it I cannot get it to work.
Catch_Rising_Edge: process(CLK, GPIO_READDATA(6))
  begin

  if rising_edge(CLK) then
    if rising_edge(GPIO_READDATA(6)) then
      cntr <= cntr+ 1;
      ENC(1) <= GPIO_READDATA(6);
    end if;
  end if;

  end process;
I get ... can't infer register for "cntr[1]" because its behavior does 
not match any supported register model

I also get 21 other similar errors.
I am a novice and was told to only implicitly trigger on a clock edge. 
What am I missing?
Moderator (Company: Titel) #5536295
Rate this post
• ▲ useful
▼ not useful
bob wrote:
1
if rising_edge(CLK) then
2
  if rising_edge(GPIO_READDATA(6)) then
3
    cntr <= cntr+ 1;
4
  end if;
5
end if;
> I get ... can't infer register for "cntr[1]" because its behavior does
> not match any supported register model
Just to clarify the issues here:
Of course this code is not synthesizeable, because
1. it requires the cntr to be built with never seen "dual clock input 
flipflops" and
2. in real life there are no edges at the very same time as this code 
demands...

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.