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

Subversion Repositories hive

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

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

Line No. Rev Author Line
1 3 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
        //
48
        `define op_jmp_iez      op_jmp_iez[9:5]
49
        `define op_jmp_ilz      op_jmp_ilz[9:5]
50
        `define op_jmp_ilez     op_jmp_ilez[9:5]
51
        `define op_jmp_igz      op_jmp_igz[9:5]
52
        `define op_jmp_igez     op_jmp_igez[9:5]
53
        `define op_jmp_iglz     op_jmp_iglz[9:5]
54
        `define op_jmp_i                op_jmp_i[9:5]
55
        //
56
        `define op_wr_i         op_wr_i[9:4]
57
        `define op_wr_ix                op_wr_ix[9:4]
58
        //
59
        `define op_jmp_ie               op_jmp_ie[9:5]
60
        `define op_jmp_il               op_jmp_il[9:5]
61
        `define op_jmp_ile      op_jmp_ile[9:5]
62
        `define op_jmp_iug      op_jmp_iug[9:5]
63
        `define op_jmp_iuge     op_jmp_iuge[9:5]
64
        `define op_jmp_igl      op_jmp_igl[9:5]
65
        //
66
        `define op_byt_i                op_byt_i[9:8]
67
        //
68
        `define op_shl_i                op_shl_i[9:6]
69
        `define op_shl_iu               op_shl_iu[9:6]
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,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
116
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
117
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
118
        i=i+4;   ram[i] = { `op_jmp_i,       -5'h1, `_, `_, `s0, `s0 };  // loop forever
119
        i=i+4;   ram[i] = { `op_jmp_i,       -5'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,       -5'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,       -5'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,       -5'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 = 'd91 ('h5b).
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,       5'd15, `_, `_, `s0, `s1 };  // jump forward
174
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3
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,       5'd10, `_, `_, `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,        5'd6, `_, `_, `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,        5'd2, `_, `_, `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,        5'd8, `_, `_, `s0, `s1 };  // jump forward (and out)
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,       -5'd4, `_, `_, `s0, `s1 };  // jump back
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,       -5'd8, `_, `_, `s0, `s1 };  // jump back
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,      -5'd12, `_, `_, `s0, `s1 };  // jump back
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,      -5'd16, `_, `_, `s0, `s1 };  // jump back
191
        //
192
        // unconditional testing
193
        //
194
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s0, `s1 };  // jump (YYY)
195
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
196
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
197
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s0, `s2 };  // jump
198
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
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,        5'd1, `_, `_, `s0, `s0 };  // jump
201
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
202
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
203
        //
204
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s1, `s1 };  // jump (YYY)
205
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
206
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
207
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s1, `s2 };  // jump
208
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
209
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
210
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s1, `s0 };  // jump
211
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
212
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
213
        //
214
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s2, `s1 };  // jump (YYY)
215
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
216
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
217
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s2, `s2 };  // jump
218
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
219
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
220
        i=i+1;   ram[i] = { `op_jmp_i,        5'd1, `_, `_, `s2, `s0 };  // jump
221
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
222
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
223
        //
224
        // (A?0) testing
225
        // ez
226
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s1 };  // (s1==0) ? jump (NNY)
227
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
228
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s2 };  // (s2==0) ? jump
229
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
230
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? jump
231
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
232
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
233
        // lz
