OpenCores
URL https://opencores.org/ocsvn/hive/hive/trunk

Subversion Repositories hive

[/] [hive/] [trunk/] [v01.09/] [boot_code/] [boot_code_v_branches.h] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module : boot_code.h
5
 
6
--------------------------------------------------------------------------------
7
 
8
Function:
9
- Boot code for a processor core.
10
 
11
Instantiates:
12
- Nothing.
13
 
14
Notes:
15
- For testing (@ core.v):
16
  CLR_BASE              = 'h0;
17
  CLR_SPAN              = 2;  // gives 4 instructions
18
  INTR_BASE             = 'h20;  // 'd32
19
  INTR_SPAN             = 2;  // gives 4 instructions
20
 
21
 
22
--------------------------------------------------------------------------------
23
*/
24
 
25
        /*
26
        -------------------------
27
        -- external parameters --
28
        -------------------------
29
        */
30
        `include "op_encode.h"
31
        `include "reg_set_addr.h"
32
 
33
        /*
34
        ------------------------------------------------------------
35
        -- defines that make programming code more human readable --
36
        ------------------------------------------------------------
37
        */
38
        `define s0                              2'd0
39
        `define s1                              2'd1
40
        `define s2                              2'd2
41
        `define s3                              2'd3
42
        `define _                               1'b0
43
        `define P                               1'b1
44
        //
45
        `define op_rd_i         op_rd_i[9:4]
46
        `define op_rd_ix                op_rd_ix[9:4]
47
        `define op_wr_i         op_wr_i[9:4]
48
        `define op_wr_ix                op_wr_ix[9:4]
49
        //
50
        `define op_jmp_ie               op_jmp_ie[9:5]
51
        `define op_jmp_iez      op_jmp_iez[9:5]
52
        `define op_jmp_il               op_jmp_il[9:5]
53
        `define op_jmp_ilz      op_jmp_ilz[9:5]
54
        `define op_jmp_ile      op_jmp_ile[9:5]
55
        `define op_jmp_ilez     op_jmp_ilez[9:5]
56
        `define op_jmp_iug      op_jmp_iug[9:5]
57
        `define op_jmp_igz      op_jmp_igz[9:5]
58
        `define op_jmp_iuge     op_jmp_iuge[9:5]
59
        `define op_jmp_igez     op_jmp_igez[9:5]
60
        `define op_jmp_igl      op_jmp_igl[9:5]
61
        `define op_jmp_iglz     op_jmp_iglz[9:5]
62
        //
63
        `define op_jmp_i                op_jmp_i[9:6]
64
        //
65
        `define op_byt_i                op_byt_i[9:8]
66
        //
67
        `define op_shl_i                op_shl_i[9:6]
68
        `define op_shl_iu               op_shl_iu[9:6]
69
        //
70
        `define op_add_i                op_add_i[9:6]
71
 
72
        /*
73
        ----------------------------------------
74
        -- initialize: fill with default data --
75
        ----------------------------------------
76
        */
77
        integer i;
78
 
79
        initial begin
80
 
81
/*      // fill with nop (some compilers need this)
82
        for ( i = 0; i < CAPACITY; i = i+1 ) begin
83
                ram[i] = { op_nop, `_, `_, `s0, `s0 };
84
        end
85
*/
86
 
87
        /*
88
        ---------------
89
        -- boot code --
90
        ---------------
91
        */
92
 
93
 
94
        // Thread 0 : test all jmp_i instructions
95
        // Thread 1 : test all jmp instructions
96
        // Thread 2 : test all gto instructions
97
        // Other threads : do nothing, loop forever
98
 
99
        ///////////////
100
        // clr space //
101
        ///////////////
102
 
103
        i='h0;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
104
        i=i+1;   ram[i] = 16'h040                                     ;  // addr
105
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // goto, pop s1 (addr)
106
        //
107
        i='h4;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
108
        i=i+1;   ram[i] = 16'h044                                     ;  // addr
109
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // goto, pop s1 (addr)
110
        //
111
        i='h8;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
112
        i=i+1;   ram[i] = 16'h048                                     ;  // addr
113
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // goto, pop s1 (addr)
114
        //
115
        i='hc;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
116
        i=i+4;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
117
        i=i+4;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
118
        i=i+4;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
119
        i=i+4;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
120
 
121
        ////////////////
122
        // intr space //
123
        ////////////////
124
 
125
        ///////////////////////
126
        // code & data space //
127
        ///////////////////////
128
 
129
        // thread 0 : do jmp_i tests
130
        i='h40;  ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
131
        i=i+1;   ram[i] = 16'h300                                     ;  // addr
132
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
133
        // loop forever
134
        i=i+1;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
135
 
136
        // thread 1 : do jmp tests
137
        i='h44;  ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
138
        i=i+1;   ram[i] = 16'h500                                     ;  // addr
139
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
140
        // loop forever
141
        i=i+1;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
142
 
143
        // thread 2 : do gto tests
144
        i='h48;  ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
145
        i=i+1;   ram[i] = 16'h700                                     ;  // addr
146
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
147
        // loop forever
148
        i=i+1;   ram[i] = { `op_jmp_i,       -6'h1, `_, `_, `s0, `s0 };  // loop forever
