Para leer sin fichero de texto:
Código
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_textio.all; use std.textio.all; ENTITY Memoria_Ins IS port(address_i : IN std_logic_vector (31 DOWNTO 0); d_o : OUT std_logic_vector (31 DOWNTO 0)); END Memoria_Ins; architecture funcional of Memoria_Ins is type memoria is array(integer range <>) of std_logic_vector(31 downto 0); signal instrucciones : memoria(0 to 64):= (0=> "11110000000000110000000000000100", 4=> "11110000000001010000000000001000", 8=> "11000000101000110011000000000001", 12=> "00000100000010000000000000000000", 16=> "00001100000001010000000000001100", 20=> "10001000000000000000000000011100", 24=> "00000000000000000000000000000000", 28=> "11000001010001010001100000000101", others=> "11111100000000000000000000000000"); begin d_o<=instrucciones(conv_integer(address_i)); end funcional;
Para leer con fichero de texto (intento de process):
Código
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_textio.all; use std.textio.all; ENTITY Memoria_Ins IS port(address_i : IN std_logic_vector (31 DOWNTO 0); d_o : OUT std_logic_vector (31 DOWNTO 0)); END Memoria_Ins; architecture funcional of Memoria_Ins is type memoria is array(integer range <>) of std_logic_vector(31 downto 0); signal instrucciones : memoria(0 to 64); --0 addi r0,r3,4 --4 addi r0,r5,8 --8 add r5,r3,r6 --12 --12 lw r0,0(r8) --16 sw r0,12(r5) begin d_o<=instrucciones(conv_integer(address_i)); process FILE vector_test : text OPEN read_mode IS "test.txt"; VARIABLE vector : LINE; VARIABLE instrucciones_aux : memoria(0 to 64); VARIABLE palabra : std_logic_vector (31 DOWNTO 0); VARIABLE instruccion : INTEGER; BEGIN instruccion:=0; WHILE NOT endfile(vector_test) LOOP readline(vector_test,vector); --Guardo la linea en vector read(vector,palabra); --Obtengo los 32 bits de la palabra y los guardo en palabra Instrucciones_aux:=(instruccion => palabra, others=> "11111100000000000000000000000000"); --Intento recrear el array de instrucciones con sus salidas instruccion:= instruccion + 4; --Sumo 4 para el siguiente ciclo WAIT FOR 20 ns; END LOOP; instrucciones <= instrucciones_aux; file_close(vector_test); END process; end funcional;
El fichero de texto sólo tiene las palabras de 32 bits:
"11110000000000110000000000000100
11110000000001010000000000001000
11000000101000110011000000000001
00000100000010000000000000000000
00001100000001010000000000001100"
Un saludo foreros