234
        i=i+1;   ram[i] = { `op_jmp_ilz,      5'd1, `_, `_, `s0, `s1 };  // (s1<0) ? jump (NYN)
235
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
236
        i=i+1;   ram[i] = { `op_jmp_ilz,      5'd1, `_, `_, `s0, `s2 };  // (s2<0) ? jump
237
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
238
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
239
        i=i+1;   ram[i] = { `op_jmp_ilz,      5'd1, `_, `_, `s0, `s0 };  // (s0<0) ? jump
240
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
241
        // lez
242
        i=i+1;   ram[i] = { `op_jmp_ilez,     5'd1, `_, `_, `s0, `s1 };  // (s1<=0) ? jump (NYY)
243
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
244
        i=i+1;   ram[i] = { `op_jmp_ilez,     5'd1, `_, `_, `s0, `s2 };  // (s2<=0) ? jump
245
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
246
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
247
        i=i+1;   ram[i] = { `op_jmp_ilez,     5'd1, `_, `_, `s0, `s0 };  // (s0<=0) ? jump
248
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
249
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
250
        // gz
251
        i=i+1;   ram[i] = { `op_jmp_igz,      5'd1, `_, `_, `s0, `s1 };  // (s1>0) ? jump (YNN)
252
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
253
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
254
        i=i+1;   ram[i] = { `op_jmp_igz,      5'd1, `_, `_, `s0, `s2 };  // (s2>0) ? jump
255
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
256
        i=i+1;   ram[i] = { `op_jmp_igz,      5'd1, `_, `_, `s0, `s0 };  // (s0>0) ? jump
257
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
258
        // gez
259
        i=i+1;   ram[i] = { `op_jmp_igez,     5'd1, `_, `_, `s0, `s1 };  // (s1>=0) ? jump (YNY)
260
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
261
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
262
        i=i+1;   ram[i] = { `op_jmp_igez,     5'd1, `_, `_, `s0, `s2 };  // (s2>=0) ? jump
263
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
264
        i=i+1;   ram[i] = { `op_jmp_igez,     5'd1, `_, `_, `s0, `s0 };  // (s0>=0) ? jump
265
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
266
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
267
        // glz
268
        i=i+1;   ram[i] = { `op_jmp_iglz,     5'd1, `_, `_, `s0, `s1 };  // (s1<>0) ? jump (YYN)
269
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
270
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
271
        i=i+1;   ram[i] = { `op_jmp_iglz,     5'd1, `_, `_, `s0, `s2 };  // (s2<>0) ? jump
272
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
273
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
274
        i=i+1;   ram[i] = { `op_jmp_iglz,     5'd1, `_, `_, `s0, `s0 };  // (s0<>0) ? jump
275
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
276
        //
277
        // (A?B) testing
278
        //
279
        // e
280
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s0, `s1 };  // (s1==s0) ? jump (NNY)
281
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
282
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s0, `s2 };  // (s2==s0) ? jump
283
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+2=>s3, pop s3 (N)
284
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s0, `s0 };  // (s0==s0) ? jump
285
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
286
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
287
        //
288
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s1, `s1 };  // (s1==s1) ? jump (YNN)
289
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
290
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
291
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s1, `s2 };  // (s2==s1) ? jump
292
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
293
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s1, `s0 };  // (s0==s1) ? jump
294
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
295
        //
296
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s2, `s1 };  // (s1==s2) ? jump (NYN)
297
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
298
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s2, `s2 };  // (s2==s2) ? jump
299
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
300
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
301
        i=i+1;   ram[i] = { `op_jmp_ie,       5'd1, `_, `_, `s2, `s0 };  // (s0==s2) ? jump
302
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
303
        // l
304
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s0, `s1 };  // (s1<s0) ? jump (NYN)
305
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
306
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s0, `s2 };  // (s2<s0) ? jump
307
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
308
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
309
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s0, `s0 };  // (s0<s0) ? jump
310
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
311
        //
312
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s1, `s1 };  // (s1<s1) ? jump (NYY)
313
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
314
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s1, `s2 };  // (s2<s1) ? jump
315
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
316
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
317
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s1, `s0 };  // (s0<s1) ? jump
318
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
319
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
320
        //
321
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s2, `s1 };  // (s1<s2) ? jump (NNN)
322
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
323
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s2, `s2 };  // (s2<s2) ? jump
324
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
325
        i=i+1;   ram[i] = { `op_jmp_il,       5'd1, `_, `_, `s2, `s0 };  // (s0<s2) ? jump
326
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
327
        // le
328
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s0, `s1 };  // (s1<=s0) ? jump (NYY)
329
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
330
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s0, `s2 };  // (s2<=s0) ? jump
331
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
332
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
333
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s0, `s0 };  // (s0<=s0) ? jump
334
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
335
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
336
        //
