ee4oi4 engineering design up1core library functions

30
EE4OI4 Engineering Design UP1core Library Functions

Upload: cora-gaines

Post on 01-Jan-2016

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: EE4OI4 Engineering Design UP1core Library Functions

EE4OI4Engineering Design

UP1core Library Functions

Page 2: EE4OI4 Engineering Design UP1core Library Functions

2

UP1 core library functions

• In complex designs, intellectual property (IP) cores are frequently used.

• An IP core is a previously developed synthesizable hardware design that provides a widely used functions.

• Some of IP cores are commercially licensed

• IP cores reduce development time by providing common hardware functions for use in a new design.

Page 3: EE4OI4 Engineering Design UP1core Library Functions

3

UP1 core library

DEC_7SEG Hexadecimal to Seven-segment decoder

DEBOUNCE Pushbutton debounce circuit

ONEPULSE Pushbutton single pulse circuit

CLK_DIV 25MHz clock divider with 7 frequency outputs

VGA_SYNC VGA synch signal generator for UP1

CHAR_ROM Character font ROM for video character generations

KEYBOARD Reads keyboard scan codes from the UP1

MOUSE Reads mouse data and outputs cursor row and column address

Page 4: EE4OI4 Engineering Design UP1core Library Functions

4

UP1 core libraryCOMPONENT VGA_SYNC

PORT(clock_25Mhz, red, green, blue : INSTD_LOGIC;

red_out, green_out, blue_out,

horiz_sync_out, vert_sync_out : OUTSTD_LOGIC;

pixel_row, pixel_column : OUT STD_LOGIC_VECTOR(9 DOWNTO 0));

END COMPONENT;

Page 5: EE4OI4 Engineering Design UP1core Library Functions

5

Video display• VGA video signal: 5 active signals

– Horizontal Sync. & Vertical Sync.: TTL logic levels

– RGB: analog signals (0.7 to 1 volt peak to peak)

• Screen has 640x480 pixels

• Video signal redraws the entire screen 60 times per second

Page 6: EE4OI4 Engineering Design UP1core Library Functions

6

Video display• Major component inside a VGA computer monitor is the

color CRT.

• Electron beam is scanned over the screen in a sequence of horizontal lines to generate an image

• The deflection yoke deflects the electron beam to the appropriate position on the face of CRT

• Light is generated when the beam is turned on by a video signal and it strikes a color phosphor on the CRT.

• Face of CRT contains three different phosphors one type for each primary color (red, green, blue)

Page 7: EE4OI4 Engineering Design UP1core Library Functions

7

0,0

639,479

640 Pixels in a row

480 Pixels

in a column

0,479

639,0

480 Horizontal Scan Lines and Retrace

.

.

.

VGA Image - 640 by 480 Pixel Layout.

Page 8: EE4OI4 Engineering Design UP1core Library Functions

8

UP1core VGA_SYNC

Page 9: EE4OI4 Engineering Design UP1core Library Functions

9

VGA display

Generation of colors of pixels based on their

location on the display

Page 10: EE4OI4 Engineering Design UP1core Library Functions

10

Video LED Design Example

Page 11: EE4OI4 Engineering Design UP1core Library Functions

11

Video Color Bar Design Example

Page 12: EE4OI4 Engineering Design UP1core Library Functions

12

Character Display

• Displaying textual data: a pixel pattern or font is needed to display each different character

• Character font can be stored in a ROM implemented inside the FLEX.

• A memory initialization file (.mif) is used to initialize the ROM

• CHAR_ROM function in UP1core functions is a character ROM.

• Characters are stored in consecutive memory cells.• Each character is stored in eight memory cells (each memory

cell 8 bits)• Each character consists of an 8x8 dot map

Page 13: EE4OI4 Engineering Design UP1core Library Functions

13

Character Display

A Address Font Data 000001000 : 00011000 ; 000001001 : 00111100 ; 000001010 : 01100110 ; 000001011 : 01111110 ; 000001100 : 01100110 ; 000001101 : 01100110 ; 000001110 : 01100110 ; 000001111 : 00000000 ; B

C

Page 14: EE4OI4 Engineering Design UP1core Library Functions

14

UP1core CHAR_ROM

Page 15: EE4OI4 Engineering Design UP1core Library Functions

15

Character Display• The function char_rom has three inputs:

– character_address: the starting address of memory location containing the character we want to be displayed

– font_row and font_col: inputs that determine which bit of the memory partition containing the character should be displayed at a particular time (which dot of the character font should be displayed)

• If each dot in a character font is mapped to pixel on the display, each character requires 8x8 pixels on the display.

• If each dot in a character font is mapped to a 2x2 pixel area on the display, each character requires 16x16 pixels on the display.

Page 16: EE4OI4 Engineering Design UP1core Library Functions

16

Table 9.1 Character Address Map for 8 by 8 Font ROM.

CHAR ADDRESS CHAR ADDRESS CHAR ADDRESS CHAR ADDRESS

