Electrical – STD_LOGIC_VECTOR to INTEGER VHDL

vhdl

The problem is to find a modulo when a three digit number is divided by its last two digits. But the three digit number is received in a binary form. So I first want to change the binary form into integer form then use the mod operator.

code

Best Answer

Why do you paste your code as an image?! This makes it harder for us to help you. Please don't do that next time.

The answer is given by TEMLIB. You have two options:

1) Make a triggered process, with the internal value as variables.

begin
    process(divident)
        variable divident_int : integer;
        variable modulo_1_int : integer;
        variable modulo_int : integer;
    begin
        divident_int := to_integer(unsigned(divident));
        modulo_1_int := divident_int mod divis_1;
        modulo_int := divident_int mod modulo_1_int;
        modulo <= std_logic_vector(to_unsigned(modulo_int, modulo'length));
    end process;
end architecture;

2) leave out the process (and keep the signals)

begin
    divident_int <= to_integer(unsigned(divident));
    modulo_1 <= divident_int mod divis_1;
    modulo_int <= divident_int mod modulo_1;
    modulo <= std_logic_vector(to_unsigned(modulo_int, modulo'length));
end architecture;