337
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s1, `s1 };  // (s1<=s1) ? jump (YYY)
338
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
339
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
340
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s1, `s2 };  // (s2<=s1) ? jump
341
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
342
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
343
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s1, `s0 };  // (s0<=s1) ? jump
344
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
345
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
346
        //
347
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s2, `s1 };  // (s1<=s2) ? jump (NYN)
348
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
349
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s2, `s2 };  // (s2<=s2) ? jump
350
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
351
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
352
        i=i+1;   ram[i] = { `op_jmp_ile,      5'd1, `_, `_, `s2, `s0 };  // (s0<=s2) ? jump
353
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
354
        // ug
355
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s0, `s1 };  // (s1>s0) ? jump (YYN)
356
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
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_iug,      5'd1, `_, `_, `s0, `s2 };  // (s2>s0) ? jump
359
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
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_iug,      5'd1, `_, `_, `s0, `s0 };  // (s0>s0) ? jump
362
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
363
        //
364
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s1, `s1 };  // (s1>s1) ? jump (NYN)
365
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
366
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s1, `s2 };  // (s2>s1) ? jump
367
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
368
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
369
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s1, `s0 };  // (s0>s1) ? jump
370
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
371
        //
372
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s2, `s1 };  // (s1>s2) ? jump (NNN)
373
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
374
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s2, `s2 };  // (s2>s2) ? jump
375
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
376
        i=i+1;   ram[i] = { `op_jmp_iug,      5'd1, `_, `_, `s2, `s0 };  // (s0>s2) ? jump
377
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
378
        // uge
379
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s0, `s1 };  // (s1>=s0) ? jump (YYY)
380
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
381
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
382
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s0, `s2 };  // (s2>=s0) ? jump
383
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
384
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
385
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s0, `s0 };  // (s0>=s0) ? jump
386
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
387
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
388
        //
389
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s1, `s1 };  // (s1>=s1) ? jump (YYN)
390
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
391
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
392
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s1, `s2 };  // (s2>=s1) ? jump
393
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
394
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
395
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s1, `s0 };  // (s0>=s1) ? jump
396
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
397
        //
398
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s2, `s1 };  // (s1>=s2) ? jump (NYN)
399
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
400
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s2, `s2 };  // (s2>=s2) ? jump
401
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
402
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
403
        i=i+1;   ram[i] = { `op_jmp_iuge,     5'd1, `_, `_, `s2, `s0 };  // (s0>=s2) ? jump
404
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
405
        // gl
406
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s0, `s1 };  // (s1<>s0) ? jump (YYN)
407
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
408
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
409
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s0, `s2 };  // (s2<>s0) ? jump
410
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
411
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
412
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s0, `s0 };  // (s0<>s0) ? jump
413
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
414
        //
415
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s1, `s1 };  // (s1<>s1) ? jump (NYY)
416
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
417
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s1, `s2 };  // (s2<>s1) ? jump
418
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
419
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
420
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s1, `s0 };  // (s0<>s1) ? jump
421
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
422
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
423
        //