149
 
150
 
151
        /////////////////
152
        // subroutines //
153
        /////////////////
154
 
155
 
156
 
157
        // sub : test all jmp_i instructions, result in s0, return to (s3)
158
        // Correct functioning is s0 = 'd99 ('h63).
159
        //
160
        // s0 : 0 (ez), final test result
161
        // s1 : +1 (gz)
162
        // s2 : -2 (lz)
163
        // s3 : running test result, subroutine return address
164
        //
165
        // setup test values and running test result:
166
        i='h300; ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s0 };  // 0=>s0
167
        i=i+1;   ram[i] = { `op_byt_i,        8'd1, `_, `_, `s0, `s1 };  // 1=>s1
168
        i=i+1;   ram[i] = { `op_byt_i,       -8'd2, `_, `_, `s0, `s2 };  // -2=>s2
169
        i=i+1;   ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s3 };  // 1=>s1
170
        //
171
        // distance testing
172
        //
173
        i=i+1;   ram[i] = { `op_jmp_i,       6'd31, `_, `_, `s0, `s1 };  // jump forward
174
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (won't happen)
175
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
176
        i=i+1;   ram[i] = { `op_jmp_i,       6'd26, `_, `_, `s0, `s1 };  // jump forward
177
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
178
        i=i+1;   ram[i] = { `op_jmp_i,       6'd22, `_, `_, `s0, `s1 };  // jump forward
179
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
180
        i=i+1;   ram[i] = { `op_jmp_i,       6'd18, `_, `_, `s0, `s1 };  // jump forward
181
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
182
        i=i+1;   ram[i] = { `op_jmp_i,       6'd14, `_, `_, `s0, `s1 };  // jump forward
183
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
184
        i=i+1;   ram[i] = { `op_jmp_i,       6'd10, `_, `_, `s0, `s1 };  // jump forward
185
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
186
        i=i+1;   ram[i] = { `op_jmp_i,        6'd6, `_, `_, `s0, `s1 };  // jump forward
187
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
188
        i=i+1;   ram[i] = { `op_jmp_i,        6'd2, `_, `_, `s0, `s1 };  // jump forward
189
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
190
        i=i+1;   ram[i] = { `op_jmp_i,       6'd16, `_, `_, `s0, `s1 };  // jump forward (and out)
191
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
192
        i=i+1;   ram[i] = { `op_jmp_i,       -6'd4, `_, `_, `s0, `s1 };  // jump back
193
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
194
        i=i+1;   ram[i] = { `op_jmp_i,       -6'd8, `_, `_, `s0, `s1 };  // jump back
195
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
196
        i=i+1;   ram[i] = { `op_jmp_i,      -6'd12, `_, `_, `s0, `s1 };  // jump back
197
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
198
        i=i+1;   ram[i] = { `op_jmp_i,      -6'd16, `_, `_, `s0, `s1 };  // jump back
199
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
200
        i=i+1;   ram[i] = { `op_jmp_i,      -6'd20, `_, `_, `s0, `s1 };  // jump back
201
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
202
        i=i+1;   ram[i] = { `op_jmp_i,      -6'd24, `_, `_, `s0, `s1 };  // jump back
203
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
204
        i=i+1;   ram[i] = { `op_jmp_i,      -6'd28, `_, `_, `s0, `s1 };  // jump back
205
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
206
        i=i+1;   ram[i] = { `op_jmp_i,      -6'd32, `_, `_, `s0, `s1 };  // jump back
207
        //
208
        // unconditional testing
209
        //
210
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s0, `s1 };  // jump (YYY)
211
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
212
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
213
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s0, `s2 };  // jump
214
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
215
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
216
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s0, `s0 };  // jump
217
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
218
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
219
        //
220
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s1, `s1 };  // jump (YYY)
221
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
222
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
223
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s1, `s2 };  // jump
224
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
225
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
226
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s1, `s0 };  // jump
227
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
228
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
229
        //
230
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s2, `s1 };  // jump (YYY)
231
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
232
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
233
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s2, `s2 };  // jump
234
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
235
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
236
        i=i+1;   ram[i] = { `op_jmp_i,        6'd1, `_, `_, `s2, `s0 };  // jump
237
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
238
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
239
        //
240
        // (A?0) testing
241
        // ez
242
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s1 };  // (s1==0) ? jump (NNY)
243
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
244
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
245
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s2 };  // (s2==0) ? jump
246
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
247
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
248
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? jump
249
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
250
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
251
        // lz
252
        i=i+1;   ram[i] = { `op_jmp_ilz,      5'd1, `_, `_, `s0, `s1 };  // (s1<0) ? jump (NYN)
253
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
254
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
255
        i=i+1;   ram[i] = { `op_jmp_ilz,      5'd1, `_, `_, `s0, `s2 };  // (s2<0) ? jump
256
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
257
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
258
        i=i+1;   ram[i] = { `op_jmp_ilz,      5'd1, `_, `_, `s0, `s0 };  // (s0<0) ? jump
259
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
260
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
261
        // lez
262
        i=i+1;   ram[i] = { `op_jmp_ilez,     5'd1, `_, `_, `s0, `s1 };  // (s1<=0) ? jump (NYY)
263
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
264
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
265
        i=i+1;   ram[i] = { `op_jmp_ilez,     5'd1, `_, `_, `s0, `s2 };  // (s2<=0) ? jump
266
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
267
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
268
        i=i+1;   ram[i] = { `op_jmp_ilez,     5'd1, `_, `_, `s0, `s0 };  // (s0<=0) ? jump
269
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
270
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
271
        // gz
272
        i=i+1;   ram[i] = { `op_jmp_igz,      5'd1, `_, `_, `s0, `s1 };  // (s1>0) ? jump (YNN)
273
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
274
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
275
        i=i+1;   ram[i] = { `op_jmp_igz,      5'd1, `_, `_, `s0, `s2 };  // (s2>0) ? jump
276
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
277
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
278
        i=i+1;   ram[i] = { `op_jmp_igz,      5'd1, `_, `_, `s0, `s0 };  // (s0>0) ? jump
279
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
280
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
281
        // gez
282
        i=i+1;   ram[i] = { `op_jmp_igez,     5'd1, `_, `_, `s0, `s1 };  // (s1>=0) ? jump (YNY)
283
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
284
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
285
        i=i+1;   ram[i] = { `op_jmp_igez,     5'd1, `_, `_, `s0, `s2 };  // (s2>=0) ? jump
286
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
287
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
288
        i=i+1;   ram[i] = { `op_jmp_igez,     5'd1, `_, `_, `s0, `s0 };  // (s0>=0) ? jump
289
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
290
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
291
        // glz
292
        i=i+1;   ram[i] = { `op_jmp_iglz,     5'd1, `_, `_, `s0, `s1 };  // (s1<>0) ? jump (YYN)
293
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
294
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
295
        i=i+1;   ram[i] = { `op_jmp_iglz,     5'd1, `_, `_, `s0, `s2 };  // (s2<>0) ? jump
296
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
297
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
298
        i=i+1;   ram[i] = { `op_jmp_iglz,     5'd1, `_, `_, `s0, `s0 };  // (s0<>0) ? jump
299
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
300
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
301
        //
302
        // (A?B) testing
303
        //
304
        // e
305
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s0, `s1 };  // (s1==s0) ? jump (NNY)
306
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
307
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
308
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s0, `s2 };  // (s2==s0) ? jump
309
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
310
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
311
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s0, `s0 };  // (s0==s0) ? jump
312
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
313
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
314
        //
315
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s1, `s1 };  // (s1==s1) ? jump (YNN)
316
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
317
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
318
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s1, `s2 };  // (s2==s1) ? jump
319
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
320
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
321
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s1, `s0 };  // (s0==s1) ? jump
322
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
323
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
324
        //
325
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s2, `s1 };  // (s1==s2) ? jump (NYN)
326
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
327
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
328
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s2, `s2 };  // (s2==s2) ? jump
329
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
330
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
331
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s2, `s0 };  // (s0==s2) ? jump
332
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
333
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
334
        // l
335
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s0, `s1 };  // (s1<s0) ? jump (NYN)
336
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
337
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
338
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s0, `s2 };  // (s2<s0) ? jump
339
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
340
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
341
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s0, `s0 };  // (s0<s0) ? jump
342
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
343
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
344
        //
345
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s1, `s1 };  // (s1<s1) ? jump (NYY)
346
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
347
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
348
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s1, `s2 };  // (s2<s1) ? jump
349
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
350
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
351
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s1, `s0 };  // (s0<s1) ? jump
352
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
353
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
354
        //
355
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s2, `s1 };  // (s1<s2) ? jump (NNN)
356
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
357
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
358
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s2, `s2 };  // (s2<s2) ? jump
359
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
360
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
361
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s2, `s0 };  // (s0<s2) ? jump
362
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
363
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
364
        // le
365
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s0, `s1 };  // (s1<=s0) ? jump (NYY)
366
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
367
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
368
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s0, `s2 };  // (s2<=s0) ? jump
369
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
370
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
371
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s0, `s0 };  // (s0<=s0) ? jump
372
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
373
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
374
        //
