像这样的东西?
module scheduler
#( parameter K = 10 )
(
input wire [K:1] current,
input wire [K:1] mask,
output reg [K:1] next
);
reg [K:1] a;
reg [K:1] b;
//'[i+1]' busses that wrap.
// eg, for a 4-bit bus...
// a[i]: a[4],a[3],a[2],a[1] (obviously...)
// a_wrap[i]: a[1],a[4],a[3],a[2]
wire [K:1] mask_wrap = { mask[1],mask[K:2] };
wire [K:1] a_wrap = { a[1], a[K:2] };
wire [K:1] current_wrap = { current[1], current[K:2] };
integer i;
always @( * ) begin
for( i=1; i<=K; i=i+1 ) begin
a[i] = ~current_wrap[i] && b[i];
b[i] = a_wrap[i] || mask_wrap[i];
next[i] = ~a[i] && mask_wrap[i];
end
end
endmodule
(免责声明:棉绒但不是模拟的)