Guest
I have the following code:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY ECROSSOVER IS
PORT (
CLK : IN bit := '0';
dad, mom : IN STD_ULOGIC_VECTOR(31 DOWNTO 0); -- 31 should be a
constant
son : OUT STD_ULOGIC_VECTOR(31 DOWNTO 0); -- 31 should be a constant
crosspoint : OUT STD_ULOGIC_VECTOR(7 DOWNTO 0)
);
END ECROSSOVER;
ARCHITECTURE ACROSSOVER OF ECROSSOVER IS
BEGIN
CROSS : PROCESS (CLK)
BEGIN
FOR1:
FOR i IN 0 TO 16 LOOP -- 16 should be crosspoint parameter
son(i) <= dad(i);
END LOOP FOR1;
FOR2:
FOR i IN 16 TO 31 LOOP -- 31 should be the same constant as in the
entity
son(i) <= mom(i);
END LOOP FOR2;
END PROCESS CROSS;
END ACROSSOVER;
My problem: I have to build a unit to do a crossover of two chromosome
and a crossover point, I did use fixed values in the declarations but I
should use constants, but I get compiler error when doing that. My idea
is to use 2 for loops copy the first part of one chromosome and
complete the rest of my new chromosome with the rest of the second
chromosome, like this:
father: 11110000
mother: 00001111
crosspoint : 4 (decimal value)
The result must be: 11111111
But I can't use signal or a variable in the for loop, is there any
other way to do this? or to correct my problem?
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY ECROSSOVER IS
PORT (
CLK : IN bit := '0';
dad, mom : IN STD_ULOGIC_VECTOR(31 DOWNTO 0); -- 31 should be a
constant
son : OUT STD_ULOGIC_VECTOR(31 DOWNTO 0); -- 31 should be a constant
crosspoint : OUT STD_ULOGIC_VECTOR(7 DOWNTO 0)
);
END ECROSSOVER;
ARCHITECTURE ACROSSOVER OF ECROSSOVER IS
BEGIN
CROSS : PROCESS (CLK)
BEGIN
FOR1:
FOR i IN 0 TO 16 LOOP -- 16 should be crosspoint parameter
son(i) <= dad(i);
END LOOP FOR1;
FOR2:
FOR i IN 16 TO 31 LOOP -- 31 should be the same constant as in the
entity
son(i) <= mom(i);
END LOOP FOR2;
END PROCESS CROSS;
END ACROSSOVER;
My problem: I have to build a unit to do a crossover of two chromosome
and a crossover point, I did use fixed values in the declarations but I
should use constants, but I get compiler error when doing that. My idea
is to use 2 for loops copy the first part of one chromosome and
complete the rest of my new chromosome with the rest of the second
chromosome, like this:
father: 11110000
mother: 00001111
crosspoint : 4 (decimal value)
The result must be: 11111111
But I can't use signal or a variable in the for loop, is there any
other way to do this? or to correct my problem?