Altera_Forum
Honored Contributor
13 years agoconver froms td_logic_vector to integer
hai every one i'm new to vhdl code and i got problem how to use decimal value instead of binary
for example right_m<="1010001010"; left_m <="1011101110"; i want to convert it to right_m<=650 left_m <=750 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity adel is Port ( clock,rest : in STD_LOGIC; input : in STD_LOGIC_VECTOR (4 downto 0); left_p : out std_logic; right_p : out std_logic); end adel; architecture Behavioral of adel is type state is (forward,right60,left60); signal pr_state,nx_state : state; signal counter : std_logic_vector(9 downto 0) ; signal left_m : std_logic_vector(9 downto 0) ; signal right_m : std_logic_vector(9 downto 0) ; begin process(clock,rest) begin if(rest='1' ) then counter<="0000000000"; right_p <= '0'; left_p<= '0'; elsif (rising_edge (clock))then if(counter=800) then counter<="0000000000"; else counter<=counter+'1'; if(counter<right_m) then right_p<='1'; else right_p<='0'; end if; if(counter<left_m) then left_p<='1'; else left_p<='0'; end if; end if; end if; end process process(clock,rest) begin if(rest = '1')then pr_state <= forward; elsif(clock'event and clock ='1')then pr_state <= nx_state; end if; end process; process(pr_state,sensor_input) begin case pr_state is ----------------------forward---------------------------- when forward => if(input = "11000")then nx_state <= right60; right_m<= "1010001010"; left_m <= "1011101110";