@ 00 P 20 Space 40 0 60 A 01 Q 21 ! 41 1 61 B 02 R 22 " 42 2 62 C 03 S 23 # 43 3 63 D 04 T 24 $ 44 4 64 E 05 U 25 % 45 5 65 F 06 V 26 & 46 6 66 G 07 W 27 ‘ 47 7 67 H 10 X 30 ( 50 8 70 I 11 Y 31 ) 51 9 71 J 12 Z 32 * 52 A 72 K 13 [ 33 + 53 B 73 L 14 Dn Arrow 34 , 54 C 74 M 15 ] 35 - 55 D 75 N 16 Up Arrow 36 . 56 E 76 O 17 Lft Arrow 37 / 57 F 77

Page 17: EE4OI4 Engineering Design UP1core Library Functions

17

Character Test Design Example

Page 18: EE4OI4 Engineering Design UP1core Library Functions

18

Interfacing to the PS/2 keyboard• Altra UP-1 supports the use of either a mouse or keyboard

using the PS/2 connector on the board

• The connector provides electrical connection between the keyboard/mouse and the board

• It is necessary to design a hardware interface using FLEX to communication with a keyboard or mouse.

• UP1core library has the required VHDL codes for a keyboard interface (keyboard.vhd) and mouse interface (mouse.vhd)

Page 19: EE4OI4 Engineering Design UP1core Library Functions

19

Keyboard scan codes• Keyboards are normally encoded by placing the key switches

in a matrix of rows and columns

• All rows and columns are periodically scanned to find any key state changes.

• Key data is passed serially to the computer from the keyboard using scan code.

• Each key has a unique scan code based on the key switch matrix row and column address

Page 20: EE4OI4 Engineering Design UP1core Library Functions

20

Keyboard scan codes• Scan code consists of Make and Break codes.

• One make code is sent every time a key is pressed

• When several keys are hit at the same time several make codes are sent (this happens in fast typing and in using shift and ctrl)

• When a key is released, a break code is sent.

• By using this break code if several keys are pressed at the same time it can be distinguished which one was released

• If a key is held down, the make code is continuously sent at typematic (autorepeat) rate.

Page 21: EE4OI4 Engineering Design UP1core Library Functions

21

ESC

110

F1

112

F2

113

F3

114

F4

115

F5

116

F6

117

F7

118

F8

119

F9

120

F10

121

F11

122

F12

123

PrintScrn124

Pause

126

ScrollLock125

