题解 | #序列发生器#

序列发生器

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

`timescale 1ns/1ns

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

	reg [5:0] buffer ;
	reg [2:0] cnt    ;

    always@(posedge clk or negedge rst_n)begin
        if(!rst_n)
	        buffer <= 6'b001011 ;
        else 
		    buffer <= buffer    ;
	end

	always@(posedge clk or negedge rst_n)begin
        if(!rst_n)
	        cnt <= 'd5          ;
        else if(cnt == 'd0)
		    cnt <= 'd5          ;
	    else 
		    cnt <= cnt - 1'd1   ;
	end

	always@(posedge clk or negedge rst_n)begin
        if(!rst_n)
	        data <= 'd0          ;
        else 
		    data <= buffer[cnt]  ;
	end

endmodule

全部评论

相关推荐

仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
点赞 评论 收藏
分享
07-18 10:39
门头沟学院 Java
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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