add sequence_generate.v

This commit is contained in:
yunlongLi 2024-10-31 22:00:17 +08:00
parent b2ad5ac5c2
commit 68cab595e2
2 changed files with 84 additions and 1 deletions

View File

@ -0,0 +1,84 @@
//==========================================================
//--Author : colonel
//--Date : 10-31
//--Module : sequence_generate_fsm
//--Function: generate sequence using fsm
//==========================================================
module sequence_generate_fsm(
//==========================< ports >=========================
input wire clk,
input wire rst_n,
output wire seq_out
);
//==========================< paramter >=========================
localparam IDLE = 4'b0001;
localparam S0 = 4'b0010;
localparam S1 = 4'b0100;
localparam S2 = 4'b1000;
//==========================< Signal >=========================
reg [4 -1:0] cur_sta;
reg [4 -1:0] nxt_sta;
//=========================================================
//-- fsm-1: state transition
//=========================================================
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
cur_sta <= IDLE;
end else begin
cur_sta <= nxt_sta;
end
end
//=========================================================
//-- fsm-2: state jump condition
//=========================================================
always @(*) begin
if (!rst_n) begin
nxt_sta = IDLE;
end else begin
case (cur_sta)
IDLE: nxt_sta = S0;
S0 : nxt_sta = S1;
S1 : nxt_sta = S2;
S2 : nxt_sta = IDLE;
default: ;
endcase
end
end
endmodule
//==========================================================
//--Author : colonel
//--Date : 10-31
//--Module : sequence_generate_shiftReg
//--Function: generate sequence using fsm
//==========================================================
module sequence_generate_shiftReg (
//==========================< ports >=========================
input wire clk,
input wire rst_n,
output wire seq_out
);
//==========================< Signal >=========================
reg [4 -1:0] sequence;
//=========================================================
//-- sequence: shift_reg
//=========================================================
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
sequence <= 4'b1001;
end else begin
sequence <= {sequence[2:0],sequence[3]};
end
end
//=========================================================
//-- seq_out
//=========================================================
assign seq_out = sequence[3];
endmodule

View File

@ -4,7 +4,6 @@
//--Module : sync_fifo_cnt
//--Function: the sync_fifo logic using cnt way
//==========================================================
module sync_fifo_cnt_way #(
//==========================< 参数 >=========================
parameter DATA_WIDTH = 8,