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

Subversion Repositories openarty

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    cpuscope.cpp
4
//
5 51 dgisselq
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6 31 dgisselq
//
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 51 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
29 31 dgisselq
// 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 51 dgisselq
#include "zopcodes.h"
57
 
58 31 dgisselq
FPGA    *m_fpga;
59
void    closeup(int v) {
60
        m_fpga->kill();
61
        exit(0);
62
}
63
 
64
const char *regstr[] = {
65
        "R0","R1","R2","R3","R4","R5","R6","R7","R8","R9","RA","RB","RC",
66
        "SP","CC","PC"
67
};
68
 
69
class   CPUSCOPE : public SCOPE {
70
public:
71
        CPUSCOPE(FPGA *fpga, unsigned addr, bool vecread)
72 34 dgisselq
                : SCOPE(fpga, addr, false, vecread) {};
73 31 dgisselq
        ~CPUSCOPE(void) {}
74
        virtual void    decode(DEVBUS::BUSW val) const {
75
                if (val & 0x80000000)
76
                        printf("TRIG ");
77
                else
78
                        printf("     ");
79 32 dgisselq
                if (true) {
80 31 dgisselq
                if ((val & 0x40000000)==0) {
81 51 dgisselq
                        printf("%s <- 0x.%07x", regstr[(val>>(32-6))&0xf], val&0x03ffffff);
82 31 dgisselq
                } else if ((val & 0x60000000)==0x60000000) {
83 51 dgisselq
                        uint32_t addr = val & 0x7ffffff;
84 31 dgisselq
                        if (val&0x08000000)
85
                                printf("MEM-W[0x........] <- 0x.%07x %s",
86 51 dgisselq
                                        addr,
87 31 dgisselq
                                        (val&0x10000000)?"(GBL)":"");
88
                        else
89
                                printf("MEM-R[0x.%07x] -> (Not Givn) %s",
90 51 dgisselq
                                        (addr<<2)&0x0ffffffc,
91 31 dgisselq
                                        (val&0x10000000)?"(GBL)":"");
92 51 dgisselq
                } else if ((val & 0x70000000)==0x40000000) {
93
                        val &= 0x0fffffff;
94
                        val <<= 2;
95 31 dgisselq
                        printf("JMP 0x%08x", (val&0x0fffffff));
96 51 dgisselq
                } else {
97
                        int     master, halt, brk, sleep, buserr, trap,
98 31 dgisselq
                                ill, clri, pfv, pfi, dcdce, dcdv, dcdstall,
99
                                opce, opvalid, oppipe, aluce, alubsy, aluwr,
100 51 dgisselq
                                memce, memwe, membsy;
101
                        // int  gie, aluill, aluwrf;
102 31 dgisselq
                        master = (val>>27)&1;
103
                        halt   = (val>>26)&1;
104
                        brk    = (val>>25)&1;
105
                        sleep  = (val>>24)&1;
106 51 dgisselq
                        // gie    = (val>>23)&1;
107 31 dgisselq
                        buserr = (val>>22)&1;
108
                        trap   = (val>>21)&1;
109
                        ill    = (val>>20)&1;
110
                        clri   = (val>>19)&1;
111
                        pfv    = (val>>18)&1;
112
                        pfi    = (val>>17)&1;
113
                        dcdce  = (val>>16)&1;
114
                        dcdv   = (val>>15)&1;
115
                        dcdstall=(val>>14)&1;
116
                        opce   = (val>>13)&1;
117
                        opvalid= (val>>12)&1;
118
                        oppipe = (val>>11)&1;
119
                        aluce  = (val>>10)&1;
120
                        alubsy = (val>> 9)&1;
121
                        aluwr  = (val>> 8)&1;
122 51 dgisselq
                        // aluill = (val>> 7)&1;
123
                        // aluwrf = (val>> 6)&1;
124 31 dgisselq
                        memce  = (val>> 5)&1;
125
                        memwe  = (val>> 4)&1;
126
                        membsy = (val>> 3)&1;
127
                        printf("FLAGS %08x", val);
128
                        printf(" CE[%c%c%c%c]",
129
                                (dcdce)?'D':' ',
130
                                (opce)?'O':' ',
131
                                (aluce)?'A':' ',
132
                                (memce)?'M':' ');
133
                        printf(" V[%c%c%c%c]",
134
                                (pfv)?'P':' ',
135
                                (dcdv)?'D':' ',
136
                                (opvalid)?'O':' ',
137
                                (aluwr)?'A':' ');
138
                        if (master) printf(" MCE");
139
                        if (halt)   printf(" I-HALT");
140
                        if (brk)    printf(" O-BREAK");
141
                        if (sleep)  printf(" SLP");
142
                        if (GIE)    printf(" GIE");
143
                        if (buserr) printf(" BE");
144
                        if (trap)   printf(" TRAP");
145
                        if (ill)    printf(" ILL");
146
                        if (clri)   printf(" CLR-I");
147
                        if (pfi)    printf(" PF-ILL");
148
                        if (dcdstall)printf(" DCD-STALL");
149
                        if (oppipe) printf(" OP-PIPE");
150
                        if (alubsy) printf(" ALU-BUSY");
151
                        if (memwe)  printf(" MEM-WE");
152
                        if (membsy) printf(" MEM-BUSY");
153
                        //
154 32 dgisselq
                }}
155
 
156
                if (false) {
157
                        // CPU internal bus_debug
158
                        int     mce, mwe, mbsy, mpip,
159
                                gcyc, gstb, lcyc, lstb, we, ack, stall, err,
160
                                pcyc, pstb, pack, pstall, perr,
161
                                mcycg, mstbg, mcycl, mstbl, mack, mstall, merr;
162
 
163
                        mce    = (val>>24)&1;
164
                        //
165
                        mbsy   = (val>>22)&1;
166
                        mpip   = (val>>21)&1;
167
                        gcyc   = (val>>20)&1;
168
                        gstb   = (val>>19)&1;
169
                        lcyc   = (val>>18)&1;
170
                        lstb   = (val>>17)&1;
171
                        we     = (val>>16)&1;
172
                        ack    = (val>>15)&1;
173
                        stall  = (val>>14)&1;
174
                        err    = (val>>13)&1;
175
                        pcyc   = (val>>12)&1;
176
                        pstb   = (val>>11)&1;
177
                        pack   = (val>>10)&1;
178
                        pstall = (val>> 9)&1;
179
                        perr   = (val>> 8)&1;
180
                        mcycg  = (val>> 7)&1;
181
                        mstbg  = (val>> 6)&1;
182
                        mcycl  = (val>> 5)&1;
183
                        mstbl  = (val>> 4)&1;
184
                        mwe    = (val>> 3)&1;
185
                        mack   = (val>> 2)&1;
186
                        mstall = (val>> 1)&1;
187
                        merr   = (val&1);
188
 
189
                        printf("P[%s%s%s%s%s]",
190
                                (pcyc)?"C":" ",
191
                                (pstb)?"S":" ",
192
                                (pack)?"A":" ",
193
                                (pstall)?"S":" ",
194
                                (perr)?"E":" ");
195
 
196
                        printf("M[(%s%s)(%s%s)%s%s%s%s]",
197
                                (mcycg)?"C":" ", (mstbg)?"S":" ",
198
                                (mcycl)?"C":" ", (mstbl)?"S":" ",
199
                                (mwe)?"W":"R", (mack)?"A":" ",
200
                                (mstall)?"S":" ",
201
                                (merr)?"E":" ");
202
 
203
                        printf("O[(%s%s)(%s%s)%s%s%s%s]",
204
                                (gcyc)?"C":" ", (gstb)?"S":" ",
205
                                (lcyc)?"C":" ", (lstb)?"S":" ",
206
                                (we)?"W":"R", (ack)?"A":" ",
207
                                (stall)?"S":" ",
208
                                (err)?"E":" ");
209
 
210
                        if (mbsy) printf("M-BUSY ");
211
                        if (mpip) printf("M-PIPE ");
212
                        if (mce)  printf("M-CE ");
213 31 dgisselq
                }
214
        }
215
};
216
 
217
int main(int argc, char **argv) {
218
        FPGAOPEN(m_fpga);
219
 
220
        signal(SIGSTOP, closeup);
221
        signal(SIGHUP, closeup);
222
 
223 51 dgisselq
        CPUSCOPE *scope = new CPUSCOPE(m_fpga, WBSCOPE, true);
224 31 dgisselq
        if (!scope->ready()) {
225
                printf("Scope is not yet ready:\n");
226
                scope->decode_control();
227
                scope->decode(WBSCOPEDATA);
228
                printf("\n");
229 51 dgisselq
        } else {
230
                printf("Scope is ready\n");
231 31 dgisselq
                scope->read();
232 51 dgisselq
        }
233 31 dgisselq
        delete  m_fpga;
234
}
235
 

powered by: WebSVN 2.1.0

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