"Steven Sharp" <sharp@cadence.com> wrote in message news:3a8e124e.0411181905.575b897e@posting.google.com...> "Jim Wu" <nospam@nospam.com> wrote in messagenews:<cngkbn$4m1@cliff.xsj.xilinx.com>...> > > > if (data == 0) begin > > $fwriteb(fd, "%u", data); > > $fseek(fd, 1, 0); > > end > > else > > $fwriteb(fd, "%c", data); > > Shouldn't that be $fseek(fd, -3, 1), to seek backwards > 3 bytes from the current position to compensate for > having written a 4-byte binary word instead of 1 byte? > With $fseek(fd, 1, 0), you are seeking to the second > byte in the file, which is only correct if you were > at the start of the file when you wrote the NUL byte.You are absolutely right. My first posting was to show how to get around the problem that some simulators (e.g. Modelsim) cannot write out the NULL byte. Of course a more general solution is using $fseek(fd, -3, 1) as you pointed out.> Some simulators actually let you write a NUL byte > out with %c, which avoids this nastiness.I know NCVerilog can do this, but not all simulators work this way. Jim
Xilinx, VHDL, Verilog, ModelSim, BMP
Started by ●November 16, 2004
Reply by ●November 19, 20042004-11-19
Reply by ●November 19, 20042004-11-19
Hi, I ended up with the following, which works:> task WRITE_BYTE; > input [7:0] data; > integer position; > begin > if (data == 0) > begin > position = $ftell(file_ptr); > position = position + 1; > $fwriteb(file_ptr, "%u", data); > $fseek(file_ptr, position, 0); > end > else > begin > $fwriteb(file_ptr, "%c", data); > end > end > endtaskAre you saying that a more concise way to do this would be with a relative seek? I don't have a good reference for these system tasks, the best I could come up with is what I put above, based on reading some web material. But this:> $fseek(fd, -3, 1)Seems much more concise... It's equivalent? Eric
Reply by ●November 22, 20042004-11-22
"Jim Wu" <nospam@nospam.com> wrote in message news:<cnkuh6$qn02@cliff.xsj.xilinx.com>...> "Steven Sharp" <sharp@cadence.com> wrote in message > news:3a8e124e.0411181905.575b897e@posting.google.com... > > > Some simulators actually let you write a NUL byte > > out with %c, which avoids this nastiness. > > I know NCVerilog can do this, but not all simulators work this way.NC-Verilog didn't work this way originally either. We added this capability in response to user requests. Perhaps other simulator vendors would also be willong to do this if they got enough requests. In the meantime, the basic workaround you suggested should work.
Reply by ●November 22, 20042004-11-22
Eric Crabill <eric.crabill@xilinx.com> wrote in message news:<419E423B.E41CDB7F@xilinx.com>...> > Are you saying that a more concise way to do > this would be with a relative seek? I don't > have a good reference for these system tasks, > the best I could come up with is what I put > above, based on reading some web material.What you came up with should work. It even has the advantage of being clearer in some ways, and doesn't rely on the implementation correctly following the LRM in writing out 32-bit chunks with %u. But a relative seek is more concise. The third argument to $fseek is 0 for a seek relative to the start of the file, 1 for a seek relative to the current position in the file, and 2 for a seek relative to the end of the file. This assumes that your simulator has implemented $fseek correctly, of course.> But this: > > > $fseek(fd, -3, 1) > > Seems much more concise... It's equivalent?Should be.
Reply by ●December 6, 20042004-12-06
Hi, Sorry it took so long, but here it is, a module that will record RGB video data to TIFF files. A small testbench is also provided: http://www.fpga-games.com/cx2600/tiff/ I hope it helps somebody, I found it useful. I'd like to thank everyone for their input on this topic. Eric
Reply by ●January 29, 20052005-01-29
i want to make a project in verilog plze guide m -- ibadwww.totallychips.com - VHDL, Verilog & General Hardware Design discussion Foru
Reply by ●January 29, 20052005-01-29






