EDAboard.com | EDAboard.eu | EDAboard.de | EDAboard.co.uk | RTV forum PL | NewsGroups PL

Writing & reading same file

Ask a question - edaboard.com

elektroda.net NewsGroups Forum Index - VHDL Language - Writing & reading same file

Niv (KP)
Guest

Mon Sep 13, 2010 4:29 pm   



In my testbench, is it possible to write to a file, then read that
file, then write to the file again, then read the file again, etc etc.
It doesn't matter if the file is re-opened and destrots the previous
data written.

Seem to be having trouble doing this.

i.e. in my tb, unit 1 writes several lines of binary data (as text) to
file A, then unit 2 needs to read this file A before it then writes
out other data to file B.

This is then repeated several times/

Jonathan Bromley
Guest

Mon Sep 13, 2010 9:05 pm   



On Mon, 13 Sep 2010 06:29:59 -0700 (PDT), "Niv (KP)" wrote:

Quote:
In my testbench, is it possible to write to a file, then read that
file, then write to the file again, then read the file again, etc etc.
It doesn't matter if the file is re-opened and destrots the previous
data written.

Seem to be having trouble doing this.

i.e. in my tb, unit 1 writes several lines of binary data (as text) to
file A, then unit 2 needs to read this file A before it then writes
out other data to file B.

hi Kevin

Did you close file A before attempting to re-open and then
read from it? (Of course this requires using the -93
form of file declaration, and FILE_OPEN and FILE_CLOSE
procedures.)

When you write new data to a file, I don't think there is
any guarantee of that file's contents until it's closed.

While we're thinking about this, it's worth mentioning
that you need to be very careful when multiple processes
access the same file. The file is in effect a shared
variable with no kind of interlock or scheduling, so it
is quite easy to get indeterminacy - one of the very few
places this can happen in VHDL. Unless you have really
huge amounts of data (many tens of megabytes) it may be
better to use shared variables of protected type.
--
Jonathan Bromley

Rob Gaddi
Guest

Mon Sep 13, 2010 9:16 pm   



On 9/13/2010 1:05 PM, Jonathan Bromley wrote:
Quote:
On Mon, 13 Sep 2010 06:29:59 -0700 (PDT), "Niv (KP)" wrote:

In my testbench, is it possible to write to a file, then read that
file, then write to the file again, then read the file again, etc etc.
It doesn't matter if the file is re-opened and destrots the previous
data written.

Seem to be having trouble doing this.

i.e. in my tb, unit 1 writes several lines of binary data (as text) to
file A, then unit 2 needs to read this file A before it then writes
out other data to file B.

hi Kevin

Did you close file A before attempting to re-open and then
read from it? (Of course this requires using the -93
form of file declaration, and FILE_OPEN and FILE_CLOSE
procedures.)

When you write new data to a file, I don't think there is
any guarantee of that file's contents until it's closed.

While we're thinking about this, it's worth mentioning
that you need to be very careful when multiple processes
access the same file. The file is in effect a shared
variable with no kind of interlock or scheduling, so it
is quite easy to get indeterminacy - one of the very few
places this can happen in VHDL. Unless you have really
huge amounts of data (many tens of megabytes) it may be
better to use shared variables of protected type.

And if you do, it may be better to use a protected type as a wrapper
around that file to manage transactions against it.

--
Rob Gaddi, Highland Technology
Email address is currently out of order

elektroda.net NewsGroups Forum Index - VHDL Language - Writing & reading same file

Ask a question - edaboard.com

Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
RTV map EDAboard.com map News map EDAboard.eu map EDAboard.de map EDAboard.co.uk map Opony