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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [cpuscope.cpp] - Blame information for rev 34

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

Line No. Rev Author Line
1 31 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    cpuscope.cpp
4
//
5
// Project:     XuLA2-LX25 SoC based upon the ZipCPU
6
//
7
// Purpose:     To read out, and decompose, the results of the wishbone scope
8
//              as applied to the ZipCPU internal operation.
9
//
10
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12
//
13
////////////////////////////////////////////////////////////////////////////////
14
//
15
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
16
//
17
// This program is free software (firmware): you can redistribute it and/or
18
// modify it under the terms of  the GNU General Public License as published
19
// by the Free Software Foundation, either version 3 of the License, or (at
20
// your option) any later version.
21
//
22
// This program is distributed in the hope that it will be useful, but WITHOUT
23
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
// for more details.
26
//
27
// You should have received a copy of the GNU General Public License along
28
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
29
// target there if the PDF file isn't present.)  If not, see
30
// <http://www.gnu.org/licenses/> for a copy.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
//
38
//
39
#include <stdio.h>
40
#include <stdlib.h>
41
#include <unistd.h>
42
#include <strings.h>
43
#include <ctype.h>
44
#include <string.h>
45
#include <signal.h>
46
#include <assert.h>
47
 
48
#include "port.h"
49
#include "llcomms.h"
50
#include "regdefs.h"
51
#include "scopecls.h"
52
 
53
#define WBSCOPE         R_CPUSCOPE
54
#define WBSCOPEDATA     R_CPUSCOPED
55
 
56
FPGA    *m_fpga;
57
void    closeup(int v) {
58
        m_fpga->kill();
59
        exit(0);
60
}
61
 
62
const char *regstr[] = {
63
        "R0","R1","R2","R3","R4","R5","R6","R7","R8","R9","RA","RB","RC",
64
        "SP","CC","PC"
65
};
66
 
