[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  Schedule::Load
  SVN::S4
  Synopsys-modes
  SystemPerl
  Verilog-Pli
  Voneline
  Vregs
General Info
  Papers

how to save a modified file?

Added by Mike Z almost 2 years ago

In the docs I see how to read a file, and I see that I could add a port to a module/instance, but I don't see how to save that file..

ie. I'd like to a- load module A b- go down to instance u_fred (of module type fred) c- add port foo to u_fred d- save A (with port added to u_fred) e- load module fred f- add the same port there g- save fred (with added port)

I've got code to do a,b,e I think I can use Verilog::Netlist::Port $self->new_port for c and/or f (be happy for any code examples) not seeing any kind of save_file or write_file command for steps d,g

thanks, Mike


Replies (6)

RE: how to save a modified file? - Added by Wilson Snyder almost 2 years ago

Call

  print $module_object->verilog_text

You'd then print to a file handle if you want it in a file, perhaps to the $module_object->filename to return it to where it came from.

RE: how to save a modified file? - Added by Mike Z almost 2 years ago

Couple of questions

a) my source file was Verilog-2001 with ANSI-style declarations... when I

open (OUT_FILE,">$newfile.tmp");
      map {
          printf OUT_FILE $_;
      } ($mod->verilog_text);
      close (OUT_FILE);
I don't get any input/output declarations..

b) does it keep the comments anywhere? I am not seeing any of the comment text from the original file in the resulting file (from the print above)

thanks, Mike

RE: how to save a modified file? - Added by Wilson Snyder almost 2 years ago

a) That should work. Maybe the objects weren't created? Try printing $netlist->dump to see if the structures are what you think they should be.

b) Only comments on nets are written out in Verilog::Netlist, IE not the comments on the top of a module. Presuming that's the ones you want, make sure you used keep_comments when creating the netlist
  $netlist_object = Verilog::Netlist->new(...., keep_comments=>1);

RE: how to save a modified file? - Added by Mike Z almost 2 years ago

netlist->dump shows the list of ports with directions.

input file has

module s0a ( output wire CLK_DBG_S0);

output file has

module s0a ( CLK_DBG_S0A ); wire CLK_DBG_S0A;

but nowhere does it declare it as an output.

RE: how to save a modified file? - Added by Wilson Snyder almost 2 years ago

I added your module to a test, and write_verilog correctly creates:

module msg328 (
   msg328w);
   output msg328w;
endmodule

Are you using the most recent version? If so, can you package up a test case and file a bug?

RE: how to save a modified file? - Added by Mike Z almost 2 years ago

Filed... Issue #278

(1-6/6)