题解 | #序列发生器#
序列发生器
https://www.nowcoder.com/practice/1fe78a981bd640edb35b91d467341061
`timescale 1ns/1ns module sequence_generator( input clk, input rst_n, output reg data ); //参数化要循环输出的序列 parameter NUEMBER = 6'b001011; //使用计数器控制循环 reg [2:0] cnt; always@(posedge clk or negedge rst_n) if(!rst_n) cnt <= 3'd0; else if(cnt == 3'd5) cnt <= 3'd0; else cnt <= cnt + 3'd1; //利用计数器数值和输出序列位数的关系 always@(posedge clk or negedge rst_n) if(!rst_n) data <= 1'd0; else data <= NUEMBER[5-cnt]; endmodule