|
|
|
|
|
|
|
|
|
|
|
|
Random Counter (LFSR)
|
|
|
|
|
|
1 //-----------------------------------------------------
2 // Design Name : lfsr
3 // File Name : lfsr.sv
4 // Function : Linear feedback shift register
5 // Coder : Deepak Kumar Tala
6 //-----------------------------------------------------
7 module lfsr (
8 output reg [7:0] out , // Output of the counter
9 input wire enable , // Enable for counter
10 input wire clk , // clock input
11 input wire reset // reset input
12 );
13 //------------Internal Variables--------
14 wire linear_feedback;
15 //-------------Code Starts Here-------
16 assign linear_feedback = ! (out[7] ^ out[3]);
17
18 always_ff @(posedge clk)
19 if (reset) begin // active high reset
20 out <= 8'b0 ;
21 end else if (enable) begin
22 out <= {out[6],out[5],
23 out[4],out[3],
24 out[2],out[1],
25 out[0], linear_feedback};
26 end
27
28 endmodule // End Of Module counter
You could download file sv_examples here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|