~ `

1

! 1

2

@ 2

3

# 3

4

$ 4

5

% 5

6

^ 6

7

& 7

8

* 8

9

( 9

10

) 0

11

- _

12

= +

13

Backspace

15

Tab

16

Q

17

W

18

E

19

R

20

T

21

Y

22

U

23

I

24

O

25

P

26

[ {

27

] }

28

\ |

29

Caps Lock

30

A

31

S

32

D

33

F

34

G

35

H

36

J

37

K

38

L

39

; :

40

‘ “

41

Enter

43

Z

31

X

32

C

33

V

34

B

35

N

36

M

37

, <

38

. >

39

/ ?

40

Shift

57

Shift

44

Ctrl

58

Ctrl

64

Alt

62

Alt

60 61

Insert

75

Home

80

Del

76

End

81

Pg Up

85

Pg Dn

86

83

79 84 89

/

95

*

100

-

105

8

96

+

106

4

76

5

97

6

102

2

98

0 Ins

99

. Del

104

NumLock90

7Home91

9Pg Up101

1End93

3Pg Dn103

Enter

108

Key Numbers for Scan Code.

Page 22: EE4OI4 Engineering Design UP1core Library Functions

22

Table 10.3 Scan Codes for PS/2 Keyboard.

Key# Make Code

Break Code

Key# Make Code

Break Code

Key# Make Code

Break Code

1 0E F0 0E 31 1C F0 1C 90 77 F0 77 2 16 F0 16 32 1B F0 1B 91 6C F0 6C 3 1E F0 1E 33 23 F0 23 92 6B F0 6B 4 26 F0 26 34 2B F0 2B 93 69 F0 69 5 25 F0 25 35 34 F0 34 96 75 F0 75 6 2E F0 2E 36 33 F0 33 97 73 F0 73 7 36 F0 36 37 3B F0 3B 98 72 F0 72 8 3D F0 3D 38 42 F0 42 99 70 F0 70 9 3E F0 3E 39 4B F0 4B 100 7C F0 7C

10 46 F0 46 40 4C F0 4C 101 7D F0 7D 11 45 F0 45 41 52 F0 52 102 74 F0 74 12 4E F0 4E 43 5A F0 5A 103 7A F0 7A 13 55 F0 55 44 12 F0 12 104 71 F0 71 15 66 F0 66 46 1A F0 1A 105 7B F0 7B 16 0D F0 0D 47 22 F0 22 106 79 F0 79 17 15 F0 15 48 21 F0 21 110 76 F0 76 18 1D F0 1D 49 2A F0 2A 112 05 F0 05 19 24 F0 24 50 32 F0 32 113 06 F0 06 20 2D F0 2P 51 31 F0 31 114 04 F0 04 21 2C F0 2C 52 3A F0 3A 115 0c F0 0C 22 35 F0 35 53 41 F0 41 116 03 F0 03 23 3C F0 3C 54 49 F0 49 117 0B F0 0B 24 43 F0 43 55 4A F0 4A 118 83 F0 83 25 44 F0 44 57 59 F0 59 119 0A F0 0A 26 4D F0 4D 58 14 F0 14 120 01 F0 01 27 54 F0 54 60 11 F0 11 121 09 F0 09 28 5B F0 5B 61 29 F0 29 122 78 F0 78 29 5D F0 5D 62 E0 11 E0 F0 11 123 07 F0 07

The remaining key codes are a function of the shift, control, alt, or num-lock keys.

Page 23: EE4OI4 Engineering Design UP1core Library Functions

23

Table 10.3 (Continued) - Scan Codes for PS/2 Keyboard.

Key No Shift or Num Lock

Shift* Num Lock On

# Make Break Make Break Make Break 76 E0 70 E0 F0 70 E0 F0 12 E0 70 E0 F0 70 E0 12 E0 12 E0 70 E0 F0 70 E0 F0 12 76 E0 71 E0 F0 71 E0 F0 12 E0 71 E0 F0 71 E0 12 E0 12 E0 71 E0 F0 71 E0 T0 12 79 E0 6B E0 F0 6B E0 F0 12 E0 6B E0 F0 6B E0 12 E0 12 E0 6B E0 F0 6B E0 F0 12 80 E0 6C E0 F0 6C E0 F0 12 E0 6C E0 F0 6C E0 12 E0 12 E0 6C E0 F0 6C E0 F0 12 81 E0 69 E0 F0 69 E0 F0 12 E0 69 E0 F0 69 E0 12 E0 12 E0 69 E0 F0 69 E0 F0 12 83 E0 75 E0 F0 75 E0 F0 12 E0 75 E0 F0 75 E0 12 E0 12 E0 75 E0 F0 75 E0 F0 12 84 E0 72 E0 F0 72 E0 F0 12 E0 72 E0 F0 72 E0 12 E0 12 E0 72 E0 F0 72 E0 F0 12 85 E0 7D E0 F0 7D E0 F0 12 E0 7D E0 F0 7D E0 12 E0 12 E0 7D E0 F0 7D E0 F0 12 86 E0 7A E0 F0 7A E0 F0 12 E0 7A E0 F0 7A E0 12 E0 12 E0 7A E0 F0 7A E0 F0 12 89 E0 74 E0 F0 74 E0 F0 12 E0 74 E0 F0 74 E0 12 E0 12 E0 74 E0 F0 74 E0 F0 12

* When the left Shift Key is held down, the 12 - FO 12 shift make and break is sent with the other scan codes. When the right Shift Key is held down, 59 – FO 59 is sent.

Key Scan Code Shift Case * # Make Break Make Break 95 E0 4A E0 F0 4A E0 F0 12 E0 4A E0 12 F0 4A

* When the left Shift Key is held down, the 12 - FO 12 shift make and break is sent with the other scan codes. When the right Shift Key is held down, 59 - FO 59 is sent. When both Shift Keys are down, both sets of codes are sent with the other scan codes.

Key Scan Code Control Case, Shift Case Alt Case

# Make Break Make Break Make Break

124 E0 12 E0 7C E0 F0 7C E0 F0 I2 E0 7C E0 F0 7C 84 F0 84

Key # Make Code Control Key Pressed

126 * El 14 77 El F0 14 F0 77 E0 7E E0 F0 7E * This key does not repeat

Page 24: EE4OI4 Engineering Design UP1core Library Functions

24

UP1 Keyboard function• UP1core library has a VHDL code that reads the scan code

bytes for the keyboard• keyboard.vhd has five inputs and two outputs:• Inputs:

– keyboard_clk: connected to keyboard clock pin keyboard_data: connected to keyboard data pin

– clock_25Mhz: connected to UP1 clock pin– reset: clears the internal registers and buffers– read: a handshaking signal. It’s rising edge clears the scan_ready

signal

• Outputs: – scan_code: scan code of the key pressed – scan_ready: is high when the scan code is ready.

Page 25: EE4OI4 Engineering Design UP1core Library Functions

25

Keyboard UP1core

Page 26: EE4OI4 Engineering Design UP1core Library Functions

26

Example design using the Keyboard UP1core.

Page 27: EE4OI4 Engineering Design UP1core Library Functions

27

Page 28: EE4OI4 Engineering Design UP1core Library Functions

28

Symbol for MOUSE UP1core.

Page 29: EE4OI4 Engineering Design UP1core Library Functions

29

UP1 Mouse function• Inputs:

– clock_25Mhz: connected to UP1 clock pin

– Reset: clears the internal registers and buffers

• Bi-directional data lines: – mouse_clk: connected to mouse clock pin

– Mouse_data: connected to keyboard data pin

• Outputs: – left_button: high if the left button is pressed

– right_button: high if the right button is pressed

– mouse_cursor_row[9..0], mouse_cursor_column[9..0]: contain the current address of the mouse cursor in 640x480 screen area

Page 30: EE4OI4 Engineering Design UP1core Library Functions

30

Example Design Using Mouse UP1core