Re: Verilog FileIO proposal

From: Adam Krolnik (adamk@cyrix.com)
Date: Thu Feb 26 1998 - 22:43:56 PST


Hello Mac,

You might want to remove this now since it seemed to include :)

      <li>Opening URLs.

What value from the file does 'signal' contains after this code completes?
   "code = $fread(signal[255:0], fd);"

You may want to include 'signal' in this section or explain how it's different than
the memory organization.

    <p>The data in the file shall be read byte by byte to fulfill the
    request. An 8-bit wide memory is loaded using one byte per memory
    word, while a 9-bit wide memory is loaded using 2 bytes per memory
    word. If the memory width is not evenly divisible by 8 (8, 16, 24,
    32), not all data in the file will be loaded into memory because
    of truncation.</p>

You may want to more concretely define 'signal'. Can it be a part select, a concatenation, etc.

<p>-------------------------------

> <p>At present there is no proposed method of creating a binary
> file using verilog; this may change. Until then, one can create
> a file using C as follows:</p>

Is this proposed system task sufficient?

<p>code = $fwritex(signal, fd);
code = $fwritex(mem[0], fd, start, count);

[This is mostly copied from fread.]

    <p><DD>Write binary values (not ascii representation) to the file
    specified by <B>fd</B> from the register <B>myreg</B> or the memory <B>mem[0]</B>.
    Memory names must have a subscript with an in-range value, though the
    value of the subscript will be ignored. <B><i>Why not just the memory name?</i></b></p>
    <p><B>Start</B> is an optional argument. If present, <B>start</B>
    will be used as the starting location in the memory. If not
    present the least significant location in the memory shall be
    used.</p>
    <p><B>Count</B> is an optional argument. If present, <B>count</B>
    will be the maximum number of locations in <B>mem</B> that will be
    loaded. If not supplied the memory will be filled with what data
    is available.</p>
    <p><B>Start</B> and <B>count</B> are be ignored if <B>$fwritex</B> is
    writing from a register.</p>
    <B>$fwritex</B> shall read data from a memory starting with the
    lowest numbered location, continuing up to the higher location.
    For the memory declared <B>up[10:20]</B>, the first location
    written will be <B>up[10]</B>, next will be <B>up[11],</B> up to
    <B>up[20]</B>. For the memory declared <B>down[20:10]</B>, the
    first location written will be <B>down[10]</B>, then
    <B>down[11],</B> down to <B>down[20]</B>.</p>
    <p><B>start</B> is the word offset from the lowest element in the
    memory. For <B>start</B> = 2 and the memory <B>up[10:20]</B>, the
    first data would be loaded at <B>up[12]</B>. For the memory
    <B>down[20:10]</B>, the first location loaded would be
    <B>down[12]</B>, then <B>down[13]</B>.</p>
    <p>The data in the file shall be written byte by byte to fulfill the
    request. An 8-bit wide memory is loaded using one byte per memory
    word, while a 9-bit wide memory is loaded using 2 bytes per memory
    word. If the memory width is not evenly divisible by 8 (8, 16, 24,
    32), the data will be padded with 0 to the next byte size.</p>
    <p>If an error occurs writing to the file, then <B>code</B> is
    set to zero. Otherwise the number of bytes written is returned
    in <B>code</B>. Applications may call <B>$ferror</B> to determine
    the cause of the most recent error (See below).

<p><p> Adam Krolnik
    Verification Engineer
    Cyrix - NSM.
    Richardson TX. 75085



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:52:46 PDT and
sponsored by Boyd Technology, Inc.