-
Notifications
You must be signed in to change notification settings - Fork 0
/
Display_Unit.v
145 lines (138 loc) · 2.8 KB
/
Display_Unit.v
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12:37:32 03/03/2015
// Design Name:
// Module Name: Display_Unit
// Project Name:
// Target Devices:
// Tool versions:
// Description: Takes 16 bit data and displays on Seven segment and VGA display
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Display_Unit(input clk,input [1:0] toggle,
input [15:0] Data_in,
output [2:0] R, G, [1:0] B,
output HS, VS, // for VGA
output [6:0] Seven_Segment, // for seven segment display
output reg [3:0] Select
);
//;parameter [15:0] Data_in = 16'b1011011110100101;
//parameter s_0 = 2'b00, s_1=2'b01, s_2=2'b10, s_3=2'b11;
parameter s_0 =1'b0, s_1=1'b1;
parameter [2:0] rCtrl = 3'b111;
parameter [2:0] gCtrl = 3'b111;
parameter [1:0] bCtrl = 2'b11;
reg [4:0] Data_in_seven;
reg state, next_state;
integer counter;
parameter off = 4'b1111;
/////////////////////////////////////////////////////
// Begin clock division
parameter N = 6; // parameter for clock division
reg clk_25Mhz;
reg [N-1:0] count;
always @ (posedge clk) begin
count <= count + 1'b1;
clk_25Mhz <= count[N-1];
end
// End clock division
/////////////////////////////////////////////////////
/*reg clk_25Mhz;
integer count;
always @(posedge clk)
begin
case(count)
500: begin clk_25Mhz <= clk_25Mhz + 1; count <= 0; end // Change 500 to any divisor you like
default: count <= count + 1;
endcase
end */
always @(posedge clk_25Mhz)
begin
case(counter)
0:
begin
Select <= 4'b0111;
counter <= 1;
end
1:
begin
Data_in_seven <= {0,Data_in[3:0]};
counter <= 2;
end
2:
begin
Data_in_seven <= 5'b10000;
counter <= 3;
end
3:
begin
Select <= 4'b1011;
counter <= 4;
end
4:
begin
Data_in_seven <= {0,Data_in[7:4]};
counter <= 5;
end
5:
begin
Data_in_seven <= 5'b10000;;
counter <= 6;
end
6:
begin
Select <= 4'b1101;
counter <= 7;
end
7:
begin
Data_in_seven <= {0,Data_in[11:8]};
counter <= 8;
end
8:
begin
Data_in_seven <= 5'b10000;;
counter <= 9;
end
9:
begin
Select <= 4'b1110;
counter <= 10;
end
10:
begin
Data_in_seven <= {0,Data_in[15:12]};
counter <= 11;
end
11:
begin
Data_in_seven <= 5'b10000;;
counter <= 0;
end
default:
counter <= 0;
endcase
end
sevensegment s( .Data_in(Data_in_seven),
.Data_out(Seven_Segment));
vga_display v(.clk(clk_25Mhz),
.R_control(rCtrl),
.G_control(gCtrl),
.B_control(bCtrl),
.R(R),
.G(G),
.B(B),
.HS(HS),
.VS(VS),
.seven(Seven_Segment)
);
endmodule