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

Subversion Repositories statled

[/] [statled/] [trunk/] [rtl/] [statled.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 mitko
//////////////////////////////////////////////////////////////////////
2
////  statled.v                                                   ////   
3
////                                                              ////
4
////  This file is part of the Status LED module.                 ////
5
////  http://www.opencores.org/projects/statled/                  ////
6
////                                                              ////
7
////  Author:                                                     ////
8
////     -Dimitar Dimitrov, d.dimitrov@bitlocker.eu               ////
9
////                                                              ////
10
//////////////////////////////////////////////////////////////////////
11
////                                                              ////
12
//// Copyright (C) 2010 Authors                                   ////
13
////                                                              ////
14
//// This source file may be used and distributed without         ////
15
//// restriction provided that this copyright statement is not    ////
16
//// removed from the file and that any derivative work contains  ////
17
//// the original copyright notice and the associated disclaimer. ////
18
////                                                              ////
19
//// This source file is free software; you can redistribute it   ////
20
//// and/or modify it under the terms of the GNU Lesser General   ////
21
//// Public License as published by the Free Software Foundation; ////
22
//// either version 2.1 of the License, or (at your option) any   ////
23
//// later version.                                               ////
24
////                                                              ////
25
//// This source is distributed in the hope that it will be       ////
26
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
27
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
28
//// PURPOSE.  See the GNU Lesser General Public License for more ////
29
//// details.                                                     ////
30
////                                                              ////
31
//// You should have received a copy of the GNU Lesser General    ////
32
//// Public License along with this source; if not, download it   ////
33
//// from http://www.opencores.org/lgpl.shtml                     ////
34
////                                                              ////
35
//////////////////////////////////////////////////////////////////////
36
 
37 2 mitko
`timescale 1ns / 100ps
38 6 mitko
 
39 2 mitko
module statled (
40 4 mitko
    input           clk,
41
    input           rst,
42
    input  [3:0]    status,
43
    output          led
44 2 mitko
);
45
 
46
`include "statled_par.v"
47
 
48 3 mitko
reg [32:0]       pre;            // Prescaler
49
reg [7:0]        bcnt;           // Bit counter
50
reg [15:0]       lsr;            // LED shift register 
51
reg [15:0]       cr;             // Code register
52
reg [3:0]        str;            // Status register
53
wire            rate;           // LED rate
54 2 mitko
 
55 6 mitko
//--------------------------------------------------------------------
56 2 mitko
// LED rate  
57
//
58
always @(posedge clk or posedge rst)
59 6 mitko
    if (rst)
60 3 mitko
        pre <= #tDLY 0;
61 2 mitko
    else if (rate)
62 3 mitko
        pre <= #tDLY 0;
63 2 mitko
    else
64 3 mitko
        pre <= #tDLY pre + 1;
65 2 mitko
 
66
assign rate = (pre == STATLED_PULSE_CLKCNT);
67
 
68 6 mitko
//--------------------------------------------------------------------
69 2 mitko
// Capture status inputs
70
//
71
always @(posedge clk or posedge rst)
72 5 mitko
    if (rst)
73 3 mitko
        str <= #tDLY 0;
74 2 mitko
    else
75 3 mitko
        str <= #tDLY status;
76 2 mitko
 
77 6 mitko
//--------------------------------------------------------------------
78 2 mitko
// Shift register and bit counter
79
//
80
always @(posedge clk or posedge rst)
81 5 mitko
    if (rst)
82 3 mitko
        bcnt <= #tDLY 15;
83 5 mitko
    else if (bcnt == 16)
84 3 mitko
        bcnt <= #tDLY 0;
85 5 mitko
    else if (rate)
86 3 mitko
        bcnt <= #tDLY bcnt + 1;
87 2 mitko
 
88
always @(posedge clk or posedge rst)
89 5 mitko
    if (rst)
90 3 mitko
        lsr <= #tDLY 0;
91 5 mitko
    else if (bcnt == 16)
92 3 mitko
        lsr <= #tDLY cr;
93 5 mitko
    else if (rate)
94 3 mitko
        lsr <= #tDLY lsr << 1;
95 2 mitko
 
96
assign led = rst? 1 : lsr[15];
97
 
98 6 mitko
//--------------------------------------------------------------------
99 2 mitko
// Codes 
100
//
101
always @*
102
    case(str)
103 4 mitko
        0: cr = CODE_50_50;           // Default code
104
        1: cr = CODE_ONE;             // State 1 
105
        2: cr = CODE_TWO;             // State 2
106
        3: cr = CODE_THREE;           // ....
107
        4: cr = CODE_FOUR;            //
108
        5: cr = CODE_FIVE;            //
109
        6: cr = CODE_SIX;             //
110
 
111
        default: cr = 0;
112
    endcase
113 2 mitko
 
114
endmodule

powered by: WebSVN 2.1.0

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