`timescale 1ns/1ns
module s_to_p(
input clk ,
input rst_n ,
input valid_a ,
input data_a ,
output reg ready_a ,
output reg valid_b ,
output reg [5:0] data_b
);
reg [5:0]data;
reg [3:0]cnt;
always@(posedge clk or negedge rst_n)begin
if(~rst_n) ready_a <= 0;
else ready_a <= 1;
end
always @ (posedge clk or negedge rst_n)begin
if (~rst_n) begin
valid_b<=1'b0;
data_b<=5'b0;
cnt<=4'b0;
data<=6'b0;
end
else if (valid_a&& ready_a) begin
if (cnt==4'd5)begin
cnt<=4'b0;
valid_b<=1'b1;
data_b<={data_a,data[5:1]};
end
else begin
data<={data_a,data[5:1]};
cnt<=cnt+4'b1;
data_b<=data_b;
valid_b<=1'b0;
end
end
end
endmodule
module s_to_p(
input clk ,
input rst_n ,
input valid_a ,
input data_a ,
output reg ready_a ,
output reg valid_b ,
output reg [5:0] data_b
);
reg [5:0]data;
reg [3:0]cnt;
always@(posedge clk or negedge rst_n)begin
if(~rst_n) ready_a <= 0;
else ready_a <= 1;
end
always @ (posedge clk or negedge rst_n)begin
if (~rst_n) begin
valid_b<=1'b0;
data_b<=5'b0;
cnt<=4'b0;
data<=6'b0;
end
else if (valid_a&& ready_a) begin
if (cnt==4'd5)begin
cnt<=4'b0;
valid_b<=1'b1;
data_b<={data_a,data[5:1]};
end
else begin
data<={data_a,data[5:1]};
cnt<=cnt+4'b1;
data_b<=data_b;
valid_b<=1'b0;
end
end
end
endmodule