Altera_Forum
Honored Contributor
12 years agoImplementing User-Defined "Wait For" time
Disclaimer: I'm a noob
I'm trying to implement an entity which takes as an input a 16-bit binary number called bounceWidth( in std_ulogic_vector(15 downto 0)) which will represent the time in which a pulse wave will last. In my behavioral architecture, I have a variable called intWidth ( in std_ulogic_vector(15 downto 0)) and another one called pulseWidth ( time ). My desire is to convert the input into a valid form of time expressed in ns so as to be used with the "wait for" command. Below is what I'm doing that Quartus doesn't like: --- Quote Start --- library ieee; use ieee.numeric_std.all; use ieee.std_logic_1164.all; entity bounce_processor is generic (prop_delay: Time:= 10ns); port (clock: in std_logic; bouncewidth: in std_ulogic_vector(15 downto 0);bounceCount: in std_ulogic_vector(7 downto 0); opcode: in std_ulogic_vector(2 downto 0); start: in bit; output: out bit); end bounce_processor; architecture behavioral of bounce_processor is variable intwidth : integer range 0 to 65535;
variable intCount : natural range 0 to 10; variable starting_output : bit; variable pulsewidth : time;
begin process(clock) begin if (rising_edge(clock) and start = '1') then intwidth := to_integer(bouncewidth);
pulsewidth := time(intwidth);
intCount := to_integer(bounceCount); starting_output := output; if opcode = "000" then output <= '0'; elsif opcode = "001" then for i in 0 to intCount loop output <= not output; wait for pulsewidth ns;
end loop; if starting_output = '1' then output <= 0; else output <= 1; end if; elsif opcode = "010" then output <= '1'; elsif opcode = "011" then output <= '0'; end if; end if; end process; end behavioral; --- Quote End --- Any help would be greatly appreciated.