7-Segment Displays Lecture L6.7 Section 6.5
Turning on an LED
This is what we use in Lab
7-Segment Display
a b c d e f g a b c d e f g
7-Segment Display a b c d e f g a b c d e f g A b C d E F
K-Map for Segment e D3 D2 D1 D D3 & D2 D1 & !D0 !D2 & !D0 e = D3 & D2 # !D2 & !D0 # D3 & D1 # D1 & !D0 D3 & D1
MODULE hex7seg INTERFACE ([D3..D0] -> [a,b,c,d,e,f,g]); TITLE 'hex to seven segment display decoder' " a " --- hex-to-seven-segment decoder " f| g |b " --- " e| d |c " --- DECLARATIONS " Input Pins " D3..D0 PIN; " display input value D = [D3..D0]; " 4-bit input vector " Output Pins " [a,b,c,d,e,f,g] PIN ISTYPE 'com'; " output values " Definitions " ON,OFF = 1,0; " for common cathode LEDs hex7seg.abl Makes this module available in higher-level modules
16; truth_table (D -> [ a, b, c, d, e, f, g ]) 0 -> [ ON, ON, ON, ON, ON, ON, OFF]; 1 -> [OFF, ON, ON, OFF, OFF, OFF, OFF]; 2 -> [ ON, ON, OFF, ON, ON, OFF, ON]; 3 -> [ ON, ON, ON, ON, OFF, OFF, ON]; 4 -> [OFF, ON, ON, OFF, OFF, ON, ON]; 5 -> [ ON, OFF, ON, ON, OFF, ON, ON]; 6 -> [ ON, OFF, ON, ON, ON, ON, ON]; 7 -> [ ON, ON, ON, OFF, OFF, OFF, OFF]; 8 -> [ ON, ON, ON, ON, ON, ON, ON]; 9 -> [ ON, ON, ON, ON, OFF, ON, ON]; 0A -> [ ON, ON, ON, OFF, ON, ON, ON]; 0B -> [OFF, OFF, ON, ON, ON, ON, ON]; 0C -> [ ON, OFF, OFF, ON, ON, ON, OFF]; 0D -> [OFF, ON, ON, ON, ON, OFF, ON]; 0E -> [ ON, OFF, OFF, ON, ON, ON, ON]; 0F -> [ ON, OFF, OFF, OFF, ON, ON, ON]; END hex7seg HEX hex7seg.abl (cont.)
MODULE main7seg TITLE 'hex to seven segment display decoder' DECLARATIONS hex7seg INTERFACE([D3..D0] -> [a,b,c,d,e,f,g]); d7L FUNCTIONAL_BLOCK hex7seg; d7R FUNCTIONAL_BLOCK hex7seg; " Input Pins " L3..L0 PIN 11,7,6,5;" Left Switches S L = [L3..L0];" 4-bit input vector R3..R0 PIN 4,3,2,1;" Right Switches S R = [R3..R0];" 4-bit input vector " Output Pins " [a,b,c,d,e,f,g] PIN 57,58,61,62,63,65,66 ISTYPE 'com'; "Leftmost (tens) 7-segment LED display [aa,bb,cc,dd,ee,ff,gg] PIN 15,18,23,21,19,14,17 ISTYPE 'com'; " Rightmost (units) 7-segment LED display EQUATIONS [a,b,c,d,e,f,g] = d7L.[a,b,c,d,e,f,g]; d7L.[D3..D0] = L; [aa,bb,cc,dd,ee,ff,gg] = d7R.[a,b,c,d,e,f,g]; d7R.[D3..D0] = R; END main7seg main7seg.abl
MODULE main7seg TITLE 'hex to seven segment display decoder' DECLARATIONS hex7seg INTERFACE([D3..D0] -> [a,b,c,d,e,f,g]); d7L FUNCTIONAL_BLOCK hex7seg; d7R FUNCTIONAL_BLOCK hex7seg; " Input Pins " L3..L0 PIN 11,7,6,5;" Left Switches S L = [L3..L0];" 4-bit input vector R3..R0 PIN 4,3,2,1;" Right Switches S R = [R3..R0];" 4-bit input vector
" Output Pins " [a,b,c,d,e,f,g] PIN 57,58,61,62,63,65,66 ISTYPE 'com'; "Leftmost (tens) 7-segment LED display [aa,bb,cc,dd,ee,ff,gg] PIN 15,18,23,21,19,14,17 ISTYPE 'com'; " Rightmost (units) 7-segment LED display EQUATIONS [a,b,c,d,e,f,g] = d7L.[a,b,c,d,e,f,g]; d7L.[D3..D0] = L; [aa,bb,cc,dd,ee,ff,gg] = d7R.[a,b,c,d,e,f,g]; d7R.[D3..D0] = R; END main7seg