题解 | #序列发生器#

序列发生器

https://www.nowcoder.com/practice/1fe78a981bd640edb35b91d467341061

`timescale 1ns/1ns

module sequence_generator(
	input clk,
	input rst_n,
	output reg data
	);

//计数
reg [2:0] cnt ;
always@(posedge clk or negedge rst_n) begin
	if(!rst_n)
		cnt <= 'd0;
	else if (cnt == 'd5)
		cnt <= 'd0 ;
	else 
		cnt <= cnt + 'd1 ;
end

always@(posedge clk or negedge rst_n) begin
	if(!rst_n)
		data <= 'd0;
	else 
		case(cnt)
			'd0: data <= 0;
			'd1: data <= 0;
			'd2: data <= 1;
			'd3: data <= 0;
			'd4: data <= 1;
			'd5: data <= 1;
			default: data <= 'd0;
		endcase
end

endmodule

全部评论

相关推荐

点赞 评论 收藏
分享
码农索隆:有点耳熟,你们是我教过最差的一届
点赞 评论 收藏
分享
陆续:不可思议 竟然没那就话 那就我来吧 :你是我在牛客见到的最美的女孩
点赞 评论 收藏
分享
Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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