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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [scopecls.cpp] - Blame information for rev 15

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

Line No. Rev Author Line
1 4 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    scopecls.cpp
4
//
5
// Project:     XuLA2-LX25 SoC based upon the ZipCPU
6
//
7
// Purpose:     After rebuilding the same code over and over again for every
8
//              "scope" I tried to interact with, I thought it would be simpler
9
//      to try to make a more generic interface, that other things could plug
10
//      into.  This is that more generic interface.
11
//
12
// Creator:     Dan Gisselquist, Ph.D.
13
//              Gisselquist Technology, LLC
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
18
//
19
// This program is free software (firmware): you can redistribute it and/or
20
// modify it under the terms of  the GNU General Public License as published
21
// by the Free Software Foundation, either version 3 of the License, or (at
22
// your option) any later version.
23
//
24
// This program is distributed in the hope that it will be useful, but WITHOUT
25
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
26
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27
// for more details.
28
//
29
// You should have received a copy of the GNU General Public License along
30
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
31
// target there if the PDF file isn't present.)  If not, see
32
// <http://www.gnu.org/licenses/> for a copy.
33
//
34
// License:     GPL, v3, as defined and found on www.gnu.org,
35
//              http://www.gnu.org/licenses/gpl.html
36
//
37
//
38
////////////////////////////////////////////////////////////////////////////////
39
//
40
//
41
#include <stdio.h>
42
#include <stdlib.h>
43
#include <unistd.h>
44
#include <strings.h>
45
#include <ctype.h>
46
#include <string.h>
47
#include <signal.h>
48
#include <assert.h>
49
 
50
#include "devbus.h"
51
#include "scopecls.h"
52
 
53
bool    SCOPE::ready() {
54
        unsigned v;
55
        v = m_fpga->readio(m_addr);
56
        if (m_scoplen == 0) {
57
                m_scoplen = (1<<((v>>20)&0x01f));
58
        } v = (v>>28)&6;
59
        return (v==6);
60
}
61
 
62
void    SCOPE::decode_control(void) {
63
        unsigned        v;
64
 
65
        v = m_fpga->readio(m_addr);
66
        printf("\t31. RESET:\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
67
        printf("\t30. STOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
68
        printf("\t29. TRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
69
        printf("\t28. PRIMED:\t%s\n", (v&0x10000000)?"Yes":"No");
70
        printf("\t27. MANUAL:\t%s\n", (v&0x08000000)?"Yes":"No");
71
        printf("\t26. DISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
72
        printf("\t25. ZERO:\t%s\n", (v&0x02000000)?"Yes":"No");
73
        printf("\tSCOPLEN:\t%08x (%d)\n", m_scoplen, m_scoplen);
74
        printf("\tHOLDOFF:\t%08x\n", (v&0x0fffff));
75
        printf("\tTRIGLOC:\t%d\n", m_scoplen-(v&0x0fffff));
76
}
77
 
78
int     SCOPE::scoplen(void) {
79
        if (m_scoplen == 0) {
80
                int     lgln = (m_fpga->readio(m_addr)>>20)&0x01f;
81
                m_scoplen = (1<<lgln);
82
        } return m_scoplen;
83
}
84
 
85
void    SCOPE::read(void) {
86
        DEVBUS::BUSW    addrv = 0;
87
 
88
        scoplen();
89
        if (m_scoplen <= 4) {
90
                printf("Not a scope?\n");
91
        }
92
 
93
        DEVBUS::BUSW    *buf;
94
 
95
        buf = new DEVBUS::BUSW[m_scoplen];
96
 
97
        if (m_vector_read) {
98
                m_fpga->readz(m_addr+1, m_scoplen, buf);
99
        } else {
100
                for(unsigned int i=0; i<m_scoplen; i++)
101
                        buf[i] = m_fpga->readio(m_addr+1);
102
        }
103
 
104
        if(m_compressed) {
105
                for(int i=0; i<(int)m_scoplen; i++) {
106
                        if ((buf[i]>>31)&1) {
107
                                addrv += (buf[i]&0x7fffffff);
108
                                printf(" ** (+0x%08x = %8d)\n",
109
                                        (buf[i]&0x07fffffff),
110
                                        (buf[i]&0x07fffffff));
111
                                continue;
112
                        }
113
                        printf("%10d %08x: ", addrv++, buf[i]);
114
                        decode(buf[i]);
115
                        printf("\n");
116
                }
117
        } else {
118
                for(int i=0; i<(int)m_scoplen; i++) {
119
                        if ((i>0)&&(buf[i] == buf[i-1])&&(i<(int)(m_scoplen-1))) {
120
                                if ((i>2)&&(buf[i] != buf[i-2]))
121
                                        printf(" **** ****\n");
122
                                continue;
123
                        } printf("%9d %08x: ", i, buf[i]);
124
                        decode(buf[i]);
125
                        printf("\n");
126
                }
127
        }
128
 
129
        delete[] buf;
130
}
131
 

powered by: WebSVN 2.1.0

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