数字逻辑电路基础-时序逻辑电路之移位寄存器

文章目录


一、移位寄存器定义

移位寄存器定义

A shift register is a type of digital circuit using a cascade of flip flops where the output of one flip-flop is connected to the input of the next.

移位寄存器是一种将一组D触发器进行级联输出而形成的一种时序逻辑电路。

在设计中经常会用到的一种基础时序电路,比如下面串转并电路,通过将串行输入的码流移位将其转换成并行数据输出。

本文设计一个简单的串并转换器,实现将串行输入数据转换成8位的并行数据进行输出,同时输出一个转换完成标志。


二、verilog源码

c 复制代码
// implement a simple 8bit serial to paralle convertor

module s2p_demo (clk, rstn, din, dout, done);
	input clk;
	input rstn;
	input din;
	output [7:0] dout;
	output done;
	
	reg [2:0] cnt;
	reg done;
	reg done_dly;
	reg [7:0] dout;
	reg [7:0] dout_dly;
	
	always@(posedge clk or negedge rstn)
	begin
		if(!rstn) begin
			dout_dly <= 8'bx; end
		else begin
			dout_dly[cnt] <= din; end
	end
	
	always@(posedge clk or negedge rstn)
	begin
		if(!rstn) begin
			dout <= 8'b0; end
		else if(done_dly) begin
			dout <= dout_dly;
			done <= done_dly; end
		else begin
			dout <= 8'b0;
			done <= done_dly; end
	end
	
	always@(posedge clk or negedge rstn)
	begin
		if(!rstn) begin
			cnt <= 3'b0;
			done_dly <= 1'b0; end
		else if(cnt == 3'b111) begin
			cnt <= 3'b0;
			done_dly <= 1'b1; end
		else begin
			cnt <= cnt + 1'b1;
			done_dly <= 1'b0;
		end
	end
endmodule

三、仿真结果


转载请注明出处!

相关推荐
szxinmai主板定制专家3 分钟前
【飞腾AI加固服务器】全国产化飞腾+昇腾310+PCIe Switch的AI大模型服务器解决方案
运维·服务器·arm开发·人工智能·fpga开发
GateWorld13 分钟前
《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析 (三)数据格式
fpga开发·mipi csi2
hahaha60164 小时前
FPGA静态功耗
fpga开发
碎碎思4 小时前
FPGA定点和浮点数学运算-实例对比
fpga开发
GateWorld15 小时前
《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析LLP (二)
fpga开发·mipi csi2
hahaha60161 天前
Xilinx 325T FPGA 中的 GT(GTP 或 GTX)收发器和普通 LVDS 接口的差模和共模电压
fpga开发
hahaha60161 天前
FPGA没有使用的IO悬空对漏电流有没有影响
fpga开发
贝塔实验室2 天前
FPGA 动态重构配置流程
驱动开发·fpga开发·硬件架构·硬件工程·射频工程·fpga·基带工程
GateWorld2 天前
《从零掌握MIPI CSI-2: 协议精解与FPGA摄像头开发实战》-- CSI-2 协议详细解析 (一)
fpga开发·mipi csi2
思尔芯S2C2 天前
思尔芯携手Andes晶心科技,加速先进RISC-V 芯片开发
人工智能·科技·fpga开发·risc-v·debugging·prototyping·soc validation