1 |
2 |
ericw |
`define ie 4'b0010
|
2 |
|
|
`define iez 4'b0011
|
3 |
|
|
`define il 4'b0100
|
4 |
|
|
`define ilz 4'b0101
|
5 |
|
|
`define ile 4'b0110
|
6 |
|
|
`define ilez 4'b0111
|
7 |
|
|
`define iug 4'b1000
|
8 |
|
|
`define igz 4'b1001
|
9 |
|
|
`define iuge 4'b1010
|
10 |
|
|
`define igez 4'b1011
|
11 |
|
|
`define igl 4'b1100
|
12 |
|
|
`define iglz 4'b1101
|
13 |
|
|
`define igle 3'b111
|
14 |
|
|
//
|
15 |
|
|
`define ez 3'b001
|
16 |
|
|
`define lz 3'b010
|
17 |
|
|
`define lez 3'b011
|
18 |
|
|
`define gz 3'b100
|
19 |
|
|
`define gez 3'b101
|
20 |
|
|
`define glz 3'b110
|
21 |
|
|
`define glez 3'b111
|
22 |
|
|
//
|
23 |
|
|
localparam OP_W = 10;
|
24 |
|
|
//
|
25 |
|
|
// immediate read & write - 64 codes
|
26 |
|
|
localparam [OP_W-1:0] op_rd_i = { 4'h0, 2'b00, 4'bxxxx }; // mem(B+I[3:0]) => A read immediate w/ offset (signed)
|
27 |
|
|
localparam [OP_W-1:0] op_rd_ix = { 4'h0, 2'b01, 4'bxxxx }; // {mem(B+I[3:0]), A[lo]} => A read immediate extended w/ offset
|
28 |
|
|
localparam [OP_W-1:0] op_wr_i = { 4'h0, 2'b10, 4'bxxxx }; // A[lo] => mem(B+I[3:0]) write immediate w/ offset
|
29 |
|
|
localparam [OP_W-1:0] op_wr_ix = { 4'h0, 2'b11, 4'bxxxx }; // A[hi] => mem(B+I[3:0]) write immediate extended w/ offset
|
30 |
|
|
// immediate conditional jump - 384 codes
|
31 |
|
|
localparam [OP_W-1:0] op_jmp_ie = { 1'b0, `ie, 5'bxxxxx }; // (A?B), (A?0) PC+I[4:0] => PC jump relative immediate conditional
|
32 |
|
|
localparam [OP_W-1:0] op_jmp_iez = { 1'b0, `iez, 5'bxxxxx };
|
33 |
|
|
localparam [OP_W-1:0] op_jmp_il = { 1'b0, `il, 5'bxxxxx };
|
34 |
|
|
localparam [OP_W-1:0] op_jmp_ilz = { 1'b0, `ilz, 5'bxxxxx };
|
35 |
|
|
localparam [OP_W-1:0] op_jmp_ile = { 1'b0, `ile, 5'bxxxxx };
|
36 |
|
|
localparam [OP_W-1:0] op_jmp_ilez = { 1'b0, `ilez, 5'bxxxxx };
|
37 |
|
|
localparam [OP_W-1:0] op_jmp_iug = { 1'b0, `iug, 5'bxxxxx };
|
38 |
|
|
localparam [OP_W-1:0] op_jmp_igz = { 1'b0, `igz, 5'bxxxxx };
|
39 |
|
|
localparam [OP_W-1:0] op_jmp_iuge = { 1'b0, `iuge, 5'bxxxxx };
|
40 |
|
|
localparam [OP_W-1:0] op_jmp_igez = { 1'b0, `igez, 5'bxxxxx };
|
41 |
|
|
localparam [OP_W-1:0] op_jmp_igl = { 1'b0, `igl, 5'bxxxxx };
|
42 |
|
|
localparam [OP_W-1:0] op_jmp_iglz = { 1'b0, `iglz, 5'bxxxxx };
|
43 |
|
|
// immediate unconditional jump - 64 codes
|
44 |
|
|
localparam [OP_W-1:0] op_jmp_i = { 1'b0, `igle, 6'bxxxxxx };
|
45 |
|
|
// immediate byte - 256 codes
|
46 |
|
|
localparam [OP_W-1:0] op_byt_i = { 2'b10, 8'bxxxxxxxx }; // I[7:0] => A byte immediate (signed)
|
47 |
|
|
// immediate shift - 128 codes
|
48 |
|
|
localparam [OP_W-1:0] op_shl_i = { 4'hc, 6'bxxxxxx }; // A<<I => A shift left A (signed) immediate
|
49 |
|
|
localparam [OP_W-1:0] op_shl_iu = { 4'hd, 6'bxxxxxx }; // 1<<I | A<<I => A shift left immediate unsigned
|
50 |
|
|
// immediate add - 64 codes
|
51 |
|
|
localparam [OP_W-1:0] op_add_i = { 4'he, 6'bxxxxxx }; // A+I[5:0] => A add immediate (I signed)
|
52 |
|
|
// conditional jump - 7 of 8 codes
|
53 |
|
|
localparam [OP_W-1:0] op_jmp_ez = { 4'hf, 3'b000, `ez }; // (A?0) PC+B[lo] => PC jump relative conditional
|
54 |
|
|
localparam [OP_W-1:0] op_jmp_lz = { 4'hf, 3'b000, `lz };
|
55 |
|
|
localparam [OP_W-1:0] op_jmp_lez = { 4'hf, 3'b000, `lez };
|
56 |
|
|
localparam [OP_W-1:0] op_jmp_gz = { 4'hf, 3'b000, `gz };
|
57 |
|
|
localparam [OP_W-1:0] op_jmp_gez = { 4'hf, 3'b000, `gez };
|
58 |
|
|
localparam [OP_W-1:0] op_jmp_glz = { 4'hf, 3'b000, `glz };
|
59 |
|
|
localparam [OP_W-1:0] op_jmp = { 4'hf, 3'b000, `glez };
|
60 |
|
|
// conditional goto - 7 of 8 codes
|
61 |
|
|
localparam [OP_W-1:0] op_gto_ez = { 4'hf, 3'b001, `ez }; // (A?0) B[lo] => PC jump absolute conditional
|
62 |
|
|
localparam [OP_W-1:0] op_gto_lz = { 4'hf, 3'b001, `lz };
|
63 |
|
|
localparam [OP_W-1:0] op_gto_lez = { 4'hf, 3'b001, `lez };
|
64 |
|
|
localparam [OP_W-1:0] op_gto_gz = { 4'hf, 3'b001, `gz };
|
65 |
|
|
localparam [OP_W-1:0] op_gto_gez = { 4'hf, 3'b001, `gez };
|
66 |
|
|
localparam [OP_W-1:0] op_gto_glz = { 4'hf, 3'b001, `glz };
|
67 |
|
|
localparam [OP_W-1:0] op_gto = { 4'hf, 3'b001, `glez };
|
68 |
|
|
// singles - 48 codes
|
69 |
|
|
localparam [OP_W-1:0] op_add = { 4'hf, 2'b01, 4'h0 }; // A+B => A add
|
70 |
|
|
localparam [OP_W-1:0] op_add_x = { 4'hf, 2'b01, 4'h2 }; // A+B => A add extended (signed)
|
71 |
|
|
localparam [OP_W-1:0] op_add_ux = { 4'hf, 2'b01, 4'h3 }; // A+B => A add extended unsigned
|
72 |
|
|
localparam [OP_W-1:0] op_sub = { 4'hf, 2'b01, 4'h4 }; // A-B => A subtract
|
73 |
|
|
localparam [OP_W-1:0] op_sub_x = { 4'hf, 2'b01, 4'h6 }; // A-B => A subtract extended (signed)
|
74 |
|
|
localparam [OP_W-1:0] op_sub_ux = { 4'hf, 2'b01, 4'h7 }; // A-B => A subtract extended unsigned
|
75 |
|
|
localparam [OP_W-1:0] op_mul = { 4'hf, 2'b01, 4'h8 }; // A*B => A multiply
|
76 |
|
|
localparam [OP_W-1:0] op_mul_x = { 4'hf, 2'b01, 4'ha }; // A*B => A multiply extended (signed)
|
77 |
|
|
localparam [OP_W-1:0] op_mul_ux = { 4'hf, 2'b01, 4'hb }; // A*B => A multiply extended unsigned
|
78 |
|
|
localparam [OP_W-1:0] op_shl = { 4'hf, 2'b01, 4'hc }; // A<<B => A shift left A (signed)
|
79 |
|
|
localparam [OP_W-1:0] op_shl_u = { 4'hf, 2'b01, 4'hd }; // 1<<B | A<<B => A 2^B | shift left A unsigned
|
80 |
|
|
//
|
81 |
|
|
localparam [OP_W-1:0] op_and = { 4'hf, 2'b10, 4'h0 }; // A&B => A logical AND
|
82 |
|
|
localparam [OP_W-1:0] op_or = { 4'hf, 2'b10, 4'h1 }; // A|B => A logical OR
|
83 |
|
|
localparam [OP_W-1:0] op_xor = { 4'hf, 2'b10, 4'h2 }; // A^B => A logical XOR
|
84 |
|
|
localparam [OP_W-1:0] op_not = { 4'hf, 2'b10, 4'h3 }; // ~B => A logical NOT
|
85 |
|
|
localparam [OP_W-1:0] op_and_b = { 4'hf, 2'b10, 4'h4 }; // &B => A logical AND bit reduction
|
86 |
|
|
localparam [OP_W-1:0] op_or_b = { 4'hf, 2'b10, 4'h5 }; // |B => A logical OR bit reduction
|
87 |
|
|
localparam [OP_W-1:0] op_xor_b = { 4'hf, 2'b10, 4'h6 }; // ^B => A logical XOR bit reduction
|
88 |
|
|
//
|
89 |
|
|
localparam [OP_W-1:0] op_lit = { 4'hf, 2'b11, 4'h0 }; // mem(PC) => A literal low (signed)
|
90 |
|
|
localparam [OP_W-1:0] op_lit_u = { 4'hf, 2'b11, 4'h1 }; // mem(PC) => A literal low unsigned
|
91 |
|
|
localparam [OP_W-1:0] op_lit_x = { 4'hf, 2'b11, 4'h2 }; // {mem(PC),A[lo]} => A literal extended
|
92 |
|
|
localparam [OP_W-1:0] op_cpy = { 4'hf, 2'b11, 4'h4 }; // B => A copy
|
93 |
|
|
localparam [OP_W-1:0] op_pc = { 4'hf, 2'b11, 4'h8 }; // PC => A read PC (unsigned)
|
94 |
|
|
localparam [OP_W-1:0] op_gsb = { 4'hf, 2'b11, 4'h9 }; // B[lo] => PC, PC => A subroutine call
|
95 |
|
|
localparam [OP_W-1:0] op_cls = { 4'hf, 2'b11, 4'hc }; // clear stacks
|
96 |
|
|
localparam [OP_W-1:0] op_pop = { 4'hf, 2'b11, 4'he }; // do nothing (but allow pops)
|
97 |
|
|
localparam [OP_W-1:0] op_nop = { 4'hf, 2'b11, 4'hf }; // do nothing (no pops either)
|