J
Jonathan Bromley
Guest
I've spent a while staring at the Verilog-2001 LRM (section
17.1.1.2, Format Specifications) trying to decide what should
happen when you write stuff with %z (4-state binary I/O).
I am happy to accept that the resulting file will differ
on various platforms because of byte ordering, endianness,
struct alignment issues and all the usual suspects.
However, my reading of the LRM leads me to believe that
such files should be interoperable between simulators
on a single platform, because the I/O machinery is
specified at quite a low level.
Contrariwise, I have two well-known simulators giving different
results on the same platform (32-bit Intel Linux). Basically
they are both writing out 32-bit words in little-endian order,
but they are swapping the aval and bval words.
For example:
reg [31:0 v;
...
v = 32'0xz1; // aval = 0x00_00_0F_01
// bval = 0x00_00_0F_F0
$fwrite(f, "%z", v);
gives the following byte-streams (using "od -t x1"):
simulator A:
01 0F 00 00 F0 0F 00 00
simulator B:
F0 0F 00 00 01 0F 00 00
I am entirely convinced that this is a Bad Thing (tm).
However, I would value the community's opinions on
whether it's a violation of the LRM.
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:jonathan.bromley@doulos.com
Fax: +44 (0)1425 471573 Web: http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
17.1.1.2, Format Specifications) trying to decide what should
happen when you write stuff with %z (4-state binary I/O).
I am happy to accept that the resulting file will differ
on various platforms because of byte ordering, endianness,
struct alignment issues and all the usual suspects.
However, my reading of the LRM leads me to believe that
such files should be interoperable between simulators
on a single platform, because the I/O machinery is
specified at quite a low level.
Contrariwise, I have two well-known simulators giving different
results on the same platform (32-bit Intel Linux). Basically
they are both writing out 32-bit words in little-endian order,
but they are swapping the aval and bval words.
For example:
reg [31:0 v;
...
v = 32'0xz1; // aval = 0x00_00_0F_01
// bval = 0x00_00_0F_F0
$fwrite(f, "%z", v);
gives the following byte-streams (using "od -t x1"):
simulator A:
01 0F 00 00 F0 0F 00 00
simulator B:
F0 0F 00 00 01 0F 00 00
I am entirely convinced that this is a Bad Thing (tm).
However, I would value the community's opinions on
whether it's a violation of the LRM.
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:jonathan.bromley@doulos.com
Fax: +44 (0)1425 471573 Web: http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.