375
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s1, `s1 };  // (s1<=s1) ? jump (YYY)
376
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
377
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
378
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s1, `s2 };  // (s2<=s1) ? jump
379
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
380
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
381
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s1, `s0 };  // (s0<=s1) ? jump
382
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
383
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
384
        //
385
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s2, `s1 };  // (s1<=s2) ? jump (NYN)
386
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
387
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
388
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s2, `s2 };  // (s2<=s2) ? jump
389
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
390
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
391
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s2, `s0 };  // (s0<=s2) ? jump
392
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
393
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
394
        // ug
395
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s0, `s1 };  // (s1>s0) ? jump (YYN)
396
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
397
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
398
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s0, `s2 };  // (s2>s0) ? jump
399
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
400
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
401
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s0, `s0 };  // (s0>s0) ? jump
402
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
403
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
404
        //
405
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s1, `s1 };  // (s1>s1) ? jump (NYN)
406
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
407
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
408
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s1, `s2 };  // (s2>s1) ? jump
409
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
410
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
411
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s1, `s0 };  // (s0>s1) ? jump
412
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
413
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
414
        //
415
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s2, `s1 };  // (s1>s2) ? jump (NNN)
416
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
417
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
418
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s2, `s2 };  // (s2>s2) ? jump
419
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
420
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
421
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s2, `s0 };  // (s0>s2) ? jump
422
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
423
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
424
        // uge
425
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s0, `s1 };  // (s1>=s0) ? jump (YYY)
426
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
427
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
428
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s0, `s2 };  // (s2>=s0) ? jump
429
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
430
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
431
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s0, `s0 };  // (s0>=s0) ? jump
432
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
433
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
434
        //
