Page 348 - Embedded Microprocessor Systems Real World Design
P. 348

Program Counter
                The control store is driven by a progrum counter. This is just a binary counter that counts from
                zero to however large the control store is. If  the control store holds four instructions, the
                program counter needs to be 2 bits wide. If  the control store holds 1024 instructions, the
                program counter needs to be 10 bits wide. The program counter is incremented each time
                an instruction is executed in order to select the next instruction in the control store.




                Opcodes
                Say that the control store is 9 bits wide and we  define the bits like this:

                  Bits 0, 1: select ALU function (00 = addition, 01 = negation, 10 = AND, 11 = OR).
                  Bits 2, 3: Select Zregister  (00 = ZO,  01 = Z1, 10 = 22, 11 = 23)
                  Bits 4, 5: Select Y-register  (00 =YO, 01 = Y1,  10 = Y2, 11 = Y3)
                  Bits 6, 7, 8: Select which register the result will be clocked into:
                    000 = zo, 001 = 21,010 = 22,011 = 23,
                    100 = YO,  101 = Yl, 110 = Y2,lll = Y3

                The different combinations of bits that tell the machine what to do are called opcodes. Now,
                say we want to write a program that will execute the following two operations:
                  Add Y1  to 22, putting the result in Y2
                  AND Y2 with  23, putting the result in Y3

                  The  control  store  would  contain  the  following words,  based  on  the  preceding  bit
                definitions:
                  Location    Control Store
                  0           11001 1000
                  1           1 1110 1110

                  The program counter starts at zero (remember, zerebased addressing), and the output
                of  the control store causes the first operation to be executed. Then  the program counter
                increments to one and the second operation is executed.




                Branching
                Now  we  can write a program, up to the length of  the control store, to do any operation
                that our simple machine is  capable of. But what happens when  we  get to the end of  the
                program? To handle this, we  can expand our control store from 9 to 20 bits, as shown in
                Figure D.5.
                  Of the added 11 bits, 10 wrap back around to the program counter as inputs, and one is
                a branch control bit. When the branch control bit is 0, the program counter increments,
               just as it did before. But when the branch control bit is  1, the program counter is loaded


                Appendix D                                                           329
   343   344   345   346   347   348   349   350   351   352   353