rohd icon indicating copy to clipboard operation
rohd copied to clipboard

A helper function to save generated System Verilog string as a file

Open quekyj opened this issue 2 years ago • 1 comments

Motivation

I'm wondering if we can have a helper function to save system Verilog module generateSynth() to a file. Its a pain to keep copy pasting the code below to keep track of system verilog code generated.

import 'dart:io';

final res = mod.generateSynth();
final out = File('output.txt').openWrite();
out. Write(res);

File('temp.sv').writeAsStringSync(myString);

I am thinking maybe someone who also beneficial to have the system verilog .sv file as well.

Desired solution

There are two ways I can think of.

First is update:

  • generateSynth() function to receive arguments like generateSynth(toFile=true, path='./mypath/simMod.sv)'
  • Note that this might cause breaking changes as openWrite().close() will return Future<void>.

Second:

  • Create a static helper function to just dump in string to any file format.

Alternatives considered

No response

Additional details

No response

quekyj avatar Dec 29 '22 08:12 quekyj

Different cases to consider:

  • Generate a string with all modules in it (already supported), return as String
  • Generate a string per-module (supported via SynthBuilder and SynthResult), return as List<SynthResult>
  • Generate a file with all modules in it (take output of above, put into file)
  • Generate one module per file (take output of above, put into files per module)

Each of these options might use a different Synthesizer

The API should be simple to use for all these cases for any Synthesizer.

Maybe something like this, where both options take Synthesizer as an option? generateSynth -> returns String, optionally additionally dumps to file with all modules in one file? generateSynthPerModule -> returns List<SynthResult>, optionally additionally dumps to a directory?

mkorbel1 avatar Jan 05 '23 01:01 mkorbel1