67
class   CPUSCOPE : public SCOPE {
68
public:
69
        CPUSCOPE(FPGA *fpga, unsigned addr, bool vecread)
70 34 dgisselq
                : SCOPE(fpga, addr, false, vecread) {};
71 31 dgisselq
        ~CPUSCOPE(void) {}
72
        virtual void    decode(DEVBUS::BUSW val) const {
73
                if (val & 0x80000000)
74
                        printf("TRIG ");
75
                else
76
                        printf("     ");
77 32 dgisselq
                if (true) {
78 31 dgisselq
                if ((val & 0x40000000)==0) {
79
                        printf("%s <- 0x.%08x", regstr[(val>>32-6)&0xf], val&0x03ffffff);
80
                } else if ((val & 0x60000000)==0x60000000) {
81
                        if (val&0x08000000)
82
                                printf("MEM-W[0x........] <- 0x.%07x %s",
83
                                        (val&0x07ffffff),
84
                                        (val&0x10000000)?"(GBL)":"");
85
                        else
86
                                printf("MEM-R[0x.%07x] -> (Not Givn) %s",
87
                                        (val&0x07ffffff),
88
                                        (val&0x10000000)?"(GBL)":"");
89
                } else if ((val & 0x70000000)==0x40000000)
90
                        printf("JMP 0x%08x", (val&0x0fffffff));
91
                else {
92
                        int     master, halt, brk, sleep, gie, buserr, trap,
93
                                ill, clri, pfv, pfi, dcdce, dcdv, dcdstall,
94
                                opce, opvalid, oppipe, aluce, alubsy, aluwr,
95
                                aluill, aluwrf, memce, memwe, membsy;
96
                        master = (val>>27)&1;
97
                        halt   = (val>>26)&1;
98
                        brk    = (val>>25)&1;
99
                        sleep  = (val>>24)&1;
100
                        gie    = (val>>23)&1;
101
                        buserr = (val>>22)&1;
102
                        trap   = (val>>21)&1;
103
                        ill    = (val>>20)&1;
104
                        clri   = (val>>19)&1;
105
                        pfv    = (val>>18)&1;
106
                        pfi    = (val>>17)&1;
107
                        dcdce  = (val>>16)&1;
108
                        dcdv   = (val>>15)&1;
109
                        dcdstall=(val>>14)&1;
110
                        opce   = (val>>13)&1;
111
                        opvalid= (val>>12)&1;
112
                        oppipe = (val>>11)&1;
113
                        aluce  = (val>>10)&1;
114
                        alubsy = (val>> 9)&1;
115
                        aluwr  = (val>> 8)&1;
116
                        aluill = (val>> 7)&1;
117
                        aluwrf = (val>> 6)&1;
118
                        memce  = (val>> 5)&1;
119
                        memwe  = (val>> 4)&1;
120
                        membsy = (val>> 3)&1;
121
                        printf("FLAGS %08x", val);
122
                        printf(" CE[%c%c%c%c]",
123
                                (dcdce)?'D':' ',
124
                                (opce)?'O':' ',
125
                                (aluce)?'A':' ',
126
                                (memce)?'M':' ');
127
                        printf(" V[%c%c%c%c]",
128
                                (pfv)?'P':' ',
129
                                (dcdv)?'D':' ',
130
                                (opvalid)?'O':' ',
131
                                (aluwr)?'A':' ');
132
                        if (master) printf(" MCE");
133
                        if (halt)   printf(" I-HALT");
134
                        if (brk)    printf(" O-BREAK");
135
                        if (sleep)  printf(" SLP");
136
                        if (GIE)    printf(" GIE");
137
                        if (buserr) printf(" BE");
138
                        if (trap)   printf(" TRAP");
139
                        if (ill)    printf(" ILL");
140
                        if (clri)   printf(" CLR-I");
141
                        if (pfi)    printf(" PF-ILL");
142
                        if (dcdstall)printf(" DCD-STALL");
143
                        if (oppipe) printf(" OP-PIPE");
144
                        if (alubsy) printf(" ALU-BUSY");
145
                        if (memwe)  printf(" MEM-WE");
146
                        if (membsy) printf(" MEM-BUSY");
147
                        //
148 32 dgisselq
                }}
149
 
150
                if (false) {
151
                        // CPU internal bus_debug
152
                        int     mce, mwe, mbsy, mpip,
153
                                gcyc, gstb, lcyc, lstb, we, ack, stall, err,
154
                                pcyc, pstb, pack, pstall, perr,
155
                                mcycg, mstbg, mcycl, mstbl, mack, mstall, merr;
156
 
157
                        mce    = (val>>24)&1;
158
                        //
159
                        mbsy   = (val>>22)&1;
160
                        mpip   = (val>>21)&1;
161
                        gcyc   = (val>>20)&1;
162
                        gstb   = (val>>19)&1;
163
                        lcyc   = (val>>18)&1;
164
                        lstb   = (val>>17)&1;
165
                        we     = (val>>16)&1;
166
                        ack    = (val>>15)&1;
167
                        stall  = (val>>14)&1;
168
                        err    = (val>>13)&1;
169
                        pcyc   = (val>>12)&1;
170
                        pstb   = (val>>11)&1;
171
                        pack   = (val>>10)&1;
172
                        pstall = (val>> 9)&1;
173
                        perr   = (val>> 8)&1;
174
                        mcycg  = (val>> 7)&1;
175
                        mstbg  = (val>> 6)&1;
176
                        mcycl  = (val>> 5)&1;
177
                        mstbl  = (val>> 4)&1;
178
                        mwe    = (val>> 3)&1;
179
                        mack   = (val>> 2)&1;
180
                        mstall = (val>> 1)&1;
181
                        merr   = (val&1);
182
 
183
                        printf("P[%s%s%s%s%s]",
184
                                (pcyc)?"C":" ",
185
                                (pstb)?"S":" ",
186
                                (pack)?"A":" ",
187
                                (pstall)?"S":" ",
188
                                (perr)?"E":" ");
189
 
190
                        printf("M[(%s%s)(%s%s)%s%s%s%s]",
191
                                (mcycg)?"C":" ", (mstbg)?"S":" ",
192
                                (mcycl)?"C":" ", (mstbl)?"S":" ",
193
                                (mwe)?"W":"R", (mack)?"A":" ",
194
                                (mstall)?"S":" ",
195
                                (merr)?"E":" ");
196
 
197
                        printf("O[(%s%s)(%s%s)%s%s%s%s]",
198
                                (gcyc)?"C":" ", (gstb)?"S":" ",
199
                                (lcyc)?"C":" ", (lstb)?"S":" ",
200
                                (we)?"W":"R", (ack)?"A":" ",
201
                                (stall)?"S":" ",
202
                                (err)?"E":" ");
203
 
204
                        if (mbsy) printf("M-BUSY ");
205
                        if (mpip) printf("M-PIPE ");
206
                        if (mce)  printf("M-CE ");
207 31 dgisselq
                }
208
        }
209
};
210
 
211
int main(int argc, char **argv) {
212
        FPGAOPEN(m_fpga);
213
 
214
        signal(SIGSTOP, closeup);
215
        signal(SIGHUP, closeup);
216
 
217
        CPUSCOPE *scope = new CPUSCOPE(m_fpga, WBSCOPE, false);
218
        if (!scope->ready()) {
219
                printf("Scope is not yet ready:\n");
220
                scope->decode_control();
221
                scope->decode(WBSCOPEDATA);
222
                printf("\n");
223
        } else
224
                scope->read();
225
        delete  m_fpga;
226
}
227
 

powered by: WebSVN 2.1.0

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