Forum Discussion
Altera_Forum
Honored Contributor
10 years agoi've got the error for the operator ""-"" in the following code. I'm not sure about accessing the indivdual bits of each unsigned in the array.
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use Ieee.numeric_std.all; use work.genetica_type.all; entity binario_fitness is Port ( clk : in std_logic; individuos: in genetica; adaptacao: out fitness; somafitness: out unsigned (7 downto 0) ); end binario_fitness; architecture Behavioral of binario_fitness is begin process (clk) begin If (clk 'event and clk = '1') then for x in 0 to 49 loop adaptacao(x) <= individuos(x)(0)-individuos(x)(1) +individuos(x)(2)- individuos(x)(3)+individuos(x)(4)- individuos(x)(5)+individuos(x)(6)-individuos(x)(7); somafitness<=(others=>'0'); end loop; end if ; end process; end Behavioral; which includes the genetica_type in another file: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_TEXTIO.ALL; use ieee.numeric_std.all; package genetica_type is type genetica is array(0 to 49) of unsigned(7 downto 0); type fitness is array(0 to 49) of unsigned (2 downto 0); end package genetica_type;