Skip to content

Add formattter for genus tcl#102

Closed
parthkalgaonkar wants to merge 5 commits intopezy-computing:masterfrom
parthkalgaonkar:feature/add_genus_tcl_formatter
Closed

Add formattter for genus tcl#102
parthkalgaonkar wants to merge 5 commits intopezy-computing:masterfrom
parthkalgaonkar:feature/add_genus_tcl_formatter

Conversation

@parthkalgaonkar
Copy link
Copy Markdown

Hi,

Adding this formatter for genus. Let me know if you need any additions / changes

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.89%. Comparing base (84d996e) to head (b831f30).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #102   +/-   ##
=======================================
  Coverage   99.89%   99.89%           
=======================================
  Files          15       17    +2     
  Lines        1828     1857   +29     
=======================================
+ Hits         1826     1855   +29     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@taichi-ishitani
Copy link
Copy Markdown
Member

taichi-ishitani commented Apr 22, 2026

@parthkalgaonkar ,

Thank you for your contribution!

I request you two thins:

  • Add unit tests for this class and confirm 100 % code coverage
    • Refer
      context '--format=vivado-tclが指定された場合' do
      let(:output) do
      'out.tcl'
      end
      before do
      allow(File).to receive(:open).with(output, 'w').and_yield(io)
      end
      it 'vivadoで読み込み可能なTCLを書き出す' do
      cli.run(["--output=#{output}", '--format=vivado-tcl', file_list])
      expect(io.string).to eq(<<~TCL)
      # flgen version #{FLGen::VERSION}
      # applied arguments
      # --output=#{output}
      # --format=vivado-tcl
      # #{file_list}
      set flgen_defines {}
      lappend flgen_defines "#{macros[0]}"
      lappend flgen_defines "#{macros[1]}"
      set_property verilog_define $flgen_defines [current_fileset]
      set flgen_include_directories {}
      lappend flgen_include_directories "#{include_directories[0]}"
      lappend flgen_include_directories "#{include_directories[1]}"
      set_property include_dirs $flgen_include_directories [current_fileset]
      set flgen_source_files {}
      lappend flgen_source_files "#{files[0]}"
      lappend flgen_source_files "#{files[1]}"
      lappend flgen_source_files "#{files[2]}"
      add_files -fileset [current_fileset] $flgen_source_files
      TCL
      end
      end
      context '--format=filelist-xsimが指定された場合' do
      let(:output) do
      'out.f'
      end
      before do
      allow(File).to receive(:open).with(output, 'w').and_yield(io)
      end
      it 'xsim対応のfilelist形式でファイルリストを書き出す' do
      cli.run(["--output=#{output}", '--format=filelist-xsim', file_list])
      expect(io.string).to eq(<<~OUT)
      // flgen version #{FLGen::VERSION}
      // applied arguments
      // --output=#{output}
      // --format=filelist-xsim
      // #{file_list}
      -d #{macros[0]}
      -d #{macros[1]}
      -i #{include_directories[0]}
      -i #{include_directories[1]}
      -sourcelibdir #{library_directories[0]}
      -sourcelibfile #{library_files[0]}
      #{compile_arguments[0]}
      #{files[0]}
      #{files[1]}
      #{files[2]}
      OUT
      end
      end
      context '--no-print-headerが指定された場合' do
      let(:output) do
      'out.f'
      end
      before do
      allow(File).to receive(:open).with(output, 'w').and_yield(io)
      end
      it 'ヘッダーを出力しない' do
      cli.run(['--no-print-header', "--output=#{output}", file_list])
      expect(io.string).to eq(<<~OUT)
      +define+#{macros[0]}
      +define+#{macros[1]}
      +incdir+#{include_directories[0]}
      +incdir+#{include_directories[1]}
      -y #{library_directories[0]}
      -v #{library_files[0]}
      #{compile_arguments[0]}
      #{files[0]}
      #{files[1]}
      #{files[2]}
      OUT
      end
      end
      end
  • Change the base class from VivadoTCLFormatter to Formatter

@parthkalgaonkar
Copy link
Copy Markdown
Author

I had inherited from VivadoTCLFormatter since quite a lot of the functionality was common. I'll change that to Formatter. Should I add a CommonTCLFormatter to capture the common features and avoid repetition?

@taichi-ishitani
Copy link
Copy Markdown
Member

Should I add a CommonTCLFormatter to capture the common features and avoid repetition?

Yes. Put common functoins into the common tcl formatter.

@taichi-ishitani taichi-ishitani self-requested a review April 23, 2026 01:02
@taichi-ishitani taichi-ishitani added the enhancement New feature or request label Apr 23, 2026
io.puts('set flgen_defines {}')
end

def format_macro(macro, value)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is also defined in the base formatter class. Please remove it from the CommonTCLFormatter class.

def format_macro(macro, value)
end

def post_macros(io)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as format_macro method.

"lappend flgen_include_directories \"#{directory}\""
end

def post_include_directories(io)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as format_macro method.

"lappend flgen_source_files \"#{path}\""
end

def post_source_files(io)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as format_macro method.

@@ -0,0 +1,26 @@
# frozen_string_literal: true

require_relative 'common_tcl_formatter'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this like to flgen.rb.

@taichi-ishitani
Copy link
Copy Markdown
Member

@parthkalgaonkar

Thank you for adding the formatter for Genus.
I put some review comments.

I'd like to confirm if Genus can load the generated tcl file but we don't have this tool.
Can you put the log file for this?

@taichi-ishitani
Copy link
Copy Markdown
Member

taichi-ishitani commented Apr 23, 2026

By the way, Design Compile can load *.f files directly like the command below.

analyze -format sverilog -vcs "-f filelist.f"

Does not Genus have such option?

@taichi-ishitani
Copy link
Copy Markdown
Member

You can execute all unit tests by swapning rake spec command on the project root. Can you confirm all unit tests are passed before commiting your change?

@parthkalgaonkar
Copy link
Copy Markdown
Author

Yeah you are right. the genus read_rtl command already takes a -f "filelist.f argument. I used to think this did not allow macro definitions and incdir directives in the filelist. But I did some checking and turns out that is not the case.

This pull request seems redundant. I can close it, or I can make the changes you asked for and push again anyways.
Let me know what you want

@taichi-ishitani
Copy link
Copy Markdown
Member

taichi-ishitani commented Apr 23, 2026

We can't maintain Genus TCL formatter because we don't have the tool.
So I'd like you to close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants