diff options
Diffstat (limited to 'tests/various/dynamic_part_select/forloop_select.v')
-rw-r--r-- | tests/various/dynamic_part_select/forloop_select.v | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/various/dynamic_part_select/forloop_select.v b/tests/various/dynamic_part_select/forloop_select.v new file mode 100644 index 000000000..8260f3186 --- /dev/null +++ b/tests/various/dynamic_part_select/forloop_select.v @@ -0,0 +1,19 @@ +module forloop_select #(parameter WIDTH=16, SELW=4, CTRLW=$clog2(WIDTH), DINW=2**SELW) + (input clk, + input [CTRLW-1:0] ctrl, + input [DINW-1:0] din, + input en, + output reg [WIDTH-1:0] dout); + + reg [SELW:0] sel; + localparam SLICE = WIDTH/(SELW**2); + + always @(posedge clk) + begin + if (en) begin + for (sel = 0; sel <= 4'hf; sel=sel+1'b1) + dout[(ctrl*sel)+:SLICE] <= din; + end + end +endmodule + |