// Quartus II Verilog Template
// Basic 64-stage shift register with multiple taps

module basic_shift_register_with_multiple_taps
#(parameter WIDTH=8, parameter LENGTH=64)
(
	input clk, enable,
	input [WIDTH-1:0] sr_in,
	output [WIDTH-1:0] sr_tap_one, sr_tap_two, sr_tap_three, sr_out
);

	// Declare the shift register
	reg [WIDTH-1:0] sr [LENGTH-1:0];

	// Declare an iterator
	integer n;

	always @ (posedge clk)
	begin
		if (enable == 1'b1)
		begin
			// Shift everything over, load the incoming data
			for (n = LENGTH-1; n>0; n = n-1)
			begin
				sr[n] <= sr[n-1];
			end

			// Shift one position in
			sr[0] <= sr_in;
		end
	end

	assign sr_tap_one = sr[LENGTH/4-1];
	assign sr_tap_two = sr[LENGTH/2-1];
	assign sr_tap_three = sr[3*LENGTH/4-1];

	// Catch the outgoing data
	assign sr_out = sr[LENGTH-1];

endmodule

 

相关文章:

  • 2021-11-28
  • 2021-10-04
  • 2021-06-05
  • 2022-12-23
  • 2021-11-28
  • 2021-08-08
  • 2022-12-23
  • 2021-09-13
猜你喜欢
  • 2021-10-15
  • 2021-05-01
  • 2021-11-28
  • 2021-07-02
相关资源
相似解决方案