module wb_io(
input clk,
input[1:0] d,
output [1:0]q
);
regs #(2,4)regs(
.clk(clk),
.d(d),
.q(q)
);
endmodule
module regs
#(parameter DATA_WIDTH=1,
parameter DATA_LEN=1)(
input clk,
input [DATA_WIDTH-1:0] d,
output [DATA_WIDTH-1:0] q
);
genvar i;
generate
for(i=0;i<DATA_LEN;i=i+1)
begin : gen16
reg [DATA_WIDTH-1:0]R;
always @ (posedge clk)
if (i==0)R<=d;
else
R<=gen16[i-1].R;
end
endgenerate
assign q = gen16[i-1].R;
endmodule
module regs#(parameter DATA_WIDTH=1,parameter DATA_LEN=1) (
input clk,
input [DATA_WIDTH-1:0] d,
output [DATA_WIDTH-1:0] q
);
reg [DATA_WIDTH-1:0]R [ DATA_LEN - 1:0];
genvar i;
generate
for(i=0;i<DATA_LEN;i=i+1)
begin : genN
always @ (posedge clk)
if (i==0)R[0]<=d;
else
R[i]<=R[i-1];
end
endgenerate
assign q = R[ DATA_LEN - 1 ];
endmodule
input clk,
input[1:0] d,
output [1:0]q
);
regs #(2,4)regs(
.clk(clk),
.d(d),
.q(q)
);
endmodule
module regs
#(parameter DATA_WIDTH=1,
parameter DATA_LEN=1)(
input clk,
input [DATA_WIDTH-1:0] d,
output [DATA_WIDTH-1:0] q
);
genvar i;
generate
for(i=0;i<DATA_LEN;i=i+1)
begin : gen16
reg [DATA_WIDTH-1:0]R;
always @ (posedge clk)
if (i==0)R<=d;
else
R<=gen16[i-1].R;
end
endgenerate
assign q = gen16[i-1].R;
endmodule
input clk,
input [DATA_WIDTH-1:0] d,
output [DATA_WIDTH-1:0] q
);
reg [DATA_WIDTH-1:0]R [ DATA_LEN - 1:0];
genvar i;
generate
for(i=0;i<DATA_LEN;i=i+1)
begin : genN
always @ (posedge clk)
if (i==0)R[0]<=d;
else
R[i]<=R[i-1];
end
endgenerate
assign q = R[ DATA_LEN - 1 ];
endmodule