本文主要是介绍序列发生器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 一开始想直接FSM,划分出6状态依次输出对应的。
- 但其实只要6比特的移位寄存器,每次输出高位。复位后的默认值时6’b001_011。这样就可以实现循环,这种移位寄存器也叫barrel_shifter。循环移位。
- 也可以使用循环计数器,然后case计数器输出对应的比特流。本质和FSM一样。
- 所以循环左移和循环寄存器主要体现思想是循环,然后循环到哪个阶段输出哪个比特。
`timescale 1ns/1nsmodule sequence_generator(input clk,input rst_n,output reg data);reg [5:0] seq_dat;always @(posedge clk or negedge rst_n)
begin if(!rst_n) begin seq_dat <= 6'b001_011;end else begin seq_dat <= {seq_dat[4:0],seq_dat[5]};end
end always @(posedge clk or negedge rst_n)
begin if(!rst_n) begin data <= 1'b0;end else begin data <= seq_dat[5];end
end endmodule
这篇关于序列发生器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!