题解 | #数据串转并电路#

数据串转并电路

https://www.nowcoder.com/practice/6134dc3c8d0741d08eb522542913583d

`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_6b ,count;
always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		ready_a <= 1'b0 ;
	end
	else begin
		ready_a <= 1'b1 ;
	end
end
always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		data_6b <= 6'b0 ;
	end
	else if(valid_a) begin
		data_6b <= {data_a , data_6b[5:1]} ;
	end
	else begin
		data_6b <= data_6b ;
	end
end
always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		data_b <= 6'b0 ;
	end
	else if(count == 6'd5) begin
		data_b <= {data_a , data_6b[5:1]} ;
	end
	else begin
		data_b <= data_b ;
	end
end
always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		count <= 6'b0 ;
	end
	else if(count == 6'd5) begin
		count <=6'b0  ;
	end
	else if(valid_a) begin
		count <=count + 1'b1  ;
	end
	else begin
		count <= count ;
	end
end
always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		valid_b <= 1'b0 ;
	end
	else if(count == 6'd5) begin
		valid_b <= 1'b1 ;
	end
	else begin
		valid_b <= 1'b0  ;
	end
end
endmodule

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 12:10
点赞 评论 收藏
分享
半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
缒梦&独舞:这家公司是这样的,去年给我实习offer了,不过也是面着玩儿的,他周六还要去做公益志愿活动
点赞 评论 收藏
分享
找到实习了&nbsp;给了150一天&nbsp;但是说是低代码&nbsp;值得去吗
码农索隆:是在没实习,可去,待个一两周,不行就润呗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务