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

Subversion Repositories rtf68ksys

[/] [rtf68ksys/] [trunk/] [rtl/] [verilog/] [seven_seg.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
// (C) 2005-2011 Robert Finch
3
// All Rights Reserved.
4
//
5
//      seven_seg.v
6
//          Seven segment display driver.
7
//
8
// This source file is free software: you can redistribute it and/or modify 
9
// it under the terms of the GNU Lesser General Public License as published 
10
// by the Free Software Foundation, either version 3 of the License, or     
11
// (at your option) any later version.                                      
12
//                                                                          
13
// This source file is distributed in the hope that it will be useful,      
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
16
// GNU General Public License for more details.                             
17
//                                                                          
18
// You should have received a copy of the GNU General Public License        
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
20
//                                                                          
21
//
22
//  Webpack 9.2i xc3s1200e 4fg320
23
//  32 slices / 62 LUTs / 208.160 MHz
24
//  27 ff's / 1 DCM
25
//
26
// 500us on per digit
27
// 10us interdigit blanking
28
//=============================================================================
29
 
30
module seven_seg(rst, clk, dp, val, ssLedAnode, ssLedSeg);
31
parameter pClkFreq=25000000;
32
parameter pTermCnt=pClkFreq/250000;
33
input rst;              // reset
34
input clk;              // clock
35
input [3:0] dp;
36
input [15:0] val;
37
output [3:0] ssLedAnode;
38
output [7:0] ssLedSeg;
39
 
40
reg [3:0] ssLedAnode;
41
reg [7:0] ssLedSeg;
42
 
43
// Generate 250kHz clock from input
44
wire [ 9:0] q1;
45
wire [11:0] q2;
46
down_counter #(10) u1 (rst, clk, 1'b1, z, pTermCnt, q1, z);
47
counter      #(12) u2 (rst, clk, z, 1'b0, 12'h000, q2);
48
 
49
reg [4:0] nyb;
50
 
51
wire [2:0] dig_ndx = q2[11:9];
52
wire dig_en = q2[8:1]!=8'hFF;
53
 
54
always @(dig_ndx or dig_en)
55
if (dig_en)
56
        case (dig_ndx)
57
        3'd0:   ssLedAnode = 4'hE;
58
        3'd1:   ssLedAnode = 4'hD;
59
        3'd2:   ssLedAnode = 4'hB;
60
        3'd3:   ssLedAnode = 4'h7;
61
        default:        ssLedAnode = 4'hF;
62
        endcase
63
else
64
        ssLedAnode = 4'hF;
65
 
66
always @(dig_ndx or dp or val)
67
case (dig_ndx)
68
3'd0:   nyb = {dp[0],val[ 3: 0]};
69
3'd1:   nyb = {dp[1],val[ 7: 4]};
70
3'd2:   nyb = {dp[2],val[11: 8]};
71
3'd3:   nyb = {dp[3],val[15:12]};
72
default:        nyb = 5'd0;
73
endcase
74
 
75
always @(dig_en or nyb)
76
if (dig_en) begin
77
        case (nyb[3:0])
78
        4'h0:   ssLedSeg <= 8'b11000000;
79
        4'h1:   ssLedSeg <= 8'b11111001;
80
        4'h2:   ssLedSeg <= 8'b10100100;
81
        4'h3:   ssLedSeg <= 8'b10110000;
82
        4'h4:   ssLedSeg <= 8'b10011001;
83
        4'h5:   ssLedSeg <= 8'b10010010;
84
        4'h6:   ssLedSeg <= 8'b10000010;
85
        4'h7:   ssLedSeg <= 8'b11111000;
86
        4'h8:   ssLedSeg <= 8'b10000000;
87
        4'h9:   ssLedSeg <= 8'b10011000;
88
        4'hA:   ssLedSeg <= 8'b10001000;
89
        4'hB:   ssLedSeg <= 8'b10000011;
90
        4'hC:   ssLedSeg <= 8'b11000110;
91
        4'hD:   ssLedSeg <= 8'b10100001;
92
        4'hE:   ssLedSeg <= 8'b10000110;
93
        4'hF:   ssLedSeg <= 8'b10001110;
94
        endcase
95
        ssLedSeg[7] <= !nyb[4];
96
end
97
else
98
        ssLedSeg <= 8'b11111111;
99
 
100
endmodule

powered by: WebSVN 2.1.0

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