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

Subversion Repositories csa

[/] [csa/] [trunk/] [quartus10/] [ledseg_cnt.v] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 33 simon111
 
2
 
3
 
4
// this file control led segment controler module
5
 
6
 
7
module ledseg_cnt(
8
                         input               clk        // clock
9
                       , input               rst        // reset , high active
10
                       , input      [15:0]   data       // the data want output at led segment
11
                       , output reg [ 3:0]   seg        // led segment scan signal
12
                       , output     [ 7:0]   segd       // led segment output
13
                );
14
 
15
 
16 38 simon111
`define CNT_W 15    // count reg width
17
 
18 33 simon111
        // interival variable
19
        reg [`CNT_W-1:0] cnt;
20
 
21
        always @(posedge clk)
22 38 simon111
                cnt<=cnt+`CNT_W'h1;      // up reg
23 33 simon111
 
24 38 simon111
        reg [3:0] h;
25 33 simon111
        always @(cnt or data)
26
        begin
27
                case (cnt[`CNT_W-1:`CNT_W-2])
28 38 simon111
                        2'b00:h <= data[15:12];
29
                        2'b01:h <= data[11: 8];
30
                        2'b10:h <= data[ 7: 4];
31
                        2'b11:h <= data[ 3: 0];
32 33 simon111
                endcase
33
        end
34
 
35
        always @(cnt)
36
        begin
37
                case (cnt[`CNT_W-1:`CNT_W-2])
38
                        2'b00:seg = 4'b1110;
39
                        2'b01:seg = 4'b1101;
40
                        2'b10:seg = 4'b1011;
41
                        2'b11:seg = 4'b0111;
42
                endcase
43
        end
44
 
45
        hex2seg h2s(
46
                  .hex(h)
47
                , .seg(segd)
48
                );
49
 
50
 
51
endmodule

powered by: WebSVN 2.1.0

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