435
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s1, `s1 };  // (s1>=s1) ? jump (YYN)
436
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
437
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
438
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s1, `s2 };  // (s2>=s1) ? jump
439
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
440
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
441
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s1, `s0 };  // (s0>=s1) ? jump
442
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
443
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
444
        //
445
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s2, `s1 };  // (s1>=s2) ? jump (NYN)
446
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
447
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
448
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s2, `s2 };  // (s2>=s2) ? jump
449
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
450
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
451
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s2, `s0 };  // (s0>=s2) ? jump
452
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
453
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
454
        // gl
455
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s0, `s1 };  // (s1<>s0) ? jump (YYN)
456
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
457
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
458
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s0, `s2 };  // (s2<>s0) ? jump
459
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
460
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
461
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s0, `s0 };  // (s0<>s0) ? jump
462
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
463
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
464
        //
465
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s1, `s1 };  // (s1<>s1) ? jump (NYY)
466
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
467
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
468
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s1, `s2 };  // (s2<>s1) ? jump
469
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
470
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
471
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s1, `s0 };  // (s0<>s1) ? jump
472
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
473
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
474
        //
475
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s2, `s1 };  // (s1<>s2) ? jump (YNY)
476
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
477
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
478
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s2, `s2 };  // (s2<>s2) ? jump
479
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
480
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
481
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s2, `s0 };  // (s0<>s2) ? jump
482
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
483
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
484
        // cleanup
485
        i=i+1;   ram[i] = {  op_pop,                `P, `P, `s2, `s1 };  // pop s1 & s2
486
        // check for opcode errors
487
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
488
        i=i+1;   ram[i] = 16'h900                                     ;  // addr
489
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
490
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
491
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
492
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
493
        // check for stack errors
494
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
495
        i=i+1;   ram[i] = 16'h910                                     ;  // addr
496
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
497
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
498
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
499
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
500
        // s3=>s0, return
501
        i=i+1;   ram[i] = {  op_cpy,                `P, `P, `s3, `s0 };  // s3=>s0, pop both
502
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
503
        // end sub
504
 
505
 
506
        // sub : test all jmp instructions, result in s0, return to (s3)
507
        // Correct functioning is s0 = 'd29 ('h1D).
508
        //
509
        // s0 : 0 (ez), final test result
510
        // s1 : +1 (gz)
511
        // s2 : -2 (lz)
512
        // s3 : running test result, subroutine return address
513
        //
514
        // setup test values and running test result:
515
        i='h500; ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s0 };  // 0=>s0
516
        i=i+1;   ram[i] = { `op_byt_i,        8'd1, `_, `_, `s0, `s1 };  // 1=>s1
