Forum Discussion
Altera_Forum
Honored Contributor
16 years agoproblem with ModelSim
I use ModelSim to simulate an adder(sumador.vdh) and a testbench(bancopruebas.vdh) that read a text file "Datos.txt" where the data are;and put the result in other file "resultados.txt". After I comp...
Altera_Forum
Honored Contributor
16 years agoSorry the extension are vhd, here are the sources:
library ieee; use std.textio.all; entity bancopruebas is end bancopruebas; -- architecture estructura of bancopruebas is signal OpA,OpB,suma:integer; component sumador port(OpA: in integer; OpB: in integer; suma : out integer); end component; begin --proceso que lee los estimulos y graba los resultados process constant Periodo :time:= 100 ns; file Datos :text is in "Datos.txt"; variable lineadatos :line; file resultados :text is out "resultados.txt"; variable linearesultados :line; variable OpA_I,OpB_I :integer; begin while not endfile(Datos) loop readline(Datos,lineadatos); -- read(lineadatos,OpA_I); read(lineadatos,OpB_I); OpA <= OpA_I; OpB <= OpB_I; wait for Periodo; write(linearesultados,OpA); if OpB_I < 0 then write(linearesultados,string'("-")); else write(linearesultados,string'("+")); end if; write(linearesultados,abs(OpB)); write(linearesultados,string'("=")); write(linearesultados,suma); writeline(resultados,linearesultados); end loop; wait; end process; -- Referencia al sumador sumador0: sumador port map(OpA,OpB,suma); end estructura; ---------------and the sumador is entity sumador is port(OpA : in integer; OpB : in integer; suma : out integer); end sumador; as you can see I dont need architecture here becouse the first program do the job