Assignment 5: First try at the MIC-1 simulator display

All programs in this assignment should output a line giving your name before doing anything else. All output from this assignment goes to standard error. Create a new directory and copy all of the following files which are in a compressed tar file.
   assign5.input
   control_store
   errout
   makefile
   memory
   mic1.h
   micani.h
   micani.o
   runmic
   Xdefaults
Milestone 1:

Copy your mic1.c from assignment 3 to this new directory. The control_store_t type has two new fields. Create a typedef for MIR_decoded_t which is suitable for holding a decoded microinstruction register. It should be a structure with fields for each field of the MIR. Modify your handle_input routine so that if the input string consists of just the letter s, your routine next_subcycle is called. This routine should just print out executing subcycle on a new line. Modify the c input so that in increments the MPC field of the control store. Modify your initialize_control_store routine so that it sets the size field. Modify your initialize_memory so that it sets the valid flag for each value read in and sets the size field to the maximum size of the array. If you still have your show_memory routine it will need to be modified also. Make sure your program still compiles and runs as before.

Milestone 2:

Create a data structure suitable for holding the 16 registers of the Mic-1. The registers, control store, and memory should be global variables. Make a global variable which keeps track of which subcycle is the next one to execute. Make a global integer variable called display_flag. Make global variables for the A Latch and B Latch values. Write a routine called initialize_Mic1 which initializes the appropriate variables. This will be called after the memory and control store files have been read in. It will initialize all variable registers to 0, set the constant registers, set the MPC to 0, set the latches to 0, and set the subcycle to 1. The display_flag should be initialized to ANI_DISPLAY_SLOW. The MAR and MBR fields of the memory should be set to 0.

Write a routine called update_display which takes one integer parameter. This routine will call routines defined in micani.h to set the animator display to the current state of the Mic-1. Eventually you should call all of the routines with names starting with ani_set. The flag parameters of these routines should be the value passed to update_display. Look carefully at the data types of the routines and try to figure out what they do. Call them with the appropriate values. For now, you can comment out your calls to routines which you do not yet know how to use. Call update_display(display_flag) after initialize_animator and after each time the c command is entered.

Milestone 3:

Write a routine with prototype: void decode_mir(MIR_t,MIR_decoded_t *); which sets the fields of the second argument based on the first. Call this from inside of initialize_Mic1 and any time the MPC changes to set the MIR field of the control store from entries[MPC]. Now make sure the ani_set_mir lines are in your update_display routine and try to get the display to look right.

The following routines should also be called in update_display:

   ani_set_alatch_value                    ani_set_mbr_value
   ani_set_a_memory_value                  ani_set_memory_pc
   ani_set_blatch_value                    ani_set_memory_sp
   ani_set_cycle_count_value               ani_set_mpc_inc_value
   ani_set_decoded_ir                      ani_set_mpc_value
   ani_set_decoded_mir                     ani_set_register_value
   ani_set_instruction_count_value         ani_set_subcycle_active
   ani_set_mar_value