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.

How to read data file by VHDL

Status
Not open for further replies.

hoangthanhtung

Full Member level 3
Joined
Apr 23, 2004
Messages
151
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,298
Activity points
1,362
I have a question. Is there anybody know how to read the text file or binary file by usng VHDL or verilog to make a test bench.

Let me know the name of VHDL or verilog, give me example if you can.


Thank in advance.
 

hi,
i have attached a sample code.u find it useful.
 

hi
i`ve stored the pixel values in a text file in form of matrix now i need to read the values into array pls tell me how can i do this
thanks in advance
 

There are plenty of examples of how to use the textio library over the internet. Come back when you're stuck with something specific.
 

i have written a program but i don` tknw wats wrong in that pls can u rectify it
 

the attachments are here the code n the file which i need to read
 

Attachments

  • file_read.txt
    1.4 KB · Views: 73
  • decimal1.txt
    231.8 KB · Views: 93

and what problems are you having with this code?
You realise you cannot synthesise it right? file IO is only appropriate for testbenches.
 

ERROR:HDLParsers:808 - "F:/Xilinx/file1/file2.vhd" Line 55. readline can not have such operands in this context.
ERROR:HDLParsers:808 - "F:/Xilinx/file1/file2.vhd" Line 56. read can not have such operands in this context. these r the errors i`m gettin.

---------- Post added at 09:36 ---------- Previous post was at 09:35 ----------

sorry i ddin`t knew this concept. actually i want to read the values n give them as input for another program which converts integer to binary. wat solution can i have now
 

are you trying to synthesise this code? or just simulate it?

---------- Post added at 09:41 ---------- Previous post was at 09:40 ----------

another unrelated issue - you cannot have inout ports of type integer.
 

i want to simulate

---------- Post added at 09:51 ---------- Previous post was at 09:43 ----------

sir as i told is it possible to read the numbers in file and give them as input. like i mean in array form for conversion
 

it is possible to do a lot of things with VHDL. And it would be fine to read them into an array.
The errors you are getting makes me think you are trying to synthesise the code rather than simulate, because there is nothing wrong with the code for simulation. But my thoughts include:

1. With the current code, you are only going to read the first value from each line in the decimal.txt file
2. you have declared a type called "decimal", which is a file of integer. Why? you are reading a text file not a data file.
3. you cannot have an inout port of type integer
4. When you get to the end of the file, it is going to start all over again from the start of the file. Processes loop forever.
 

no sir simulation is happenin wid this code

---------- Post added at 16:43 ---------- Previous post was at 16:41 ----------

sorry simulation is not happening with the code bcos its showing the error
ERROR:HDLParsers:808 - "F:/Xilinx/file1/file2.vhd" Line 55. readline can not have such operands in this context.
ERROR:HDLParsers:808 - "F:/Xilinx/file1/file2.vhd" Line 56. read can not have such operands in this context.
 

delete all of the type declarations in your file. It is messing it all up. The types are already declared in std.textio, you should not declare them again yourself.
 

thank u sir now the error is not there. how can i view the values that i`ve got from file.
ERROR:Simulator:29 - at 0 ns : Could not open file 'C:\Documents and
Settings\Chitra\Desktop\decimal.txt' of Text
ERROR:Simulator:29 - at 0 ns :
bcos while simulating i got this error
 

first of all, you need to make sure that the file exists where you say it does - the path is obviosuly wrong.
Secondly - put the "int" signal on a wave window.
 

sir i got the output

---------- Post added at 17:10 ---------- Previous post was at 17:08 ----------

but its reading only first value shd i extend the loop
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top