UCR CS 122B Winter 2004 Prof. Frank Vahid Homework 1 Due Thursday, 1/22/04, at the beginning of lecture. For any problem, if you need to make assumptions not stated in the problem, list them explicitly. 1. (2 points) Show the event queue for signal s and the event queue for port D (ports are signals), and the relationship of those queues to the generated timing diagram, for the VHDL code below, simulated for 3 ns. D is a port of type integer. signal S: integer; process() variable v : integer := 0; begin v := v + 1; S <= S + v; D <= S; wait for 1 ns; end process; 2. (2 points) You saw a button eBlock connected to a beeper eBlock in class. The button eBlock should send a packet (yes=1001, no=0110) whenever there's a change on input "button" or when 3 seconds have passed. Write two VHDL processes that simulate the eBlock system. You need not actually simulate the processes, but that wouldn't hurt. 3. (2 points) List and describe 5 advantages of simulating a system before building it. 4. (1 point) List and summarize in your own words the CMM. 5. (2 points) List the four main suggestions (mentioned in class) for improving software productivity that Brook's makes in his classic book The Mythical Man Month. (Hint: the first is "buy, don't build."). For the following questions, a microcontroller has an interrupt input Int1 that causes a call to Int1ISR(). The microcontroller has a timer controlled by functions: void TimerSet(int d); // d is in ms void TimerEnable(); void TimerDisable(); It has a UART that we can write to using a function: void UartPut(char d); It has interrupt enable and disable functions void EI(); void DI(); It has a sleep mode enabled by setting sleepreg=1. During sleep mode, the timers and UART are still active. Sleep mode is ended by any interrupt, which causes a jump to the appropriate ISR, followed by execution after the statement sleepreg=1; 6. (2 points) Write a program that for a button eBlock (described in class), that polls its input P1 (connected to the button) every 10 milliseconds. The eBlock outputs a packet whenever there's an event (a change) on P1, or when 3 seconds has passed. The button should be debounced for 50 ms. Hint: since you must poll every 10 milliseconds, debouncing can be done by using a counter that counts 5 10 millisecond sequences. The button is NOT connected to Int1. Sleep in between 10 millisecond intervals. 7. (3 points -- HARD): Come up with a way to maximize sleep time. Ideally, the processor will awaken only if the 3 second timeout has passed, or if an event has occurred. You may not be able to achieve the ideal. Describe your work, and why you could or couldn't achieve the ideal. 8. (3 points) Assume an additional input D that is 8 bits. Every time P1 pulses, you want to store D. (Ignore bounce issues on P1.) Whenever 10 D values have been stored, you want to send all 10 values, one at a time, over the UART. After that, you can discard the 10 values, and store new ones. Assume that every instruction requires 4 cycles to execute, that UartPut requires 8 cycles, and that pulses arrive no faster than every 50 cycles. 9. (3 points -- HARD) Repeat the above, assuming that pulses may arrive as fast as every 5 cycles. Do you ever miss events on P1? NOTE: be careful that you send the stores values to the UART IN THE SAME ORDER AS THEY ARE RECEIVED!!!! Note: Collaboration on this assignment is strongly ENCOURAGED. 5% extra credit for study groups of size at least 3 -- study groups may be bigger, even the entire class. Turn in your own unique homework (don't copy answers or create one answer together and then copy it), but help each other understand the concepts, debug each others' homeworks, etc. Working side-by-side and helping each other is what we're hoping for.