Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Problem writing output result to text file

 
Thread Tools Search this Thread
Old 05-15-2004, 01:51 PM   #1
Default Problem writing output result to text file


Hello,

I'd like to write the output of my testbench to a text file.
Unfortunately now, the stimulus.dat (my output text file) is just
rubbish. The results are perfect when i checked using waveform. I
suspect there is something wrong with the timing in my program, but
dont have any clue how to solve it. are they any suggestions/advice to
solve this ? thanks in advance. below is my testbench code :-

library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
use work.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use IEEE.STD_LOGIC_ARITH.ALL;
library std;



entity alu_testbench is
end alu_testbench;

architecture test_alu of alu_testbench is
component alu_structure
generic(
OPERAND_WIDTH : integer := ;
Port (
-- The input/ouput interface of the module
S : in std_logic_vector(3 downto 0);
A : in std_logic_vector(OPERAND_WIDTH-1 downto 0);
B : in std_logic_vector(OPERAND_WIDTH-1 downto 0);
Y : out std_logic_vector(OPERAND_WIDTH-1 downto 0);
CI : out std_logic;
C, V, Z : out std_logic;
clk : in std_logic;
reset : in std_logic
);
end component;



-- declare math opcode constants
constant ADD : std_logic_vector(3 downto 0) := "0000";
constant SUB : std_logic_vector(3 downto 0) := "0010";
constant INC : std_logic_vector(3 downto 0) := "0001";
constant CMP : std_logic_vector(3 downto 0) := "0011";

-- declare logical opcode constants
constant opAND : std_logic_vector(3 downto 0) := "1100";
constant opOR : std_logic_vector(3 downto 0) := "1101";
constant opXOR : std_logic_vector(3 downto 0) := "1110";
constant opCPL : std_logic_vector(3 downto 0) := "1111";

constant OPERAND_WIDTH : integer := 8;
constant clk_period : time := 10 ns;

signal clock : std_logic;
signal rst : std_logic;
signal S : std_logic_vector(3 downto 0);
signal A : std_logic_vector(OPERAND_WIDTH-1 downto 0);
signal B : std_logic_vector(OPERAND_WIDTH-1 downto 0);
signal alu_result : std_logic_vector(OPERAND_WIDTH-1 downto 0);

signal CI : std_logic;
signal C, V, Z : std_logic;
signal done : std_logic;


for t1 : alu_structure use entity work.alu_structure(alu_arch);


begin -- behavior
t1 : alu_structure


port map (
S => S,
A => A,
B => B,
Y => alu_result,
CI => CI,
C => C,
V => V,
clk => clock,
reset => rst,
Z => Z

);

-- reset process
reset : process
begin
rst <='0','1' after 100 ns;
wait for 1 ms;
end process reset;




-- clock process

clk : process
begin
clock <= '0', '1' after 50 ns;
wait for 100 ns;
end process clk;



-- prinstatus
prinstatus : process (clock, rst)

file infile : text is in
"/elhome/elhh2/ALU_MODEL/alu_example/command.dat";
file outfile : text is out
"/elhome/elhh2/ALU_MODEL/alu_example/stimulus.dat";
variable aluinput : std_logic_vector(19 downto 0);
variable aluoutput : std_logic_vector(7 downto 0);
variable buff : line;

begin -- process
if rst = '0' then
A <= "00000000";
B <= "00000000";
alu_result <= "00000000";

elsif clock'event and clock = '1' then
if not (endfile(infile)) then
readline(infile,buff);
read(buff,aluinput);

B <= aluinput(7 downto 0);
A <= aluinput(15 downto ;
S <= aluinput(19 downto 16);


elsif rising_edge(clock) then
aluoutput(7 downto 0) := alu_result;

write(buff,aluoutput);
writeline(outfile,buff);


end if;
end if;
end process prinstatus;

end test_alu;


Lily
  Reply With Quote
Old 05-19-2004, 04:34 PM   #2
Amontec Team
 
Posts: n/a
Default Re: Problem writing output result to text file
Lily wrote:
> Hello,
>
> I'd like to write the output of my testbench to a text file.
> Unfortunately now, the stimulus.dat (my output text file) is just
> rubbish. The results are perfect when i checked using waveform. I
> suspect there is something wrong with the timing in my program, but
> dont have any clue how to solve it. are they any suggestions/advice to
> solve this ? thanks in advance. below is my testbench code :-
>
> library ieee;
> use ieee.std_logic_1164.all;
> use std.textio.all;
> use work.all;
> use ieee.numeric_std.all;
> use ieee.std_logic_textio.all;
> use IEEE.STD_LOGIC_ARITH.ALL;
> library std;
>
>-- ...


Don't use both ieee.numeric_std.all and IEEE.STD_LOGIC_ARITH.ALL.

Please remove the IEEE.STD_LOGIC_ARITH.ALL.

And run again !

Laurent Gauch
www.amontec.com


Amontec Team
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Ripping DVDs. Please answer the attached question. - Question.txt Stan Brown DVD Video 19 02-09-2005 11:19 PM
Burn process failed - help! Log file posted for help troubleshooting Michael Mason DVD Video 1 08-16-2004 09:24 PM
"Rip" lyrics/subtitles from DVD to text file ©® DVD Video 5 12-19-2003 08:17 PM
How do I split a mpeg-2 file, then recombine to get the same thing? William Richardson DVD Video 5 12-18-2003 02:17 PM
Pioneer A05 Problems Bill Stock DVD Video 8 11-28-2003 05:03 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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