|
From: <ni...@ly...> - 2015-02-10 14:35:30
|
I'm now trying to read a memory dump, using a command line argument for the file name (as hinted at the end of http://iverilog.wikia.com/wiki/Simulation). System verilog has a string type, so I tried this program, module main; reg [64:0] mem [0:100]; string img; initial begin if (!$value$plusargs("img=%s", img)) begin $display("Specify image file with +img=<image>."); $finish_and_return(1); end $display("Using image: %s", img); $readmemh(img, mem); $display("Initial memory word: mem[0] = %x", mem[0]); $finish; end endmodule // main I compile using $ iverilog -g2005-sv main.vl -o main (with iverilog compiled from git eariler today). Works fine, so far. But running it fails, $ ./main +img=../examples/hello.hex ERROR: main.vl:5: $value$plusargs's second argument must be a variable, found a vpiStringVar. If I change "string img;" to "reg [300:0] img;" it works, and I get the output Using image: ../examples/hello.hex WARNING: main.vl:10: $readmemh(../examples/hello.hex): Not enough words in the file for the requested range [0:100]. Initial memory word: mem[0] = 07000b4a08408e500 But that doesn't seem like a very good solution, since I have to put an arbitrary size on the register, and it will fail with filenames which exceed this size. If I try the System verilog support in iverilog (primarily, I would like to use the interface abstraction), I should be able to use the vlog95 target to generate plain verilog code which I could feed to, e.g., yosys, right? Regards, /Niels -- Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance. |