UCR CS122A, Fall 2005 Prof. Frank Vahid Homework 2 Working in groups is encouraged. 10% extra credit for groups of 3 or more working together for an hour or more. Write down each others' names, and when/where you met. Every student should still solve every problem and submit his/her own solutions; working together is useful to understand the problems, discuss solution ideas, and compare answers. This homework should be submitted ELECTRONICALLY using the CS&E department's turnin server. Expected time is 2-3 hours -- please record and report your actual time per problem. Start early! All VHDL code should be generally suitable for synthesis using modern commercial FPGA synthesis tools. All code, VHDL or C, should be reasonably concise. 1. Create a system that simply pulses an output P high very briefly (e.g., 1 clock cycle) every 1 second. Create this system: (a) Using an FSMD captured in a single VHDL process. Assume an input to your system is a 1 MHz clock named clk. You need only show the process, not the complete VHDL code. (b) Using a microcontroller coded in C, assuming the microcontroller described at the bottom of this homework. Show the main and the ISR contents. 2. Repeat the above problem, but create a pulse Q that is high 0.5 seconds seconds and low 0.5 seconds. 3. Create a system that waits for an input B to become 1, and then lights three lights L, M, N in sequence: L for 1 second, then M for 1 second, then N for 1 second. (a) Using one or more VHDL processes. (b) Using a microcontroller coded in C, assuming the microcontroller described at the bottom of this homework. Show the main and the ISR contents. 4. (a) Combine the systems in 1(a) and 3(a) into a single system that generates the pulse on P, and meanwhile also waits for the button B and then lights three lights. Use as many processes as you see fit. (b) Combine the systems in 1(b) and 3(b) into a single system, using a microcontroller coded in C, assuming the microcontroller described at the bottom of this homework. Show the main and the ISR contents. MICROCONROLLER: For the above problems that refer to a microcontroller described here, assume you are using a microcontroller with the following: * an external interrupt input Int1 that causes a call to an interrupt service routine names ISR_Int1(). * an internal 16-bit timer that can be set by writing to the following registers, accessed as global variables in C: - short int timer1init: starting count value, counts down to 0 - int timer1enable: set to 1 to enable counting, 0 to disable - int timer1wrap: set to 1 to wrap around to starting count value each time the counter hits 0 - int timerdir: counts down if 0, up if 1. * an internal interrupt generated by timer1 hitting 0, causing a call to ISR_Timer1(). * 8-bit ports P0, P1, P2 and P3 accessible as global variables, each also accessible as individual bits (e.g., P0.0-P0.7). * A clock with a period of 100 nanoseconds.