fusesoc icon indicating copy to clipboard operation
fusesoc copied to clipboard

how to add filesets from another file?

Open davideschiavone opened this issue 3 years ago • 2 comments

Dear all,

I have a top .core file as:

filesets:
  files_rtl_generic:
    depend:
    - verynice_submodule:submodule
    files:
    - hw/mytoplevel.sv
    file_type: systemVerilogSource
 
  tb-verilator:
    files:
    - tb/tb_top.cpp
    file_type: cppSource
    
   
targets:
  default: &default_target
    filesets:
    - files_rtl_generic
    toplevel: [mytoplevel]

  sim:
    <<: *default_target
    default_tool: verilator
    filesets_append:
    - tb-verilator
    toplevel:
    - [mytoplevel]
    tools:
      verilator:
        mode: cc
        verilator_options:
          - '--cc'
          - '--exe tb_top.cpp'

The verynice_submodule:submodule core file looks similar, as:

filesets:
  files_rtl_generic:
    files:
    - hw/my_synchgate.sv
    - hw/my_wrapper.sv
    file_type: systemVerilogSource

  files_clk:
    files:
    - hw/my_clkprescaler.sv
    file_type: systemVerilogSource
 
  tb-verilator:
    files:
    - tb/tb_top.cpp
    file_type: cppSource
    
   
targets:
  default: &default_target
    filesets:
    - files_rtl_generic
    toplevel: [my_wrapper]

  sim:
    <<: *default_target
    default_tool: verilator
    filesets_append:
    - files_clk
    - tb-verilator
    toplevel:
    - [my_wrapper]
    tools:
      verilator:
        mode: cc
        verilator_options:
          - '--cc'
          - '--exe tb_top.cpp'

In the top .core, I don't see the my_clkprescaler.sv file, I only see the default files as my_synchgate.sv and my_wrapper.sv.

I guess this is because when including .core files, it only appends the filesets specified in default when using *default_target as I have done.

Do you have any idea how I can include the verynice_submodule:submodule 's files_clk file set in my top module?

One solution can be just re-defining them in the top module, but I was looking for a cleaner way of doing it.

Maybe something like

  filesets_append:
  - verynice_submodule:submodule:files_clk

or anything else it comes to your mind would be appreciated.

Thanks a lot, Davide

davideschiavone avatar Jul 04 '22 08:07 davideschiavone

Break it out into it's own core file and call it as a dependency. Anything you want to reuse should probably be in its own core file. The alternate is to use flags to include it in the default, so your verynice_submodule:submodule would look like:

targets:
  default: &default_target
    filesets:
      - files_rtl_generic
      - target_sim ? (files_clk)

Or some other flag you've passed on the command line. I think @olofk was somewhere in the middle of implementing flags that can be set by targets?

shareefj avatar Jul 04 '22 11:07 shareefj

thanks a lot, indeed what you proposed works just fine. Also, the idea of splitting the .core files is probably even nicer.

Thanks a lot

I leave the issue open for @olofk to comment about the flags

davideschiavone avatar Jul 04 '22 13:07 davideschiavone

Yes. Setting flags works now, but it's still missing some convenience features. I took the opportunity to expand a bit on the flags documentation here. Hope this clears things up https://fusesoc.readthedocs.io/en/latest/user/build_system/flags.html

olofk avatar Oct 16 '22 14:10 olofk