Part I 1. Unzip the tar file to any directory. 2. change to directory altera 3. run vsim & 4. Then type 'source altera.tcl' in the command line inside vsim 5. Press Start 6. You should be able to see the counter running and the signals in the waveform window. 7. Try changing the switch 'dip1' to change the direction of counting. 8. Try changing the switch 'dip2' to disable the switch. The 'depressed' state of the switch disables the counter. 9. Look in the waveform window. You can see that the changes to the input get reflected there. 10. Press Exit to exit the simulation. Part II Please look at the end of this file for descriptions of the changes you make. 1. Open the file 'altera.tcl' in any editor of your choice. 2. Navigate to the part where it says “uncomment the following lines to add ‘Reset’ Button” 3. Try to understand the significance of the lines and then uncomment them 4. Next go to the part which says “uncomment the following lines for adding display 2” and uncomment them. 5. Save the file and source the file from ‘vsim’ 6. The interface should now show the new additions 7. Now press 'start' to start the simulation. 8. Change the values of the button's location in the lines which you uncommented above. 9. Source the file again to see the change. 10. Play around with the other attributes to see what effect they have. Here is a brief description of the functions in the file start_running - initializes the simulation. This is linked to the start button run_clock - This is initialized from start_running. It runs recursively every 100 ms. paint_displays - called from run_clock and also initially. This sets the value of the displays after examining the state of the signals from the testbench. CreateWindow - This function creates the complete interface including buttons, checkbuttons and the displays. close_window - terminates the simulation. called by the 'exit' button. create_display - creates the seven segment display. It creates an individual canvas so that the background color can be set as black. The different segments are created as rectangles and set to have a very light red colour initially. update_display - updates the color of the 7-segment display. it uses the command itemconfigure to change the color. The command 'lindex' selects the color from the array $colours according to the variable $pattern (which is nothing but the output signal from the VHDL design). run_command - This procedure is used to group together all the commands to be executed. since all commands are subsets of this procedure, it reduces the risk associated with accidentally calling any of modelsim's inbuilt commands. initialize - this procedure compiles the vhdl files and loads the design. it also initializes the wave window and adds signals to it. It also sets the initial values of the inputs and runs the simulation for 500 ms. Try to understand the commands by referring to the modelsim reference given in this directory. CHANGES MADE Before describing the steps, the three steps in the addition of a widget are described. These three steps constitute the first change to be made in part II. The first step is the creation of the widget. Some of the common attributes like the dimensions, the orientation, the background and foreground colors, the text to be displayed on or beside the widget, are set in this step. The next step is packing or placing the widgets. The difference between the ‘pack’ and ‘place’ command is that the ‘place’ command can specify the exact location in the canvas. The ‘pack’ command specifies relative location and also bind the widget to a function. Without this step, the widges are invisible. The third optional step in this process is the binding of the widgets if necessary. The button widget needs explicit binding if different commands need to be executed at the pressed and released states of the button. For most other widgets the command to be executed is specified in the ‘creation’ step. The other change that needs explanation is the addition of the display. This is done with a function named ‘create_display’. A tag is passed as the argument to this function. This tag when passed to the ‘update_display’ function will set the states of the various line widgets to the required state. The two widgets are named as ‘display_l and ‘display_r’ to signify the left and right display widgets. A variable named ‘twodisplays’ is used so that the updating of the display proceeds smoothly when the second widget is added. This is used in the function ‘paint_displays’ which gets called each time the output changes state.