S1 microprogram systems


In the "s1mx.zip"  you will find the following files:

s1mx.h, s1mx.c, supportm.c     simulator files
mpgm.txt                                     microprogram file used by s1m.c
in.obj, in0.obj, in2.obj          test machine code
mgen.c, hash.c                           microprogram generator
mspec.txt                                   input microprogram in human readable form
 
The S1 microprogram  simulator takes machine code input from "in.obj" and executes it.  The control unit can be programmed by "microprogram", which is represented by "mpgm.txt".  To add new instruction, this microprogram must be altered.  To facilitate the writing of microprogram I wrote a simple macro processor, mgen.c, which will take input "mspec.txt", a human readable form of microprogram and output "mpgm.txt".

S1 microprogram bit position and coding form

bit field signal

0  dest   r
1         pc
2         ir
3         mar
4         mdr
5  src    r
6         pc
7         ir
8         mar
9         mdr
10        t
11        ir:disp
12 selr   ir:r0
13        ir:r1
14        ir:r2
15        ir:r12
16        r1p1
17        r2p1
18 alu    pass1
19        add
20        sub
21        add1
22 mctl   rd
23        wr
24 misc   pc+1
25 cond   u
26        mrdy
27        testcc
28        decode
29 goto   5 bits 29..33

How to use mgen.c to generate microprogram

Mgen takes input from microprogram specification which is a readable form that human programmer wrote.  Mgen is a simple macro processor that substitute symbolic names with numeric values (set microprogram bits). The output is in the form :
nn
aaaa xxxxxxxxxxxxxxxxxxx
....

where nn is the number of microword, aaaa is address and xxxxx... is
the microprogram bit.  xxx... begins at the column 5.

Input to mgen is in a simple form as follows :

.w N      // width of microword N bits
.a B E    // bit position of Goto field, B start, E end
.s        // start symbolic name section
name bit  // "name" is the signal at "bit" position
...
.m        // start microprogram section
:label name name ...  /label ;
          // lable begins with ":"
          // name is signal name
          // /label is in Goto field
          // ";" end a microword spec.
...
.e        end of microprogram spec.

Example from mspec.txt (comment shows here for explanation, no comments are allowed in mspec.txt).

.w 34       // width 34 bits
.a 29 33    // Goto start at bit 29 end at 33
.s          // symbol section
dr   0      // dest R bit 0
dpc  1      // dest PC bit 1
...
sub  20     // alu sub bit 20
add1 21
mrd  22     // memory read bit 22
mwr  23
pc+1 24
u    25     // Cond uncond bit 25
mrdy 26
testcc 27
decode 28
.m                              // microprogram section
:ifetch dmar spc ;              // <ifetch> MAR = PC
:w0     mrd mrdy /w0 ;          // MDR = M[MAR]; MREAD  MRDY w0
        dir smdr pc+1 decode ;  // IR = MDR; PC = PC + 1  DECODE
:load   dmar sir:ads ;          // <load> MAR = IR:ADS
:w1     mrd mrdy /w1 ;
        dr smdr ir:r0 u /ifetch ;
...
.e                              // end

This is the output (from mpgm.txt )

35
  0 000100100000000000000000000000000000
  1 000000000000000000000000100010000001
  2 001000000100000000000000001000100000
  3 000100010000000000000000000000000000
  4 000000000000000000000000100010000100
  5 100000000100100000000000000100000000
  . . .
 32 000000000100000010010100000000000000
 33 100000000010010000000000000100000000
 34 000000000000000000000000000100000000

S1m microprogram simulator reads this microprogram (mpgm.txt) to instantiate its microstore.  S1m runs the
same machine code program as S1, such as "in.obj" which is sum(a[0]..a[n]). The "in.obj" executed 1109
instructions 6054 clocks with CPI = 5.46
 
23 November 2001
Prabhas Chongstitvatana