Lab 7 - Simple Micro-coded operations

Goal

To automate the processes of of the simple computer created in the last lab using micro coding.

Step 1 - Verify and update your system from Lab 6

Below is a system similar to what you should have after lab 6. Verify that your system is capable of everything this system can do. If not, update your system.

DualBusALU4Reg.png

To Do:

  1. Modify your Lab 6 system to look like the system above.
  2. How can you clear the accumulator?

Step 2 - Adding a micro-Sequencer

In lab 6 the operation of the system was completely manual. In order to work through a series of steps, the operations had to be selected manually step by step.

Consider that rather than entering these values manually, we could put the bits in a ROM memory, and step through the operations one location at a time.

Consider that the inputs to the circuit are merely a series of bits from a ROM:

Lab7_-_Overview.png

The bits of the ROM can be assigned specific function selections:

Ununsed Halt unused Cin ALU Func Data Source ACC C B MAR Mem
31-12 13 12 11 8-10 5-7 4 3 2 1 0

The bit fields are defined as follows:

ALU Functions

ALU Functions

Bits Operation
000 ACC
001 Reg
010 ACC'
011 Reg ^ ACC
100 Reg V ACC
101 Reg + ACC + Cin
110 -Reg
111 ACC-Reg

Data Source

Bits Source
000 Input
001 Memory
010 MAR
011 B
100 C
101 ACC

Counter for microprogram ROM

In order to make a microseqencer we need to generate addresses for a ROM memory that will hold the program. This can be done with a Logisim 8-bit counter. For now we use a push button rather than a clock. Below is a simple circuit to count uo from 0 to 255:

counter.png

The enable must be on for the counter to count. Note that the counter can be set to trigger with a clock on the rising edge, or falling edge. The counter also has an 8-bit D (Data) input so a number can be loaded into it. Also, the 0 input clears the counter (asynchronously) back to zero. The load and count bits control this function.

counter2.png

To Do
  1. Build the counter circuit above. Try it out.
  2. Paste an image of your clock in the lab report.
  3. What is the purpose of the carry out bit? How could it be useful?
  4. Below is a table that shows the functions of the counter based on the inputs. Finish the table to explain how the counter works.
Load Count Operation
0 0  
0 1  
1 0  
1 1  

Building the complete microsequencer

Below is microsequencer - a simple device to send the signals to the processing system.

SimpleMicroSequence_.png

Below is the Microsequencer in place:

DualBusALUMicro1.png

We can assign the bits of the ROM to specific functions. We are using 32 bits for future expansion. First let us consider a simple micro-program to add the contents of register B to register C, and put the result in ACC.

The table below is filled in to the values of the micro instructions:

Unused Halt unused Cin ALU Func Data Source ACC C B MAR Mem Operations Binary Hex Value
31-12 13 12 11 8-10 5-7 4 3 2 1 0      
0000000000000000000 0 0 0 100 011 1 0 0 0 0 ACC<-B 00000000000000000000010001110000 00000470
0000000000000000000 0 0 0 011 100 1 0 0 0 0 ACC<-ACC+C+Cin 00000000000000000000001110010000 00000390
0000000000000000000 1 0 0 000 000 0 0 0 0 0 Halt 00000000000000000010000000000000 00002000

If we select the ROM in the micro-sequencer we can select edit contents and put 00000470 in location 0, and 00000390 in location on.

EditingROM.png

Now if we hit reset, and then hit the clock button twice we can step through the instructions.

To Do

  1. Modify your machine from the last lab to include the micro-sequencer. Build the micro-sequencer first as a sub-circuit. Then connect it you your main system, and test it out.
  2. Get it to work with the simple program to add B and C above.
  3. What happens if you don't include the Halt instruction at the end?
  4. Take screen shots of the main machine, and the micro-sequencer, and include in Lab report.

Step 3 - Writing larger programs.

