OpenCores
URL https://opencores.org/ocsvn/logicprobe/logicprobe/trunk

Subversion Repositories logicprobe

[/] [logicprobe/] [trunk/] [tst/] [boards/] [XESS-XST-3S1000/] [lfsr128.v] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 hellwig
//
2
// lfsr128.v -- a linear feedback shift register with 128 bits
3
//              (actually constructed from 4 instances of a 32-bit lfsr)
4
//
5
 
6
 
7
module lfsr128(clk, reset_in_n, s, rs232_txd);
8
    input clk;
9
    input reset_in_n;
10
    output [3:0] s;
11
    output rs232_txd;
12
 
13
  wire reset;
14
  reg [23:0] reset_counter;
15
 
16
  reg [31:0] lfsr0;
17
  reg [31:0] lfsr1;
18
  reg [31:0] lfsr2;
19
  reg [31:0] lfsr3;
20
 
21
  wire trigger;
22
  wire sample;
23
  wire [127:0] log_data;
24
 
25
  assign reset = (reset_counter == 24'hFFFFFF) ? 0 : 1;
26
  always @(posedge clk) begin
27
    if (reset_in_n == 0) begin
28
      reset_counter <= 24'h000000;
29
    end else begin
30
      if (reset_counter != 24'hFFFFFF) begin
31
        reset_counter <= reset_counter + 1;
32
      end
33
    end
34
  end
35
 
36
  always @(posedge clk) begin
37
    if (reset == 1) begin
38
      lfsr0 <= 32'hC70337DB;
39
      lfsr1 <= 32'h7F4D514F;
40
      lfsr2 <= 32'h75377599;
41
      lfsr3 <= 32'h7D5937A3;
42
    end else begin
43
      if (lfsr0[0] == 0) begin
44
        lfsr0 <= lfsr0 >> 1;
45
      end else begin
46
        lfsr0 <= (lfsr0 >> 1) ^ 32'hD0000001;
47
      end
48
      if (lfsr1[0] == 0) begin
49
        lfsr1 <= lfsr1 >> 1;
50
      end else begin
51
        lfsr1 <= (lfsr1 >> 1) ^ 32'hD0000001;
52
      end
53
      if (lfsr2[0] == 0) begin
54
        lfsr2 <= lfsr2 >> 1;
55
      end else begin
56
        lfsr2 <= (lfsr2 >> 1) ^ 32'hD0000001;
57
      end
58
      if (lfsr3[0] == 0) begin
59
        lfsr3 <= lfsr3 >> 1;
60
      end else begin
61
        lfsr3 <= (lfsr3 >> 1) ^ 32'hD0000001;
62
      end
63
    end
64
  end
65
 
66
  assign s[3] = lfsr0[27];
67
  assign s[2] = lfsr1[13];
68
  assign s[1] = lfsr2[23];
69
  assign s[0] = lfsr3[11];
70
 
71
  assign trigger = (lfsr0 == 32'h7119C0CD) ? 1 : 0;
72
  assign sample = 1;
73
  assign log_data = { lfsr0, lfsr1, lfsr2, lfsr3 };
74
  LogicProbe lp(clk, reset, trigger, sample, log_data, rs232_txd);
75
 
76
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.