-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSevSegDisp.sv
executable file
·53 lines (45 loc) · 1.76 KB
/
SevSegDisp.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: Cal Poly
// Engineer: Paul Hummel
//
// Create Date: 06/29/2018 12:58:25 AM
// Design Name: Seven SSEGment Display Driver
// Module Name: SevSSEGDisp
// Target Devices: RAT MCU on Basys3
// Description: 7 SSEGment Display Driver with a 16-bit input and 4 character
// display. The input is assumed to be unsigned and can be
// displayed as hex or decimal. The BCD converts the 16-bit
// input into binary coded decimal of 4 digits, giving a
// maximum value of 9999. This is below the maximum value of a
// 16-bit input (65,535).
//
// 7 SSEGment configuration for SSEG and DISP_EN
// SSEG = {dp,a,b,c,d,e,f,g}
// DISP_EN = {d4, d3, d2, d1}
//
// Revision:
// Revision 0.01 - File Created
//////////////////////////////////////////////////////////////////////////////////
module SevSegDisp(
input CLK, // 100 MHz clock
input MODE, // 0 - display hex, 1 - display decimal
input [15:0] ALU_VAL,
output [7:0] SSEG,
output [3:0] SSEG_EN
);
logic [15:0] BCD_Val;
logic [15:0] Hex_Val;
BCD BCDMod (.HEX(ALU_VAL), .THOUSANDS(BCD_Val[15:12]),
.HUNDREDS(BCD_Val[11:8]), .TENS(BCD_Val[7:4]),
.ONES(BCD_Val[3:0]));
CathodeDriver CathMod (.HEX(Hex_Val), .CLK(CLK), .CATHODES(SSEG),
.ANODES(SSEG_EN));
// MUX to switch between HEX and BCD input
always_comb begin
if (MODE == 1'b1)
Hex_Val = BCD_Val;
else
Hex_Val = ALU_VAL;
end
endmodule