S1 microprogram simulator package

Compile and test under Turbo C v2.0

file-list :

s1m.h
s1m.c
supportm.c	simulator files

mpgm.txt	microprogram file used by s1m.c
in.obj		test machine code

mgen.c
hash.c		microprogram generator

mspec.txt	input microprogram in human readable form

s1mx.txt	explain S1 instruction set and microprogram format.

Run mgen.exe, it takes input from mspec.txt and outputs a microprogram
in the form that s1m.exe can read. (see 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 selr	ir:r0
12	ir:r1
13	ir:r2
14	ir:r1,r2
15 alu	pass1
16	add
17	sub
18	add1
19 mctl	rd
20	wr
21 misc	pc+1
22 cond	u
23 	mrdy
24	testcc
25	decode
26 goto	5 bits 26..30

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 following :

.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 31			// width 31 bits
.a 26 30		// Goto start at bit 26 end at 30
.s			// symbol section
dr	0		// dest R bit 0
dpc	1		// dest PC bit 1
...
sub	17		// alu sub bit 17
add1	18
mrd	19		// memory read bit 19
mwr	20
pc+1	21
u	22		// Cond uncond bit 22
mrdy	23
testcc	24
decode	25
.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 )

29
  0 0001001000000000000000000000000
  1 0000000000000000000100010000001
  2 0010000001000000000001000100000
  3 0001000100000000000000000000000
  4 0000000000000000000100010000100
  5 1000000001010000000000100000000
  6 0001000100000000000000000000000
  ....
 27 0100000100000000000000100000000
 28 0100010000001000000000100000000

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


26 July 1998
Prabhas Chongstitvatana
