本帖最后由 dongdong521 于 2013-11-27 13:57 编辑
32位串入并出移位寄存器
系统时钟clk_50M(频率50M),clk1移位时钟(周期10US),data数据
reg clk1,data1,data_rst1;
always@(posedge clk_50M or negedge rst_n )
begin
if (!rst_n)
begin
clk1<=0;
data1<=0;
end
else
begin
clk1<=clk;
data1<=data;
data_rst<=data_rst;
end
end
reg[31:0] reg_cmd;
always@(posedge clk_50M or negedge rst_n)
begin
if (!rst_n)
begin
cnt[5:0]<=0;
end
else
begin
if (data_rst1==0 && data_rst==1)
begin
cnt[5:0]<=5'b0;
end
else if (!data_rst)
begin
if (cnt[5:0]<33)
begin
if (clk==0 && clk1==1)
begin
cnt[5:0]<=cnt[5:0]+1'b1;
end
else if (clk==1 && clk1==0)
begin
reg_cmd[0]<=data;
reg_cmd[31:1]<=reg_cmd[30:0];
end
end
end
end
end
|