Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] need help for textio function

Status
Not open for further replies.

kasthu

Newbie level 3
Joined
Sep 13, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
37
me newly working in textio function. integer files to write and read no problem,where as to write the output of binary vectors problem. any one know syntax for that help me please.below is code.



1)library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;


entity m is
Port ( clk ,rst: in STD_LOGIC);

end m;

architecture Behavioral of m is

begin
process(clk,rst)
file outfile:text is out"d:\kasthu\outfile1.txt";
variable outline:line;
variable q:bit_vector(4 downto 0);
begin
if(rst='1')then
q:="00000";
elsif(clk'event and clk='1')then
q:=q+1;

write(outline,q);
writeline(outfile,outline);
end if;
end process;
end Behavioral;


error:
+ can not have such operands in this context.

-------------------------------------------------------------------------------------------------------------------------------------------------

2)library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;


entity lf is
Port ( clk,rst : in STD_LOGIC;
q :inout STD_LOGIC_vector(4 downto 0));
end lf;

architecture Behavioral of lf is

begin

process(clk,rst)
file outfile:text is out"d:\kas\outfile1.txt";
variable outline:line;
begin

for i in 0 to 31 loop
if(rst='1')then
q<="00001";

elsif(clk'event and clk='1')then
q(0)<=q(4) ;
q(1)<=q(0);
q(2)<=q(1);
q(3)<=q(2);
q(4)<=q(3);

write(outline,q);
writeline(outfile,outline);
end if;
end loop;
end process;
end Behavioral;

error:
write can not have such operands in this context.
 

try using conv_integer() to convert q to integer and then write.

Code:
write(outline,conv_integer(q));
writeline(outfile,outline);
 
  • Like
Reactions: kasthu

    kasthu

    Points: 2
    Helpful Answer Positive Rating
or include the std_logic_textio package (so you can write std_logic and std_logic_vectors directly to text files)

Or even better, swap to VHDL 2008 where textio for all base types in normal, and included in appropriate packages (like std_logic_1164).

In regards to the OPs first bit of code - you cannot do arithmatic with bit vectors. THey are just that, a vector full of bits. its not a number. You need to include the numeric_std package (and delete std_logic_unsigned and std_logic_arith) and use the signed/unsigned types. Or just switch to integer.
 

try using conv_integer() to convert q to integer and then write.

Code:
write(outline,conv_integer(q));
writeline(outfile,outline);

thank you so much:)

- - - Updated - - -

thank u so much :smile:
 

thanks . i used ur command for convert to integer i get text file like this . but i need to write binary vector output in text file. i searched syntax but all end with errors. u konw this help me please for code number 1.
 

I told you the problem with code number 1. THe problem is with the + function, not the text io. You cannot do arithmatic with bit_vectors.
 

thanks . i used ur command for convert to integer i get text file like this . but i need to write binary vector output in text file. i searched syntax but all end with errors. u konw this help me please for code number 1.

you mean that you be able to write text file, then is that true that there were no error in code?

if it's true:
there is a syntax that can convert a type to character. the syntax is:
T'IMAGE(x), T is a type and x is an element of that object. for example
Code:
type T1 is (s1,s2,s3);
T1'image(s1);-- return "s1"

for your problem test code like below. I think it will be ok. tell me the results plz.
Code:
write(outline,integer'image(conv_integer(q)));
writeline(outfile,outline);
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top