517
        i=i+1;   ram[i] = { `op_byt_i,       -8'd2, `_, `_, `s0, `s2 };  // -2=>s2
518
        i=i+1;   ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s3 };  // 1=>s1
519
        //
520
        // distance testing
521
        //
522
        i=i+1;   ram[i] = { `op_byt_i,       8'd15, `_, `_, `s0, `s2 };  // 15=>s2
523
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward, pop s2
524
        //
525
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
526
        i=i+1;   ram[i] = { `op_byt_i,        8'd9, `_, `_, `s0, `s2 };  // 9=>s2
527
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward, pop s2
528
        //
529
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
530
        i=i+1;   ram[i] = { `op_byt_i,        8'd3, `_, `_, `s0, `s2 };  // 3=>s2
531
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward, pop s2
532
        //
533
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
534
        i=i+1;   ram[i] = { `op_byt_i,        8'd9, `_, `_, `s0, `s2 };  // 9=>s2
535
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward (and out), pop s2
536
        //
537
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
538
        i=i+1;   ram[i] = { `op_byt_i,       -8'd6, `_, `_, `s0, `s2 };  // -6=>s2
539
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump back, pop s2
540
        //
541
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
542
        i=i+1;   ram[i] = { `op_byt_i,      -8'd12, `_, `_, `s0, `s2 };  // -12=>s2
543
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump back, pop s2
544
        //
545
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
546
        i=i+1;   ram[i] = { `op_byt_i,      -8'd18, `_, `_, `s0, `s2 };  // -18=>s2
547
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump back, pop s2
548
        //
549
        // unconditional testing
550
        //
551
        i=i+1;   ram[i] = {  op_jmp,                `_, `_, `s1, `s1 };  // jump (YYY)
552
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
553
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
554
        i=i+1;   ram[i] = {  op_jmp,                `_, `_, `s1, `s2 };  // jump
555
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
556
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
557
        i=i+1;   ram[i] = {  op_jmp,                `_, `_, `s1, `s0 };  // jump
558
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
559
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
560
        //
561
        // (A?0) testing
562
        // ez
563
        i=i+1;   ram[i] = {  op_jmp_ez,             `_, `_, `s1, `s1 };  // (s1==0) ? jump (NNY)
564
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
565
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
566
        i=i+1;   ram[i] = {  op_jmp_ez,             `_, `_, `s1, `s2 };  // (s2==0) ? jump
567
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
568
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
569
        i=i+1;   ram[i] = {  op_jmp_ez,             `_, `_, `s1, `s0 };  // (s0==0) ? jump
570
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
571
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
572
        // lz
573
        i=i+1;   ram[i] = {  op_jmp_lz,             `_, `_, `s1, `s1 };  // (s1<0) ? jump (NYN)
574
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
575
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
576
        i=i+1;   ram[i] = {  op_jmp_lz,             `_, `_, `s1, `s2 };  // (s2<0) ? jump
577
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
578
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
579
        i=i+1;   ram[i] = {  op_jmp_lz,             `_, `_, `s1, `s0 };  // (s0<0) ? jump
580
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
581
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
582
        // lez
583
        i=i+1;   ram[i] = {  op_jmp_lez,            `_, `_, `s1, `s1 };  // (s1<=0) ? jump (NYY)
584
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
585
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
586
        i=i+1;   ram[i] = {  op_jmp_lez,            `_, `_, `s1, `s2 };  // (s2<=0) ? jump
587
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
588
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
589
        i=i+1;   ram[i] = {  op_jmp_lez,            `_, `_, `s1, `s0 };  // (s0<=0) ? jump
590
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
591
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
592
        // gz
593
        i=i+1;   ram[i] = {  op_jmp_gz,             `_, `_, `s1, `s1 };  // (s1>0) ? jump (YNN)
594
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
595
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
596
        i=i+1;   ram[i] = {  op_jmp_gz,             `_, `_, `s1, `s2 };  // (s2>0) ? jump
597
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
598
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
599
        i=i+1;   ram[i] = {  op_jmp_gz,             `_, `_, `s1, `s0 };  // (s0>0) ? jump
600
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
601
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
602
        // gez
603
        i=i+1;   ram[i] = {  op_jmp_gez,            `_, `_, `s1, `s1 };  // (s1>=0) ? jump (YNY)
604
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
605
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
606
        i=i+1;   ram[i] = {  op_jmp_gez,            `_, `_, `s1, `s2 };  // (s2>=0) ? jump
607
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
608
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
609
        i=i+1;   ram[i] = {  op_jmp_gez,            `_, `_, `s1, `s0 };  // (s0>=0) ? jump
610
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
611
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
612
        // glz
613
        i=i+1;   ram[i] = {  op_jmp_glz,            `_, `_, `s1, `s1 };  // (s1<>0) ? jump (YYN)
614
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
615
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
616
        i=i+1;   ram[i] = {  op_jmp_glz,            `_, `_, `s1, `s2 };  // (s2<>0) ? jump
617
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
618
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
619
        i=i+1;   ram[i] = {  op_jmp_glz,            `_, `_, `s1, `s0 };  // (s0<>0) ? jump
620
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
621
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
622
        // cleanup
623
        i=i+1;   ram[i] = {  op_pop,                `P, `P, `s2, `s1 };  // pop s1 & s2
624
        // check for opcode errors
625
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
626
        i=i+1;   ram[i] = 16'h900                                     ;  // addr
627
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
628
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
629
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
630
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
631
        // check for stack errors
632
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
633
        i=i+1;   ram[i] = 16'h910                                     ;  // addr
634
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
635
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
636
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
637
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
638
        // s3=>s0, return
639
        i=i+1;   ram[i] = {  op_cpy,                `P, `P, `s3, `s0 };  // s3=>s0, pop both
640
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
641
        // end sub
642
 
643
 
644
        // sub : test all gto instructions, result in s0, return to (s3)
645
        // Correct functioning is s0 = 'd25 ('h19).
646
        //
647
        // s0 : 0 (ez), final test result
648
        // s1 : PC (gz)
649
        // s2 : -2 (lz)
650
        // s3 : running test result, subroutine return address
651
        //
652
        // setup test values and running test result:
653
        i='h700; ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s0 };  // 0=>s0
654
        i=i+1;   ram[i] = { `op_byt_i,       -8'd2, `_, `_, `s0, `s2 };  // -2=>s2
655
        i=i+1;   ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s3 };  // 1=>s1
656
        //
657
        // distance testing
658
        //
659
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
660
        i=i+1;   ram[i] = { `op_add_i,        6'd6, `_, `P, `s0, `s1 };  // s1+6=>s1, pop s1
661
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go forward, pop s1
662
        //
663
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
664
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
665
        i=i+1;   ram[i] = { `op_add_i,        6'd6, `_, `P, `s0, `s1 };  // s1+6=>s1, pop s1
666
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go forward, pop s1
667
        //
668
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
669
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
670
        i=i+1;   ram[i] = { `op_add_i,       -6'd6, `_, `P, `s0, `s1 };  // s1-6=>s1, pop s1
671
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go back, pop s1
672
        //
673
        // unconditional testing
674
        //
675
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
676
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
677
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s1 };  // go, pop s1 (YYY)
678
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
679
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
680
        //
681
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
682
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
683
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s2 };  // go, pop s1 (YYY)
684
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
685
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
686
        //
687
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
688
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
689
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go, pop s1 (YYY)
690
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
691
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
692
        //
693
        // (A?0) testing
694
        // ez
695
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
696
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
697
        i=i+1;   ram[i] = {  op_gto_ez,             `P, `_, `s1, `s1 };  // (s1==0) ? go, pop s1(NNY)
698
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
699
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
700
        //
701
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
702
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
703
        i=i+1;   ram[i] = {  op_gto_ez,             `P, `_, `s1, `s2 };  // (s2==0) ? go, pop s1
704
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
705
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
706
        //
707
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
708
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
709
        i=i+1;   ram[i] = {  op_gto_ez,             `P, `_, `s1, `s0 };  // (s0==0) ? go, pop s1
710
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
711
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
712
        // lz
713
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
714
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
715
        i=i+1;   ram[i] = {  op_gto_lz,             `P, `_, `s1, `s1 };  // (s1<0) ? go, pop s1(NYN)
716
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
717
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
718
        //
719
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
720
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
721
        i=i+1;   ram[i] = {  op_gto_lz,             `P, `_, `s1, `s2 };  // (s2<0) ? go, pop s1
722
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
723
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
724
        //
725
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
726
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
727
        i=i+1;   ram[i] = {  op_gto_lz,             `P, `_, `s1, `s0 };  // (s0<0) ? go, pop s1
728
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
729
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
730
        // lez
731
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
732
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
733
        i=i+1;   ram[i] = {  op_gto_lez,            `P, `_, `s1, `s1 };  // (s1<=0) ? go, pop s1(NYY)
734
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
735
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
736
        //
737
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
738
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
739
        i=i+1;   ram[i] = {  op_gto_lez,            `P, `_, `s1, `s2 };  // (s2<=0) ? go, pop s1
740
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
741
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
742
        //
743
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
744
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
745
        i=i+1;   ram[i] = {  op_gto_lez,            `P, `_, `s1, `s0 };  // (s0<=0) ? go, pop s1
746
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
747
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
748
        // gz
749
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
750
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
751
        i=i+1;   ram[i] = {  op_gto_gz,             `P, `_, `s1, `s1 };  // (s1>0) ? go, pop s1(YNN)
752
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
753
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
754
        //
755
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
756
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
757
        i=i+1;   ram[i] = {  op_gto_gz,             `P, `_, `s1, `s2 };  // (s2>0) ? go, pop s1
758
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
759
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
760
        //
761
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
762
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
763
        i=i+1;   ram[i] = {  op_gto_gz,             `P, `_, `s1, `s0 };  // (s0>0) ? go, pop s1
764
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
765
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
766
        // gez
767
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
768
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
769
        i=i+1;   ram[i] = {  op_gto_gez,            `P, `_, `s1, `s1 };  // (s1>=0) ? go, pop s1(YNY)
770
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
771
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
772
        //
773
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
774
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
775
        i=i+1;   ram[i] = {  op_gto_gez,            `P, `_, `s1, `s2 };  // (s2>=0) ? go, pop s1
776
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
777
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
778
        //
779
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
780
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
781
        i=i+1;   ram[i] = {  op_gto_gez,            `P, `_, `s1, `s0 };  // (s0>=0) ? go, pop s1
782
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
783
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
784
        // glz
785
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
786
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
787
        i=i+1;   ram[i] = {  op_gto_glz,            `P, `_, `s1, `s1 };  // (s1<>0) ? go, pop s1(YYN)
788
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
789
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
790
        //
791
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
792
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
793
        i=i+1;   ram[i] = {  op_gto_glz,            `P, `_, `s1, `s2 };  // (s2<>0) ? go, pop s1
794
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
795
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
796
        //
797
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
798
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
799
        i=i+1;   ram[i] = {  op_gto_glz,            `P, `_, `s1, `s0 };  // (s0<>0) ? go, pop s1
800
        i=i+1;   ram[i] = { `op_add_i,        6'd2, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
801
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
802
        // cleanup
803
        i=i+1;   ram[i] = {  op_pop,                `_, `P, `s0, `s2 };  // pop s2
804
        // check for opcode errors
805
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
806
        i=i+1;   ram[i] = 16'h900                                     ;  // addr
807
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
808
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
809
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
810
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
811
        // check for stack errors
812
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
813
        i=i+1;   ram[i] = 16'h910                                     ;  // addr
814
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
815
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
816
        i=i+1;   ram[i] = { `op_add_i,       -6'd2, `_, `P, `s0, `s3 };  // s3-2=>s3, pop s3 (Y)
817
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
818
        // s3=>s0, return
819
        i=i+1;   ram[i] = {  op_cpy,                `P, `P, `s3, `s0 };  // s3=>s0, pop both
820
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
821
        // end sub
822
 
823
 
824
        // sub : read & clear opcode errors for this thread => s0, return to (s3)
825
        i='h900; ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
826
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
827
        i=i+1;   ram[i] = { `op_rd_i, THRD_ID_ADDR, `_, `_, `s2, `s0 };  // read (s2+offset)=>s0
828
        i=i+1;   ram[i] = {  op_shl_u,              `_, `P, `s0, `s0 };  // 1<<s0=>s0, pop s0
829
        i=i+1;   ram[i] = { `op_rd_i,   OP_ER_ADDR, `_, `_, `s2, `s1 };  // read (s2+offset)=>s1
830
        i=i+1;   ram[i] = {  op_and,                `P, `P, `s1, `s0 };  // s0&s1=>s0, pop both
831
        i=i+1;   ram[i] = { `op_wr_i,   OP_ER_ADDR, `P, `_, `s2, `s0 };  // write s0=>(s2+offset), pop s2
832
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
833
 
834
 
835
        // sub : read & clear stack errors for this thread => s0, return to (s3)
836
        i='h910; ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
837
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
838
        i=i+1;   ram[i] = { `op_rd_i, THRD_ID_ADDR, `_, `_, `s2, `s0 };  // read (s2+offset)=>s0
839
        i=i+1;   ram[i] = {  op_shl_u,              `_, `P, `s0, `s0 };  // 1<<s0=>s0, pop s0
840
        i=i+1;   ram[i] = {  op_cpy,                `_, `_, `s0, `s1 };  // s0=>s1
841
        i=i+1;   ram[i] = { `op_shl_i,        6'd8, `_, `P, `s0, `s1 };  // s1<<8=>s1, pop s1
842
        i=i+1;   ram[i] = {  op_or,                 `P, `P, `s1, `s0 };  // s0|s1=>s0, pop both
843
        i=i+1;   ram[i] = { `op_rd_i,  STK_ER_ADDR, `_, `_, `s2, `s1 };  // read (s2+offset)=>s1
844
        i=i+1;   ram[i] = {  op_and,                `P, `P, `s1, `s0 };  // s0&s1=>s0, pop both
845
        i=i+1;   ram[i] = { `op_wr_i,  STK_ER_ADDR, `P, `_, `s2, `s0 };  // write s0=>(s2+offset), pop s2
846
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
847
 
848
 
849
        // sub : read 32 bit GPIO => s0, return to (s3)
850
        i='h920; ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
851
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
852
        i=i+1;   ram[i] = { `op_rd_i,   IO_LO_ADDR, `_, `_, `s1, `s0 };  // read (s1+offset) => s0
853
        i=i+1;   ram[i] = { `op_rd_ix,  IO_HI_ADDR, `P, `P, `s1, `s0 };  // read (s1+offset) => s0, pop s1 & s0
854
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
855
 
856
 
857
        // sub : write s0 => 32 bit GPIO, return to (s3)
858
        i='h930; ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
859
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
860
        i=i+1;   ram[i] = { `op_wr_i,   IO_LO_ADDR, `_, `_, `s1, `s0 };  // write s0 => (s1+offset)
861
        i=i+1;   ram[i] = { `op_wr_ix,  IO_HI_ADDR, `P, `_, `s1, `s0 };  // write s0 => (s1+offset), pop s1
862
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
863
 
864
 
865
        end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.