J'ai un signal et ce signal est un bitvector (Z). La longueur du bitvector dépend d'une entrée n, elle n'est pas fixe. Pour trouver la longueur, je dois faire quelques calculs. Puis-je définir un signal après avoir défini les variables? Cela me donne des erreurs quand je fais ça. Cela fonctionne bien Si je garde le signal avant les variables (ce qui est montré ci-dessous) .. mais je ne le veux pas .. la longueur de Z dépend des calculs des variables. Quelle est la solution ?Signaux et variables en VHDL (ordre) - Problème
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BSD_Full_Comp is
Generic (n:integer:=8);
Port(X, Y : inout std_logic_vector(n-1 downto 0);
FZ : out std_logic_vector(1 downto 0));
end BSD_Full_Comp;
architecture struct of BSD_Full_Comp is
Component BSD_BitComparator
Port (Ai_1 : inout STD_LOGIC; Ai_0 : inout STD_LOGIC;
Bi_1 : inout STD_LOGIC; Bi_0 : inout STD_LOGIC;
S1 : out STD_LOGIC; S0 : out STD_LOGIC
);
END Component;
Signal Z : std_logic_vector(2*n-3 downto 0);
begin
ass : process
Variable length : integer := n;
Variable pow : integer :=0 ;
Variable ZS : integer :=0;
begin
while length /= 0 loop
length := length/2;
pow := pow+1;
end loop;
length := 2 ** pow;
ZS := length - n;
wait;
end process;
end struct;