USB mouse/touchscreen controller

The USB mouse/touchscreen controller works with the DE2-115's USB controller to communicate with a USB mouse or touchscreen. The USB mouse/touchscreen controller is implemented in usbmouse.v, usbram.v, and usbram.mif.

mouse_command and mouse_response implement the standard I/O protocol. There are no command parameters. The response parameters are mouse_deltax, mouse_deltay, mouse_button1, mouse_button2, and mouse_button3. mouse_deltax and mouse_deltay describe the movement of the mouse since the last time the mouse was read. Positive values for mouse_deltax indicate motion to the right. Positive values for mouse_deltay indicate motion downward (toward your body); this matches the orientation used for VGA coordinates. mouse_button1, mouse_button2, and mouse_button3 are 1 when the corresponding mouse button is pressed and 0 otherwise.

ase100 simulates the USB mouse controller accurately enough to test your device driver and to run assembly-language programs. The simulator typically pays attention to mouse movement and buttons whenever the mouse is in the VGA window. If you want to move the mouse without affecting the data being sent to the simulator (e.g., you want to move the mouse to another window), type Control-m (hold the Control button down and type m). Type Control-m again to reactivate the mouse.

The mouse cursor will change to a star shape when ase100 is paying attention to the mouse. This mouse cursor exists only as a convenience when running ase100, so you can see where the mouse is on the computer's screen. This means that the position of star cursor will typically not match the (x,y) position maintained by your program. Remember that the star-shaped mouse cursor in ase100 has no hardware equivalent: the mouse controller on the DE2-115 only sends mouse movements and does not maintain a mouse position.

Touchscreen Specifics

You may not choose the Touchscreen for Lab 7.

The interface for the touchscreen is slightly different than the mouse, providing absolute positions for x and y as well as returning whether the screen is currently being pressed in the touch_x, touch_y, and touch_pressed values.

Lab 7 task

Write a device driver for the USB mouse controller that a program can call to read a mouse event from the USB mouse controller. Then, write a test program that maintains a current (x,y) position for the mouse and displays this position on the hexdigits. Constrain x to be in the range [0,639]; constrain y to be in the range [0,479].

Optional: If one of your teammates has written a driver for the VGA monitor, try displaying the current mouse position as a pixel on the VGA monitor.