Writing the microcode words is obviously extremely tedious. To avoid the probably insanity I have created a simple Javascript program to automatically assemble micro-instructions for you. The program is VERY simple. It merely ORs together the selected bits to form a bit string and then converts it to HEX for easy copy and pasting into your machines.

The Microcode generator: http://cs.mvnu.edu/classes/CSC3054/microcode0.html

Note that you select the functions, and the micro-instruction is generated.

Lets try to write a program that sums the first 4 numbers in memory, and puts the result in memory location 5. For example, suppose:

Memory Address Contents
0 0x2
1 0x5
2 0x6
3 0x3
4 0x0

What we want the program to do is add M[0]+M[1]+M[2]+M[3]=0x2+0x5+0x6+0x3 = 0x10. (or 16 decimal)

Here is a program:

Operation Comment Code
CLRACC Set ACC to point to first location 000007b0
ACC->MAR Set up to read memory 000005a2
Mem->ACC Get M[0] 00000430
MAR+1->MAR Point MAR to M[1], Increment MAR using MAR+Cin, and setting Cin=1 00000c42
Mem+ACC->ACC Add M[1] to ACC. Cin must be 0 00000330
MAR+1->MAR Point MAR to M[2] 00000c42
Mem+ACC->ACC Add M[2] to ACC 00000330
MAR+1->MAR Point MAR to M[3] 00000c42
Mem+ACC->ACC Add M[3] to ACC 00000330
MAR+1->MAR Point MAR to M[4] 00000c42
ACC->Mem Save Sum to M[4] 000005a1
Halt All done 00002000

The ROM image should look like:

v2.0 raw
7b0 5a2 430 c42 330 c42 330 c42
330 c42 330 c42 5a1 2000

Copy and paste the ROM image to a text file. Then go to the microcode ROM on the system, and load the file into the ROM. Make sure it works.

To Do
  1. Get the Machine to run the program above.
  2. Paste a picture of the machine and the sequencer into the lab report after the program has run correctly
  3. Write a program to do the following:
    M[0] ^ Input v M[1] -> M[2] where Input = 0x3, M[0] = 0x5, M[1]=0x8.
    Start by making a table like above. Show the operations, and then convert the operations into HEX.
  4. Use the microprogram generator to create the ROM image. Load the ROM image into the ROM.
  5. Test the program out.
  6. Show of picture of the machine after running the program, and the ROM file that you created.

Final Questions

  1. Consider if you wanted to write code to multiple two arbitrary numbers. Could you do it? How, or why not?
  2. What if you wanted to average an array of numbers in memory, where the array size was specified by another word in memory?
  3. In general, what is missing from this too allow more general programming?
*
Topic attachments
I Attachment Action Size Date Who Comment
Pngpng DualBusALU4Reg.png manage 35.3 K 2014-11-04 - 21:09 JimSkon  
Pngpng DualBusALUMicro1.png manage 37.7 K 2014-10-14 - 18:09 JimSkon  
Pngpng EditingROM.png manage 23.5 K 2014-09-30 - 04:45 JimSkon  
Pngpng Lab7_-_Control.png manage 8.7 K 2014-10-06 - 01:33 JimSkon  
Pngpng Lab7_-_Overview.png manage 10.1 K 2014-09-30 - 03:06 JimSkon  
Pngpng SImpleSystemWithMAR.png manage 38.2 K 2014-10-14 - 18:18 JimSkon  
Pngpng SimpleMicroSequence_.png manage 21.4 K 2014-10-14 - 18:11 JimSkon  
Pngpng SimpleMicroSequencedSystem.png manage 22.7 K 2014-10-06 - 01:46 JimSkon  
Pngpng SimpleMicroSequencer.png manage 9.7 K 2014-09-30 - 03:57 JimSkon  
Pngpng counter.png manage 2.1 K 2014-10-04 - 18:51 JimSkon  
Pngpng counter2.png manage 3.9 K 2014-10-04 - 18:51 JimSkon  
Topic revision: r16 - 2014-11-15 - JimSkon
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback