1 |
2 |
wd5gnr |
/*
|
2 |
|
|
This file is part of Blue8.
|
3 |
|
|
|
4 |
|
|
Foobar is free software: you can redistribute it and/or modify
|
5 |
|
|
it under the terms of the GNU Lesser General Public License as published by
|
6 |
|
|
the Free Software Foundation, either version 3 of the License, or
|
7 |
|
|
(at your option) any later version.
|
8 |
|
|
|
9 |
|
|
Foobar is distributed in the hope that it will be useful,
|
10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
GNU Lesser General Public License for more details.
|
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU Lesser General Public License
|
15 |
|
|
along with Blue8. If not, see <http://www.gnu.org/licenses/>.
|
16 |
|
|
|
17 |
|
|
Blue8 by Al Williams alw@al-williams.com
|
18 |
|
|
|
19 |
|
|
*/
|
20 |
|
|
|
21 |
|
|
`default_nettype none
|
22 |
|
|
|
23 |
|
|
module idecode( input [15:0] ir16, output wire ophlt, output wire opadd, output wire opxor,
|
24 |
|
|
output wire opand, output wire opior, output wire opnot, output wire oplda, output wire opsta,
|
25 |
|
|
output wire opsrj, output wire opjmp, output wire opldx,
|
26 |
|
|
output wire opral, output wire opnop,
|
27 |
|
|
output wire opinc, output wire opdec, output wire opskip, output wire opspn, output wire opq,
|
28 |
|
|
output wire opqtog, output wire opsub, output wire opcmp, output wire opldi, output wire oprar,
|
29 |
|
|
output wire opincdecx, output wire opstx, output wire opjmpa, output wire opswap,
|
30 |
|
|
output wire oplds, output wire oppush, output wire oppop, output wire opframe, output wire opldxa);
|
31 |
|
|
wire [3:0] ir;
|
32 |
|
|
|
33 |
|
|
assign ir=ir16[15:12];
|
34 |
|
|
assign ophlt=ir16==16'h0;
|
35 |
|
|
assign opadd=ir==1;
|
36 |
|
|
assign opxor=ir==2;
|
37 |
|
|
assign opand=ir==3;
|
38 |
|
|
assign opior=ir==4;
|
39 |
|
|
assign opnot=ir16==16'h2;
|
40 |
|
|
assign opcmp=ir==5;
|
41 |
|
|
assign oplda=ir[2:0]==6;
|
42 |
|
|
assign opsta=ir[2:0]==7;
|
43 |
|
|
assign opsrj=ir==8;
|
44 |
|
|
assign opsub=ir==9;
|
45 |
|
|
assign opjmp=ir==10;
|
46 |
|
|
assign opldx=ir==11;
|
47 |
|
|
assign oplds=ir==12;
|
48 |
|
|
assign opral=ir16==16'h3;
|
49 |
|
|
|
50 |
|
|
assign opnop=ir16==16'h1;
|
51 |
|
|
assign opinc=ir16==16'h5;
|
52 |
|
|
assign opdec=ir16==16'h6;
|
53 |
|
|
assign oprar=ir16==16'h7;
|
54 |
|
|
assign opskip=ir16[15:4]==12'b1; // skip is 0x0010 + skip code + 8 (if ~flags)
|
55 |
|
|
assign opspn=ir16[15:1]==15'b10000; // 0x0020/21 - skip positive/negative
|
56 |
|
|
assign opq=ir16[15:1]==15'b10001; // 0x22/23 - qoff, qon
|
57 |
|
|
assign opqtog=ir16==16'h24; // 0x24 qtog
|
58 |
|
|
assign opldi=ir16==16'h25; // 0x25 ldi
|
59 |
|
|
assign opincdecx=ir16[15:1]==15'h0018; // 0x30/0x31
|
60 |
|
|
assign opstx=ir16==16'h32;
|
61 |
|
|
assign opjmpa=ir16==16'h33;
|
62 |
|
|
assign opswap=ir16==16'h34;
|
63 |
|
|
assign oppop=ir16[15:4]==12'h4; // pop includes ret
|
64 |
|
|
assign oppush=ir16[15:4]==12'h5;
|
65 |
|
|
assign opframe=ir16==16'h8; // frame SP->X
|
66 |
|
|
assign opldxa=ir16==16'h9;
|
67 |
|
|
|
68 |
|
|
// note that now ir D, E, and F are open
|
69 |
|
|
endmodule
|