📄 hexdisplay.v
字号:
//////////////////////////////////////////////////////////////////////////////////// Company: // Engineer: Patrick Moore and John Lagnese (group 1)// // Create Date: 15:17:34 01/24/2007 // Design Name: // Module Name: HexDisplay, DigitDisplay // Project Name: Count// Target Devices: // Tool versions: // Description: Displays a Hex number on the board//// Dependencies: none.//// Revision: // Revision 0.01 - File Created// Additional Comments: ////////////////////////////////////////////////////////////////////////////////////module HexDisplay(value,CLK,an,seg); //Display the value on the board in Hex
input CLK; input [15:0] value; //Value being passed in output an3,an2,an1,an0,a,b,c,d,e,f,g; output [3:0] an;
output [6:0] seg; reg [3:0] digit; //Represent the actual digit reg [3:0] an; //Individual display digits DigitDiplay dd(digit,seg[0],seg[1],seg[2],seg[3],seg[4],seg[5],seg[6]); //Displays the digit
reg [15:0] counter; //Keeps track of the clock always @ (posedge CLK) //Cycles through the board display enabling\disabling, too fast for the eye to notice begin casex(counter)//Disables the left most display, digit represents the 1s place, and the right most is enabled. 16'b0000000000000000: begin an[3] = 1; digit = value & 16'h000F; an[0] = 0; counter = counter + 1; end//Enables the 2nd most display, digit represents the 10s place, and the right most is disabled. 16'b0100000000000000: begin an[0] = 1; digit = (value >> 4) & 16'h000F; an[1] = 0; counter = counter + 1; end//Enables the 2nd left most display, digit represents the 100s place, and the 2nd right most is disabled. 16'b1000000000000000: begin an[1] = 1; digit = (value >> 8) & 16'h000F; an[2] = 0; counter = counter + 1; end//Disables the 2nd left most display, digit represents the 1000s place, and the left most digit is enabled 16'b1100000000000000: begin an[2] = 1; digit = (value >> 12) & 16'h000F; an[3] = 0; counter = counter + 1; end default begin counter = counter + 1; end endcase endendmodulemodule DigitDiplay(value,a,b,c,d,e,f,g); //Digital logic to represent the digits on the LEDs. input [3:0] value; output a,b,c,d,e,f,g; //Individual display segments assign c = (value == 2 || value == 12 || value == 14 || value == 15); //2,C,E,F assign a = (value == 1 || value == 4 || value == 11 || value == 13); //1,4,b,D assign b = (value == 5 || value == 6 || value == 11 || value == 12 || value == 14 || value == 15); //5,6,b,D,E,F assign d = (value == 1 || value == 4 || value == 7 || value == 10 || value == 15); //1,4,7,A,F assign g = (value == 0 || value == 1 || value == 7 || value == 12); //0,1,7,C assign f = (value == 1 || value == 2 || value == 3 || value == 7 || value == 13); //1,2,3,7,D assign e = (value == 1 || value == 3 || value == 4 || value == 5 || value == 7 || value == 9); //1,3,4,5,7,9endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -