//*******************************************************************************//
//根据腾讯课堂至-FPGA从入门到实战-上海V3学院中学习写出,代码来源与此,注释由自己所写
//*******************************************************************************//
//串并转换,移位寄存器(左移右移)
module ex_shift_reg(
input wire lvds_clk,//标准的查分信号的时钟
input wire rst_n,
input wire lvds_d,//输入信号
output reg [7:0] o_lvds_d//输出信号
);
reg [7:0] shift_reg;//用于存储串转并的数据
reg [2:0] s_cnt;
reg s_flag;//采样标志,以组合逻辑实现
reg s_flag_dly1,s_flag_dly2;
//位拼接符 {7'b1010_000,3'b010}--->10'b1010_000_010;等效的,
//数据之间的下划线无意义,只是为了增加可读性
always @(posedge lvds_clk or negedge rst_n)
begin
if(rst_n == 1'b0)
shift_reg <= 8'd0;//返回32位的0也可以,这里是不是用8’b0更好;
else
shift_reg <= shift_reg>>1;//>>右移一位
shift_reg[7] <= lvds_d;
//shift_reg <= {lvds_d,shift_reg[7:1]};//右移位寄存器,两种写法