IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VHDL Discussion :

Problème avec la fonction READ


Sujet :

VHDL

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2011
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Septembre 2011
    Messages : 4
    Points : 4
    Points
    4
    Par défaut Problème avec la fonction READ
    Bonjour,

    En fait, je suis en train d'écrire un code pour faire la multiplication avec la méthode de wallace...
    Lors de la génération d'un "test-bench" j'utilise deux fichiers .bat dont chacun contient des données string de la forme "0010100110011011" (16 bits chaque ligne) qui sont constituées à partir de Matlab...

    Bref, en test-bench, je fais la conversion string<==>std_logic_vector pour convertir les données "string" lues à partir des fichiers ".bat" en std_logic_vector et par suite faire la multiplication et le stockage du résultat dans un fichier .dat...

    Mais lors de la simulation sous Isim, il me donne l'erreur suivante :
    Error: length of string read is less than the string size, ceci à chaque fois qu'il tente à stocker le contenu de la ligne dans la variable de type string "str1_signal" et "str2_signal".
    Le code source de test-bensh est le suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    LIBRARY ieee;
    USE ieee.std_logic_1164.ALL;
    USE IEEE.numeric_std.ALL;
    --
    LIBRARY std;
    USE std.textio.ALL;
     
    -- Uncomment the following library declaration if using
    -- arithmetic functions with Signed or Unsigned values
    --USE ieee.numeric_std.ALL;
     
    ENTITY multiplication_tb IS
    generic (N : integer:= 16);
    END multiplication_tb;
     
    ARCHITECTURE behavior OF multiplication_tb IS 
     
        -- Component Declaration for the Unit Under Test (UUT)
     
        COMPONENT multiplication
        PORT(
             clk : IN  std_logic;
             rst : IN  std_logic;
             en : IN  std_logic;
             AA : IN  std_logic_vector(N downto 0);
             BB : IN  std_logic_vector(N downto 0);
             SS : OUT  std_logic_vector(2*N downto 0)
            );
        END COMPONENT;
     
     
       --Inputs
       signal clk : std_logic := '1';
       signal rst : std_logic := '0';
       signal en : std_logic := '1';
       signal AA : std_logic_vector(N downto 0) := (others => '0');
       signal BB : std_logic_vector(N downto 0) := (others => '0');
     
     	--Outputs
       signal SS : std_logic_vector(2*N downto 0);
     
       -- Clock period definitions
       constant clk_period : time := 10 ns; --10 ns;
    	--CONSTANT PERIOD : time := 12500 ps; 
     
       --files decleration 
    	file signal1_vect : text open READ_MODE is "C:\Users\CHIHEB\Documents\MATLAB\data_in1.dat";    
    	file signal2_vect : text open READ_MODE is "C:\Users\CHIHEB\Documents\MATLAB\data_in2.dat";
    	file signalout_vect : text open WRITE_MODE is "C:\Users\CHIHEB\Documents\MATLAB\data_out.dat";
    	--conversion functions decleration 
    	--
    FUNCTION str_to_stdvec(inp: string) return std_logic_vector is
     
    VARIABLE temp: std_logic_vector(inp'range) := (others => 'X');
     
    BEGIN 
     
            for i in inp'range loop
     
                if (inp(i) = '1') then
     
                    temp(i) := '1';
     
                elsif (inp(i) = '0') then
     
                    temp(i) := '0'; 
    			   else  temp(i) :='X';
     
                end if;
     
            end loop;
     
    return temp;
     
    end function str_to_stdvec;
    --
    FUNCTION stdvec_to_str(inp: std_logic_vector) return string is
     
    VARIABLE temp: string(inp'left+1 downto 1) := (others => 'U');
     
    BEGIN
     
            for i in inp'reverse_range loop
     
                if (inp(i) = '1') then
     
                    temp(i+1) := '1';
     
                elsif (inp(i) = '0') then
     
                    temp(i+1) := '0';
                else temp(i+1) := 'X';				
     
                end if;
     
            end loop;
     
    return temp;
     
    end function stdvec_to_str;
    --
     
     
    BEGIN
     
    	-- Instantiate the Unit Under Test (UUT)
       uut: multiplication PORT MAP (
              clk => clk,
              rst => rst,
              en => en,
              AA => AA,
              BB => BB,
              SS => SS
            );
     
       -- Clock process definitions
       clk_process :process
       begin
    		clk <= '0';
    		wait for clk_period/2;
    		clk <= '1';
    		wait for clk_period/2;
       end process;
     
    	-- ENABLE CLOCK DEF
    ENABLE : process
    begin
    	  en <= not en;
    	  wait for 10*clk_period/2;
    end process ENABLE;
    -- RESET CLOCK DEF
    RESET : process
    begin
    	  rst <= transport '1';
    	  wait for 7000 ps;
    	  rst <= transport '0';
    	  wait for 1000000 ns;
    end process RESET;
    --
     
     
     
    --   -- Stimulus process
    --   stim_proc: process
    --   begin		
    --      -- hold reset state for 100 ns.
    --      wait for 100 ns;	
    --
    --      wait for clk_period*10;
    --
    --      -- insert stimulus here 
    --
    --      wait;
    --   end process;
     
     
    --		
     
    Read_input : process
     
    variable str1_signal : string (N+1 downto 1);
    variable file1_line : line;
    variable str2_signal: string (N+1 downto 1);
    variable file2_line : line;
     
    begin 
    wait until rising_edge(Clk);
    	while not endfile(signal1_vect)and not endfile(signal2_vect)loop
    	      readline(signal1_vect,file1_line);
    			readline(signal2_vect,file2_line);
             read(file1_line,str1_signal);
    			read(file2_line,str2_signal);
    			wait for 1 ns;
       	   AA <= str_to_stdvec(str1_signal);
    			BB <= str_to_stdvec(str2_signal);
    			wait until falling_edge(Clk);
    	end loop;
     file_close(signal1_vect);	
     file_close(signal2_vect);	
    end process;
    --
    Write_output:process
     
    variable temp_out: std_logic_vector (2*N downto 0);
    variable outb: string (2*N+1 downto 1);
     
    variable file_line : line;
     
    begin
     
    wait until falling_edge(Clk);
    	while not endfile(signal1_vect)and not endfile (signal2_vect)loop
    			wait for clk_period;
    		   temp_out := SS;
    			outb := stdvec_to_str(temp_out);
    			write(file_line,outb);
             writeline(signalout_vect,file_line);
    	end loop;	
     file_close(signalout_vect);		
    end process Write_output;
     
     
    END behavior;
    J'attends votre aide, vraiment j'ai passé environ une semaine mais je n'ai pas trouvé la solution !!

    Je vous remercie

  2. #2
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2011
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Septembre 2011
    Messages : 4
    Points : 4
    Points
    4
    Par défaut
    Vraiment je me suis bloqué !!
    Je me sens que c'est un petit problème de rien du tout, mais j'ai pas encore trouvé la solution !!

    Merci de me faire un petit clin d’œil !!

  3. #3
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Septembre 2011
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Septembre 2011
    Messages : 4
    Points : 4
    Points
    4
    Par défaut
    Citation Envoyé par chiheb1111111 Voir le message
    Vraiment je me suis bloqué !!
    Je me sens que c'est un petit problème de rien du tout, mais j'ai pas encore trouvé la solution !!

    Merci de me faire un petit clin d’œil !!
    J'ai trouvé l'erreur: en fait, les fichiers data_in1 et data_in2, contiennent des strings de longueur 16 et non 17 ....

    Maintenant la fonction "read" marche bien, mais maintenant, il y a un problème avec la fonction write: en effet, le simulateur m'indique sue la ligne que je viens de construire "file_line" reste toujours vide "NULL", je sais pas pourkoi !!

    Est ce que quelqu'un parmi vous peux m'aider ?

    Je vous remercie


Discussions similaires

  1. Problème avec la fonction read.
    Par Whaouu dans le forum Langage
    Réponses: 10
    Dernier message: 23/09/2005, 10h33
  2. Problème avec la fonction findfirst ()
    Par Angelico dans le forum Windows
    Réponses: 3
    Dernier message: 05/08/2004, 20h40
  3. [Requete SQL en VBA] Problème avec la fonction FLOOR
    Par zubral dans le forum Langage SQL
    Réponses: 4
    Dernier message: 13/07/2004, 13h24
  4. Problème avec les fonctions
    Par jvachez dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 13/01/2004, 12h06
  5. [Postgresql]Problème avec les fonctions ...
    Par fet dans le forum Requêtes
    Réponses: 4
    Dernier message: 02/10/2003, 09h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo