您当前的位置:五五电子网电子知识单片机-工控设备DSP/FPGA技术Verilog HDL 实例设计程序移位寄存器 正文
Verilog HDL 实例设计程序移位寄存器

Verilog HDL 实例设计程序移位寄存器

点击数:7663 次   录入时间:03-04 11:39:27   整理:http://www.55dianzi.com   DSP/FPGA技术
//
//
//-----------------------------------------------------------------------------------
// DESCRIPTION   :  Shift register
//                  Type : univ
//                  Width : 4
//                  Shift direction: right/left (right active high)
//
//                  CLK active : high
//                  CLR active : high
//                  CLR type : synchronous
//                  SET active : high
//                  SET type : synchronous
//                  LOAD active : high
//                  CE active : high
//                  SERIAL input : SI
//
//-----------------------------------------------------------------------------------


module shft_reg (CLR , SET , DIR , CE , LOAD , DATA , SI , data_out , CLK );
input CLR , SET , CE , LOAD , DIR , SI , CLK ;
input [3:0] DATA ;
output [3:0] data_out ;



reg [3:0] TEMP;

	always @(posedge CLK )
	begin
		if (CE == 1'b1)
			if (CLR == 1'b1)
				TEMP = {4{1'b0}};
			else if (SET == 1'b1)
				TEMP = {4{1'b1}};
			else if (LOAD == 1'b1)
				TEMP = DATA ;
			else if (DIR == 1'b1)
				TEMP = {SI , TEMP [3:1]};
			else
				TEMP = {TEMP [2:0], SI };
	end

	assign data_out = TEMP;
endmodule




本文关键字:寄存器  设计程序  DSP/FPGA技术单片机-工控设备 - DSP/FPGA技术