Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Error (10818) Can't infer......

Hi all, again.

I'm trying to follow coding guide lines, but i'm failing with this particular PROCESS call. I can't see how to form the process_button1_handler into anything like the Altera Template examples that allow registers to be properly created.:confused:

I realise that the code for process_button1 is very clunky, that will be reworked later.

In addition, does QII have a predefined TRUE and FALSE?

help?


Error (10818): Can't infer register for "button1_go" at keyfob_top.vhd(52) because it does not hold its value outside the clock edge.
Error (10818): Can't infer register for "process_button1_handler:counter" at keyfob_top.vhd(52) because it does not hold its value outside the clock edge
.
.
.

code as follows:


library ieee;
use ieee.std_logic_1164.all; 
entity keyfob_top is
    port
    (
        pin_clk:          in  std_logic;    -- our input clock
        pin_button1:      in  std_logic; -- user button, fires a signal1
        pin_led1_output: out std_logic;    -- user sees that a button has been pushed
        pin_ir_output:      out std_logic    -- IR output signal
    );
end keyfob_top;
architecture led_behaviour of keyfob_top is
    signal baud_tick   : std_logic := '0';  -- baud rate delay
    signal button1_go  : std_logic := '0';    -- start sending button1 press information
    constant button_up : std_logic := '0';    -- button has not been pressed
    constant button_down : std_logic :='1';    -- button has been pressed
    constant led_on  : std_logic := '1';
    constant led_off : std_logic := '0';
    constant true : std_logic := '1';
    constant false : std_logic := '0';
        
begin    
    -- create our baud_rate clock
    process_baud_clock : process(pin_clk, baud_tick)
        variable counter1 : integer range 0 to 100 := 0;
        constant baud_rate : integer := 3;        -- baud rate divider
    begin
        if(rising_edge(pin_clk)) then            -- do we have a new rising edge?
            counter1 := counter1 + 1;            -- incrament the counter
            if(counter1 > baud_rate) then
                counter1 := 0;                    -- reset the counter            
                if(baud_tick = '1') then
                    baud_tick <= '0';            -- toggle state
                else    
                    baud_tick <= '1';            -- toggle state
                end if;
            end if;
        end if;
    end process process_baud_clock;
    
    -- button1 process handler (and debounce)
    process_button1_handler : process(pin_button1, baud_tick)
        variable counter : integer range 0 to 100 := 0;  
        constant delay : integer := 3;
        variable delay_ongoing : std_logic := false;
    begin 
        -- has a button just been pressed
        if(rising_edge(pin_button1)) then    -- (line52)has button just been pressed
            delay_ongoing := true;
            button1_go <= button_down;
        -- this is a baud tick, continue
        elsif((delay_ongoing = true)) then    -- are we counting a delay?
            if(counter = 0) then        -- button has just been pressed, start
                counter := counter + 1;
            elsif(counter = delay)then    -- end of debounce, reset everything
                counter := 0;
                delay_ongoing := false;
                button1_go <= button_up;    
            else                         -- we are in the middle of debounce, continue
                counter := counter + 1;
            end if;
        end if;        
    end process process_button1_handler;
    
  
    -- baud tick handler
    process_button1 : process(baud_tick, button1_go)
        variable button1_bits_left : integer range 0 to 10 := 7;     -- bits left to transmit for button1 press
        variable button1_status : std_logic := '0';
    begin
        if(rising_edge(baud_tick)) then                
            if((button1_bits_left < 7) or              -- we are already servicing it
               (button1_go = button_down and button1_bits_left = 7)) then -- start servicing it
                case button1_bits_left is            -- choose which bit to send out
                    when 7 =>                         -- our first bit
                        pin_ir_output <= led_off;        
                        pin_led1_output <= led_on;        -- show user what is going on
                    when 6 => 
                        pin_ir_output <= led_on;
                    when 5 => 
                        pin_ir_output <= led_off;
                    when 4 => 
                        pin_ir_output <= led_off;
                    when 3 => 
                        pin_ir_output <= led_on;
                    when 2 => 
                        pin_ir_output <= led_off;
                    when 1 => 
                        pin_ir_output <= led_on;
                    when 0 =>                         -- our last bit
                        pin_ir_output <= led_off;
                        pin_led1_output <= led_off;    -- show user what is going on
                        --button1_go_write(button_up);-- signal we have finished with teh button press
                    when others => null;
                end case;
            
                if(button1_bits_left > 0) then
                    button1_bits_left := button1_bits_left - 1; -- decrament by one
                else
                    button1_bits_left := 7;        -- reset our bit counter;
                end if;
            end if;        
        end if;
    end process process_button1;
    
end led_behaviour;

yours, in need of help,

bag it.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Some of your constructs can never work in logic hardwire design, e.g. operating a counter without an edge sensitive condition. (in the second part of process_button1_handler).

    What update rate do you expect for the counter? Where should it come from?

    You can possibly have both ansynchronous and synchronous set for a register value like button1_go. But to be recognized as an asynchronous preset, the condition must take precedence over the synchronous action, but you have reversed the precedence.

    --- Quote Start ---

    In addition, does QII have a predefined TRUE and FALSE?

    --- Quote End ---

    VHDL has it for the boolean data type.