submod - moving part of a module to a new submodule

yosys> help submod
submod [options] [selection]
This pass identifies all cells with the 'submod' attribute and moves them to
a newly created module. The value of the attribute is used as name for the
cell that replaces the group of cells with the same attribute value.

This pass can be used to create a design hierarchy in flat design. This can
be useful for analyzing or reverse-engineering a design.

This pass only operates on completely selected modules with no processes
or memories.
-copy
by default the cells are 'moved' from the source module and the source
module will use an instance of the new module after this command is
finished. call with -copy to not modify the source module.
-name <name>
don't use the 'submod' attribute but instead use the selection. only
objects from one module might be selected. the value of the -name option
is used as the value of the 'submod' attribute instead.
-hidden
instead of creating submodule ports with public names, create ports with
private names so that a subsequent 'flatten; clean' call will restore
the original module with original public names.