题解 | #序列发生器#

序列发生器

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) begin
			cnt <= 0;
		end
		else begin
			cnt <= (cnt == 3'd5)? 0: cnt + 1'b1;
		end
	end

	always @(posedge clk or negedge rst_n) begin
		if(!rst_n) begin
			data <= 0;
		end
		else begin
			case(cnt) 
				0: data <= 0;
				1: data <= 0;
				2: data <= 1;
				3: data <= 0;
				4: data <= 1;
				5: data <= 1;
				default: data <= 0;
			endcase
		end
	end*/
	


	reg [5:0] data_in_reg;
	always @(posedge clk or negedge rst_n) begin
		if(!rst_n) begin
			data_in_reg <= 6'b001011;
		end
		else begin
			data_in_reg <= {data_in_reg[4:0],data_in_reg[5]};
		end
	end
	
	always @(posedge clk or negedge rst_n) begin
		if(!rst_n) begin
			data <= 0;
		end
		else begin
			data <= data_in_reg[5];
		end
	end

endmodule

全部评论

相关推荐

湫湫湫不会java:写的很杂,连自己都不知道找什么工作的感觉,只是要份工作。针对自己稍微有点优势的方向好好整份简历投投吧,然后这杂的简历就辅助投投,因为自己认为的优势可能也不是很大的优势all in可能失业,自己也没有啥很想的方向还是可以用这通用的碰碰运气吧,加油
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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