1

I am having problem partitioning my top module using using submod command.

I have a simple counter (I have a behavioral code for a 4bit counter). with the following cells in it:

yosys> select -list
counter
counter/$procmux$4_Y
counter/$add$counter.v:10$2_Y
counter/$0\count[3:0]
counter/count
counter/en
counter/rst
counter/clk
counter/$procdff$9
counter/$procmux$7
counter/$procmux$4
counter/$add$counter.v:10$2

Now I want to put the following cells into a submodule:

counter/$procdff$9
counter/$procmux$7

I do not know how to use select, setattr, submod to do so. Any help is greatly appreciated.

Thank you


verilog code for my counter:

module module counter (clk, rst, en, count);
input clk, rst, en;
output reg [3:0] count;   
always @(posedge clk)
  if (rst)
     count <= 4'd0;
  else if (en)
     count <= count + 4'd1;
endmodule
Mehrdad
  • 107
  • 8

1 Answers1

1

I figured it out:

first I select the cells, then put them into the partition that I want:

yosys> select counter/$procmux$4
yosys*> select -add counter/$procmux$7
yosys*> select -add counter/$add$counter.v:10$2
yosys*> submod -name sub_2

yosys> select counter/$procmux$4_Y
yosys*> select -add counter/$add$counter.v:10$2_Y
yosys*> select -add counter/$0\count[3:0]
yosys*> select -add counter/count
yosys*> select -add counter/$procdff$9
submod -name sub_1

please let me know if there is a better way. Thank you

Mehrdad
  • 107
  • 8
  • 1
    Looks good to me. See `help select` for more sophisticated ways of selecting objects, if you want to avoid enumerating them all. – CliffordVienna May 14 '16 at 10:43