Search code examples
integertype-conversionvhdl

std_logic to integer conversion


I would like to convert my sys-clock (std_logic) to an integer value (sys_clk). Therefore I am using following libs:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

-- code example 
sys_clk         : INTEGER;
clk_clk         : in  std_logic;

how can I convert the clk_clk to my sys_clk?

Thanks


Solution

  • Assuming conversion from std_logic as '0' and '1' to integer as 0 and 1, you can make concurrent statements like:

    sys_clk <= 1 when (clk_clk = '1') else 0;
    

    or

    sys_clk <= to_integer(unsigned'('0' & clk_clk));
    

    Besides, there are some syntax errors in the declarations.