ISSUE 111

Add Proposal  Add Analysis  Edit Class, Environment, or Release
Number 111
Category errata
Synopsis 17.2.4.4: How should $fread deal with partial data to a memory?
State open
Class errata-discuss
Arrival-DateSep 09 2002
Originator Charles Dawson
Release 2001b: 17.2.4.4
Environment
Description
Section 17.2.4.4 Reading binary Data

This section does not adequately describe what should
happen if there is partial data. Should the partial
data be read and placed into the memory using the most
or least significant words? Should it not be read at
all since it doesn't fit (I think this is what C does)?

For example, suppose you have:

reg [15:0] mem [1:0];

And you have 3 bytes of data. Should the $fread result
in:

A) mem[0] = {byte1,byte2}
mem[1] = {byte3,0}

B) mem[0] = {byte1,byte2}
mem[1] = {0,byte3}

C) mem[0] = {byte2,byte1}
mem[1] = {0,0}

In these cases I am assuming that the bytes not containing
data from the file are set to zero. Should they keep
whatever value was there previously? This seems like a
bad idea to me (especially for cases A and B above), but
the spec doesn't say.
Fix
I think option B makes the most sense, since that is the
way a string would be read.
Audit-Trail

From: Gordon Vreugdenhil <gvreugde@synopsys.com>
To: etf-bugs@boyd.com
Cc:
Subject: Re: errata/111: How should $fread deal with partial data to a memory?
Date: Tue, 10 Sep 2002 10:40:50 -0700

I neglected to send this to etf-bugs (thanks Stephen).

Gord.

-------- Original Message --------
Subject: Re: errata/111: How should $fread deal with partial data to a memory?
Date: Mon, 09 Sep 2002 14:20:22 -0700
From: Gordon Vreugdenhil <Gordon.Vreugdenhil@synopsys.COM>
Reply-To: Gordon.Vreugdenhil@synopsys.COM
To: chas@cadence.com
CC: etf@boyd.com
References: <200209091941.g89JfQK01158@max.boyd.com>

Precedence: bulk

chas@cadence.com wrote:
>
> Precedence: bulk
>
> >Number: 111
> >Category: errata
> >Originator: Charles Dawson
> >Environment:
>
> >Description:
>
> Section 17.2.4.4 Reading binary Data
>
> This section does not adequately describe what should
> happen if there is partial data. Should the partial
> data be read and placed into the memory using the most
> or least significant words? Should it not be read at
> all since it doesn't fit (I think this is what C does)?
>
> For example, suppose you have:
>
> reg [15:0] mem [1:0];
>
> And you have 3 bytes of data. Should the $fread result
> in:
>
> A) mem[0] = {byte1,byte2}
> mem[1] = {byte3,0}
>
> B) mem[0] = {byte1,byte2}
> mem[1] = {0,byte3}
>
> C) mem[0] = {byte2,byte1}
> mem[1] = {0,0}
>
> In these cases I am assuming that the bytes not containing
> data from the file are set to zero. Should they keep
> whatever value was there previously? This seems like a
> bad idea to me (especially for cases A and B above), but
> the spec doesn't say.


I think that the "strict" LRM answer is (A) but without zeroing
the low bits of the word. It certainly is not clear what to do
with a partial read however.

What I would prefer (and what VCS currently does coincidentally :-)
is to ignore any trailing partial read. The problem that does
show up there is what to do with the "extra" bytes of data.
One could unget them and return a count that would always
be a multiple of the byte size of the word or one could just
throw them away and return a count that includes "thrown away"
bytes. Again, VCS currently does the latter (throws away the
bytes and returns the byte count including the thrown away bytes).
Note that we *never* clear the remainder of the memory in
any case nor do we write a 0 for a partially read trailing word.

Gord.


--
----------------------------------------------------------------------
Gord Vreugdenhil gvreugde@synopsys.com
Staff Engineer, VCS (Verification Tech. Group) (503) 547-6054
Synopsys Inc., Beaverton OR
Unformatted


Hosted by Boyd Technology