How to microprogram Sx
To write microprogram for Sx, the microprogram specification is in the
file "mspec.txt". "mgen" transforms the specification to a
"rom" file. Store it in the name "mpgm.txt". The
source for "mgen" can be found in sx0.zip package.
c:> mgen < mspec.txt >
mpgm.txt
Here is what mpgm.txt looked like.
62
0
00000000000010000000000001000000100010000001
1
00100001000100000000000100000010100000000010
2
00100010000000000001000000001000000000000011
3
10001010000001000000001000100001000000000000
4
10000010000001000000001000100001000000000000
. . .
55
00010010000001000000000100100001000000000000
56
10000010000000000000000100000100000000111001
57
01000101000100000100000000100000100000111010
58
10000010000000000001000000100000000000111011
59
01000100001100000100000000000000010000111100
60
00010010000001000000000100100001000000000000
61
00000000000001000000000000000001000001000000
A few right most bits are the next microprogram address. "mgen"
also generates binding of symbolic names to numeric values which are
used in the simulator, "mspec.h". This is it:
#define s_x_ts 0
#define s_x_fp 1
#define s_x_sp 2
#define s_x_nx 3
#define s_y_ff 4
. . .
#define a_fetch 0
#define a_bop 1
#define a_uop 4
#define a_get 5
#define a_put 8
#define a_popts 9
#define a_ld 11
. . .
#define a_end 61
#define MCWIDTH 38
#define MAWIDTH 6
#define MLEN 62
The event names prefixed "s_" are the signal events, prefixed "a_" are
the address of the label of microprogram. The MCWIDTH is
the number of the control bits. The MAWIDTH is the number of bit
of the microprogram address field. The MLEN is the number of
microprogram word. "mgen" also generates a listing file
"mlist.txt". It is used for debugging.
The next step is to convert this micro-rom into an event-list.
"sxgen" combines "mgen" and conversion to event-list. (If you are
using sx1, sx2 simulator, sxgen is inside the simulator, you don't have
to do it explicitly). "sxgen" reads the files "mpgm.txt" and
"mspec.h" then generates "sxbit.h" which must be compiled with the
simulator.
c:> sxgen < mspec.txt
The sxbit.h contains the binding, the op-decoder-rom (udop[]),
the pointer to event-list (mw[]), the event-list itself (mx[]) and
finally the next-address-rom (nxt[]).
#define s_x_ts 0
#define s_x_fp 1
. . .
#define a_sys 51
#define a_array 51
#define a_end 51
#define MCWIDTH 38
#define MAWIDTH 6
#define MLEN 52
int udop[] = {
0, 1, 1, 1, 1, 1, 1, 1, 4, 1,
1, 1, 1, 1, 1, 1, 1, 0, 15, 18,
40, 0, 51, 51, 5, 8, 11, 14, 26,
27,
30, 23, 33, 0, 0, 0, 51, 0, 0, 0,
0 };
int mw[] = {
0, 5, 12, 17, 25, 32, 37, 43, 53,
60,
67, 74, 79, 85, 94, 100, 107,
112, 122, 129,
134, 141, 148, 153, 158, 164,
171, 174, 178, 187,
192, 196, 205, 210, 215, 223,
226, 234, 241, 248,
253, 258, 263, 268, 274, 281,
286, 293, 300, 305,
311, 318, 0 };
int mx[] = {
12, 32, 25, 36, -1,
2, 23, 11, 32, 7, 30, -1,
2, 19, 6, 28, -1,
0, 4, 22, 6, 13, 31, 26, -1,
. . .
1, 5, 17, 6, 28, -1,
1, 23, 11, 32, 7, 27, -1,
13, 31, 37, -1,
0 };
int nxt[] = {
1, 2, 3, 0, 0, 6, 7, 0, 9, 10,
0, 12, 13, 0, 9, 16, 17, 0, 19,
20,
21, 22, 9, 24, 25, 0, 0, 31, 29,
0,
28, 32, 0, 34, 35, 36, 37, 38,
39, 0,
41, 47, 43, 44, 45, 46, 0, 48,
49, 50,
0, 0, 0 };
You must recompile the simulator to include your new signal defintions,
or new instruction labels. The processor simulator takes a proper
object file as input and run it. If it is sx0, the processor is
run in a batch mode. For sx1 and sx2 they run in interactive
mode. You can ask for help by typing "h". The following
session is sx0 running quicksort.
D:\prabhas\bag\Chip\sx0\test>sx
qs.obj
load program, last address 203
DP 1000
20 19 18 17 16 15 14 13 12 11 10
9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 16 17 18 19 20
4820 instructions, 20231 clocks,
CPI 4.20
D:\prabhas\bag\Chip\sx0\test>
last update 8 Aug 2006