424
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s2, `s1 };  // (s1<>s2) ? jump (YNY)
425
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
426
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
427
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s2, `s2 };  // (s2<>s2) ? jump
428
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
429
        i=i+1;   ram[i] = { `op_jmp_igl,      5'd1, `_, `_, `s2, `s0 };  // (s0<>s2) ? jump
430
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
431
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
432
        // cleanup
433
        i=i+1;   ram[i] = {  op_pop,                `P, `P, `s2, `s1 };  // pop s1 & s2
434
        // check for opcode errors
435
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
436
        i=i+1;   ram[i] = 16'h900                                     ;  // addr
437
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
438
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
439
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
440
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
441
        // check for stack errors
442
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
443
        i=i+1;   ram[i] = 16'h910                                     ;  // addr
444
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
445
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
446
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
447
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
448
        // s3=>s0, return
449
        i=i+1;   ram[i] = {  op_cpy,                `P, `P, `s3, `s0 };  // s3=>s0, pop both
450
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
451
        // end sub
452
 
453
 
454
        // sub : test all jmp instructions, result in s0, return to (s3)
455
        // Correct functioning is s0 = 'd29 ('h1D).
456
        //
457
        // s0 : 0 (ez), final test result
458
        // s1 : +1 (gz)
459
        // s2 : -2 (lz)
460
        // s3 : running test result, subroutine return address
461
        //
462
        // setup test values and running test result:
463
        i='h500; ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s0 };  // 0=>s0
464
        i=i+1;   ram[i] = { `op_byt_i,        8'd1, `_, `_, `s0, `s1 };  // 1=>s1
465
        i=i+1;   ram[i] = { `op_byt_i,       -8'd2, `_, `_, `s0, `s2 };  // -2=>s2
466
        i=i+1;   ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s3 };  // 1=>s1
467
        //
468
        // distance testing
469
        //
470
        i=i+1;   ram[i] = { `op_byt_i,       8'd15, `_, `_, `s0, `s2 };  // 15=>s2
471
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward, pop s2
472
        //
473
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
474
        i=i+1;   ram[i] = { `op_byt_i,        8'd9, `_, `_, `s0, `s2 };  // 9=>s2
475
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward, pop s2
476
        //
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_byt_i,        8'd3, `_, `_, `s0, `s2 };  // 3=>s2
479
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward, pop s2
480
        //
481
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
482
        i=i+1;   ram[i] = { `op_byt_i,        8'd9, `_, `_, `s0, `s2 };  // 9=>s2
483
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump forward (and out), pop s2
484
        //
485
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
486
        i=i+1;   ram[i] = { `op_byt_i,       -8'd6, `_, `_, `s0, `s2 };  // -6=>s2
487
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump back, pop s2
488
        //
489
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
490
        i=i+1;   ram[i] = { `op_byt_i,      -8'd12, `_, `_, `s0, `s2 };  // -12=>s2
491
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump back, pop s2
492
        //
493
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
494
        i=i+1;   ram[i] = { `op_byt_i,      -8'd18, `_, `_, `s0, `s2 };  // -18=>s2
495
        i=i+1;   ram[i] = {  op_jmp,                `P, `_, `s2, `s0 };  // jump back, pop s2
496
        //
497
        // unconditional testing
498
        //
499
        i=i+1;   ram[i] = {  op_jmp,                `_, `_, `s1, `s1 };  // jump (YYY)
500
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
501
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
502
        i=i+1;   ram[i] = {  op_jmp,                `_, `_, `s1, `s2 };  // jump
503
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
504
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
505
        i=i+1;   ram[i] = {  op_jmp,                `_, `_, `s1, `s0 };  // jump
506
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
507
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
508
        //
509
        // (A?0) testing
510
        // ez
511
        i=i+1;   ram[i] = {  op_jmp_ez,             `_, `_, `s1, `s1 };  // (s1==0) ? jump (NNY)
512
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
513
        i=i+1;   ram[i] = {  op_jmp_ez,             `_, `_, `s1, `s2 };  // (s2==0) ? jump
514
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
515
        i=i+1;   ram[i] = {  op_jmp_ez,             `_, `_, `s1, `s0 };  // (s0==0) ? jump
516
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
517
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
518
        // lz
519
        i=i+1;   ram[i] = {  op_jmp_lz,             `_, `_, `s1, `s1 };  // (s1<0) ? jump (NYN)
520
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
521
        i=i+1;   ram[i] = {  op_jmp_lz,             `_, `_, `s1, `s2 };  // (s2<0) ? jump
522
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
523
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
524
        i=i+1;   ram[i] = {  op_jmp_lz,             `_, `_, `s1, `s0 };  // (s0<0) ? jump
525
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
526
        // lez
527
        i=i+1;   ram[i] = {  op_jmp_lez,            `_, `_, `s1, `s1 };  // (s1<=0) ? jump (NYY)
528
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
529
        i=i+1;   ram[i] = {  op_jmp_lez,            `_, `_, `s1, `s2 };  // (s2<=0) ? jump
530
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
531
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
532
        i=i+1;   ram[i] = {  op_jmp_lez,            `_, `_, `s1, `s0 };  // (s0<=0) ? jump
533
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
534
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
535
        // gz
536
        i=i+1;   ram[i] = {  op_jmp_gz,             `_, `_, `s1, `s1 };  // (s1>0) ? jump (YNN)
537
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
538
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
539
        i=i+1;   ram[i] = {  op_jmp_gz,             `_, `_, `s1, `s2 };  // (s2>0) ? jump
540
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
541
        i=i+1;   ram[i] = {  op_jmp_gz,             `_, `_, `s1, `s0 };  // (s0>0) ? jump
542
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
543
        // gez
544
        i=i+1;   ram[i] = {  op_jmp_gez,            `_, `_, `s1, `s1 };  // (s1>=0) ? jump (YNY)
545
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
546
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
547
        i=i+1;   ram[i] = {  op_jmp_gez,            `_, `_, `s1, `s2 };  // (s2>=0) ? jump
548
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
549
        i=i+1;   ram[i] = {  op_jmp_gez,            `_, `_, `s1, `s0 };  // (s0>=0) ? jump
550
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
551
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
552
        // glz
553
        i=i+1;   ram[i] = {  op_jmp_glz,            `_, `_, `s1, `s1 };  // (s1<>0) ? jump (YYN)
554
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
555
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
556
        i=i+1;   ram[i] = {  op_jmp_glz,            `_, `_, `s1, `s2 };  // (s2<>0) ? jump
557
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
558
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
559
        i=i+1;   ram[i] = {  op_jmp_glz,            `_, `_, `s1, `s0 };  // (s0<>0) ? jump
560
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
561
        // cleanup
562
        i=i+1;   ram[i] = {  op_pop,                `P, `P, `s2, `s1 };  // pop s1 & s2
563
        // check for opcode errors
564
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
565
        i=i+1;   ram[i] = 16'h900                                     ;  // addr
566
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
567
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
568
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
569
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
570
        // check for stack errors
571
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
572
        i=i+1;   ram[i] = 16'h910                                     ;  // addr
573
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
574
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
575
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
576
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
577
        // s3=>s0, return
578
        i=i+1;   ram[i] = {  op_cpy,                `P, `P, `s3, `s0 };  // s3=>s0, pop both
579
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
580
        // end sub
581
 
582
 
583
        // sub : test all gto instructions, result in s0, return to (s3)
584
        // Correct functioning is s0 = 'd25 ('h19).
585
        //
586
        // s0 : 0 (ez), final test result
587
        // s1 : PC (gz)
588
        // s2 : -2 (lz)
589
        // s3 : running test result, subroutine return address
590
        //
591
        // setup test values and running test result:
592
        i='h700; ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s0 };  // 0=>s0
593
        i=i+1;   ram[i] = { `op_byt_i,       -8'd2, `_, `_, `s0, `s2 };  // -2=>s2
594
        i=i+1;   ram[i] = { `op_byt_i,        8'd0, `_, `_, `s0, `s3 };  // 1=>s1
595
        //
596
        // distance testing
597
        //
598
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
599
        i=i+1;   ram[i] = { `op_add_i,        6'd6, `_, `P, `s0, `s1 };  // s1+6=>s1, pop s1
600
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go forward, pop s1
601
        //
602
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
603
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
604
        i=i+1;   ram[i] = { `op_add_i,        6'd6, `_, `P, `s0, `s1 };  // s1+6=>s1, pop s1
605
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go forward, pop s1
606
        //
607
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
608
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
609
        i=i+1;   ram[i] = { `op_add_i,       -6'd6, `_, `P, `s0, `s1 };  // s1-6=>s1, pop s1
610
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go back, pop s1
611
        //
612
        // unconditional testing
613
        //
614
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
615
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
616
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s1 };  // go, pop s1 (YYY)
617
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
618
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
619
        //
620
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
621
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
622
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s2 };  // go, pop s1 (YYY)
623
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
624
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
625
        //
626
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
627
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
628
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s1, `s0 };  // go, pop s1 (YYY)
629
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
630
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
631
        //
632
        // (A?0) testing
633
        // ez
634
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
635
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
636
        i=i+1;   ram[i] = {  op_gto_ez,             `P, `_, `s1, `s1 };  // (s1==0) ? go, pop s1(NNY)
637
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
638
        //
639
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
640
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
641
        i=i+1;   ram[i] = {  op_gto_ez,             `P, `_, `s1, `s2 };  // (s2==0) ? go, pop s1
642
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
643
        //
644
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
645
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
646
        i=i+1;   ram[i] = {  op_gto_ez,             `P, `_, `s1, `s0 };  // (s0==0) ? go, pop s1
647
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
648
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
649
        // lz
650
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
651
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
652
        i=i+1;   ram[i] = {  op_gto_lz,             `P, `_, `s1, `s1 };  // (s1<0) ? go, pop s1(NYN)
653
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
654
        //
655
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
656
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
657
        i=i+1;   ram[i] = {  op_gto_lz,             `P, `_, `s1, `s2 };  // (s2<0) ? go, pop s1
658
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
659
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
660
        //
661
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
662
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
663
        i=i+1;   ram[i] = {  op_gto_lz,             `P, `_, `s1, `s0 };  // (s0<0) ? go, pop s1
664
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
665
        // lez
666
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
667
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
668
        i=i+1;   ram[i] = {  op_gto_lez,            `P, `_, `s1, `s1 };  // (s1<=0) ? go, pop s1(NYY)
669
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
670
        //
671
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
672
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
673
        i=i+1;   ram[i] = {  op_gto_lez,            `P, `_, `s1, `s2 };  // (s2<=0) ? go, pop s1
674
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
675
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
676
        //
677
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
678
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
679
        i=i+1;   ram[i] = {  op_gto_lez,            `P, `_, `s1, `s0 };  // (s0<=0) ? go, pop s1
680
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
681
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
682
        // gz
683
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
684
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
685
        i=i+1;   ram[i] = {  op_gto_gz,             `P, `_, `s1, `s1 };  // (s1>0) ? go, pop s1(YNN)
686
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
687
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
688
        //
689
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
690
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
691
        i=i+1;   ram[i] = {  op_gto_gz,             `P, `_, `s1, `s2 };  // (s2>0) ? go, pop s1
692
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
693
        //
694
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
695
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
696
        i=i+1;   ram[i] = {  op_gto_gz,             `P, `_, `s1, `s0 };  // (s0>0) ? go, pop s1
697
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
698
        // gez
699
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
700
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
701
        i=i+1;   ram[i] = {  op_gto_gez,            `P, `_, `s1, `s1 };  // (s1>=0) ? go, pop s1(YNY)
702
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
703
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
704
        //
705
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
706
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
707
        i=i+1;   ram[i] = {  op_gto_gez,            `P, `_, `s1, `s2 };  // (s2>=0) ? go, pop s1
708
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
709
        //
710
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
711
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
712
        i=i+1;   ram[i] = {  op_gto_gez,            `P, `_, `s1, `s0 };  // (s0>=0) ? go, pop s1
713
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
714
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
715
        // glz
716
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
717
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
718
        i=i+1;   ram[i] = {  op_gto_glz,            `P, `_, `s1, `s1 };  // (s1<>0) ? go, pop s1(YYN)
719
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
720
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
721
        //
722
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
723
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
724
        i=i+1;   ram[i] = {  op_gto_glz,            `P, `_, `s1, `s2 };  // (s2<>0) ? go, pop s1
725
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
726
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3
727
        //
728
        i=i+1;   ram[i] = {  op_pc,                 `_, `_, `s0, `s1 };  // pc => s1
729
        i=i+1;   ram[i] = { `op_add_i,        6'd3, `_, `P, `s0, `s1 };  // s1+3=>s1, pop s1
730
        i=i+1;   ram[i] = {  op_gto_glz,            `P, `_, `s1, `s0 };  // (s0<>0) ? go, pop s1
731
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `_, `P, `s0, `s3 };  // s3+1=>s3, pop s3 (N)
732
        // cleanup
733
        i=i+1;   ram[i] = {  op_pop,                `_, `P, `s0, `s2 };  // pop s2
734
        // check for opcode errors
735
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
736
        i=i+1;   ram[i] = 16'h900                                     ;  // addr
737
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
738
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
739
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
740
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
741
        // check for stack errors
742
        i=i+1;   ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
743
        i=i+1;   ram[i] = 16'h910                                     ;  // addr
744
        i=i+1;   ram[i] = {  op_gsb,                `P, `_, `s2, `s3 };  // gsb, pop s2 (addr)
745
        i=i+1;   ram[i] = { `op_jmp_iez,      5'd1, `_, `_, `s0, `s0 };  // (s0==0) ? skip
746
        i=i+1;   ram[i] = { `op_add_i,       -6'd1, `_, `P, `s0, `s3 };  // s3-1=>s3, pop s3 (Y)
747
        i=i+1;   ram[i] = { `op_add_i,        6'd1, `P, `P, `s0, `s3 };  // s3+1=>s3, pop both
748
        // s3=>s0, return
749
        i=i+1;   ram[i] = {  op_cpy,                `P, `P, `s3, `s0 };  // s3=>s0, pop both
750
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
751
        // end sub
752
 
753
 
754
        // sub : read & clear opcode errors for this thread => s0, return to (s3)
755
        i='h900; ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
756
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
757
        i=i+1;   ram[i] = { `op_rd_i, THRD_ID_ADDR, `_, `_, `s2, `s0 };  // read (s2+offset)=>s0
758
        i=i+1;   ram[i] = {  op_shl_u,              `_, `P, `s0, `s0 };  // 1<<s0=>s0, pop s0
759
        i=i+1;   ram[i] = { `op_rd_i,   OP_ER_ADDR, `_, `_, `s2, `s1 };  // read (s2+offset)=>s1
760
        i=i+1;   ram[i] = {  op_and,                `P, `P, `s1, `s0 };  // s0&s1=>s0, pop both
761
        i=i+1;   ram[i] = { `op_wr_i,   OP_ER_ADDR, `P, `_, `s2, `s0 };  // write s0=>(s2+offset), pop s2
762
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
763
 
764
 
765
        // sub : read & clear stack errors for this thread => s0, return to (s3)
766
        i='h910; ram[i] = {  op_lit_u,              `_, `_, `s0, `s2 };  // lit => s2
767
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
768
        i=i+1;   ram[i] = { `op_rd_i, THRD_ID_ADDR, `_, `_, `s2, `s0 };  // read (s2+offset)=>s0
769
        i=i+1;   ram[i] = {  op_shl_u,              `_, `P, `s0, `s0 };  // 1<<s0=>s0, pop s0
770
        i=i+1;   ram[i] = {  op_cpy,                `_, `_, `s0, `s1 };  // s0=>s1
771
        i=i+1;   ram[i] = { `op_shl_i,        6'd8, `_, `P, `s0, `s1 };  // s1<<8=>s1, pop s1
772
        i=i+1;   ram[i] = {  op_or,                 `P, `P, `s1, `s0 };  // s0|s1=>s0, pop both
773
        i=i+1;   ram[i] = { `op_rd_i,  STK_ER_ADDR, `_, `_, `s2, `s1 };  // read (s2+offset)=>s1
774
        i=i+1;   ram[i] = {  op_and,                `P, `P, `s1, `s0 };  // s0&s1=>s0, pop both
775
        i=i+1;   ram[i] = { `op_wr_i,  STK_ER_ADDR, `P, `_, `s2, `s0 };  // write s0=>(s2+offset), pop s2
776
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return to (s3), pop s3
777
 
778
 
779
        // sub : read 32 bit GPIO => s0, return to (s3)
780
        i='h920; ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
781
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
782
        i=i+1;   ram[i] = { `op_rd_i,   IO_LO_ADDR, `_, `_, `s1, `s0 };  // read (s1+offset) => s0
783
        i=i+1;   ram[i] = { `op_rd_ix,  IO_HI_ADDR, `P, `P, `s1, `s0 };  // read (s1+offset) => s0, pop s1 & s0
784
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
785
 
786
 
787
        // sub : write s0 => 32 bit GPIO, return to (s3)
788
        i='h930; ram[i] = {  op_lit_u,              `_, `_, `s0, `s1 };  // lit => s1
789
        i=i+1;   ram[i] = REG_BASE_ADDR                               ;  // reg base addr
790
        i=i+1;   ram[i] = { `op_wr_i,   IO_LO_ADDR, `_, `_, `s1, `s0 };  // write s0 => (s1+offset)
791
        i=i+1;   ram[i] = { `op_wr_ix,  IO_HI_ADDR, `P, `_, `s1, `s0 };  // write s0 => (s1+offset), pop s1
792
        i=i+1;   ram[i] = {  op_gto,                `P, `_, `s3, `s0 };  // return, pop s3
793
 
794
 
795
        end

powered by: WebSVN 2.1.0

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