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

Subversion Repositories wbscope

[/] [wbscope/] [trunk/] [doc/] [src/] [spec.tex] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 dgisselq
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
%%
3
%% Filename:    spec.tex
4
%%
5
%% Project:     Wishbone scope
6
%%
7
%% Purpose:     This LaTeX file contains all of the documentation/description
8
%%              currently provided with this Wishbone scope core.  It's not
9
%%              nearly as interesting as the PDF file it creates, so I'd
10
%%              recommend reading that before diving into this file.  You
11
%%              should be able to find the PDF file in the SVN distribution
12
%%              together with this PDF file and a copy of the GPL-3.0 license
13
%%              this file is distributed under.  If not, just type 'make'
14
%%              in the doc directory and it (should) build without a problem.
15
%%
16
%%
17
%% Creator:     Dan Gisselquist
18
%%              Gisselquist Technology, LLC
19
%%
20
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21
%%
22
%% Copyright (C) 2015, Gisselquist Technology, LLC
23
%%
24
%% This program is free software (firmware): you can redistribute it and/or
25
%% modify it under the terms of  the GNU General Public License as published
26
%% by the Free Software Foundation, either version 3 of the License, or (at
27
%% your option) any later version.
28
%%
29
%% This program is distributed in the hope that it will be useful, but WITHOUT
30
%% ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
31
%% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
32
%% for more details.
33
%%
34
%% You should have received a copy of the GNU General Public License along
35
%% with this program.  (It's in the $(ROOT)/doc directory, run make with no
36
%% target there if the PDF file isn't present.)  If not, see
37
%% <http://www.gnu.org/licenses/> for a copy.
38
%%
39
%% License:     GPL, v3, as defined and found on www.gnu.org,
40
%%              http://www.gnu.org/licenses/gpl.html
41
%%
42
%%
43
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
\documentclass{gqtekspec}
45
\project{Wishbone Scope}
46
\title{Specification}
47
\author{Dan Gisselquist, Ph.D.}
48
\email{dgisselq (at) opencores.org}
49
\revision{Rev.~0.1}
50
\begin{document}
51
\pagestyle{gqtekspecplain}
52
\titlepage
53
\begin{license}
54
Copyright (C) \theyear\today, Gisselquist Technology, LLC
55
 
56
This project is free software (firmware): you can redistribute it and/or
57
modify it under the terms of  the GNU General Public License as published
58
by the Free Software Foundation, either version 3 of the License, or (at
59
your option) any later version.
60
 
61
This program is distributed in the hope that it will be useful, but WITHOUT
62
ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
63
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
64
for more details.
65
 
66
You should have received a copy of the GNU General Public License along
67
with this program.  If not, see \hbox{<http://www.gnu.org/licenses/>} for a
68
copy.
69
\end{license}
70
\begin{revisionhistory}
71 4 dgisselq
0.2 & 6/22/2015 & Gisselquist & Finished Draft \\\hline
72 2 dgisselq
0.1 & 6/22/2015 & Gisselquist & First Draft \\\hline
73
\end{revisionhistory}
74
% Revision History
75
% Table of Contents, named Contents
76
\tableofcontents
77
% \listoffigures
78
\listoftables
79
\begin{preface}
80 4 dgisselq
This project began, years ago, for all the wrong reasons.  Rather than pay a
81
high price to purchase a Verilog simulator and then to learn how to use it,
82
I took working Verilog code, to include a working bus, added features and
83
used the FPGA system as my testing platform.  I arranged the FPGA to step
84
internal registers upon command, and to make many of those registers
85
available via the bus.
86 2 dgisselq
 
87 4 dgisselq
When I then needed to make the project run in real-time, as opposed to the
88
manually stepped approach, I generated a scope like this one.  I had already
89
bench tested the components on the hardware itself.  Thu, testing and
90
development continued on the hardware, and the scope helped me see what was
91
going right or wrong.  The great advantage of the approach was that, at the
92
end of the project, I didn't need to do any hardware in the loop testing.
93
All of the testing that had been accomplished prior to that date was already
94
hardware in the loop testing.
95
 
96
When I left that job, I took this concept with me and rebuilt this piece of
97
infrastructure using a Wishbone Bus.
98 2 dgisselq
\end{preface}
99
 
100
\chapter{Introduction}
101
\pagenumbering{arabic}
102
\setcounter{page}{1}
103
 
104
The wishbone Scope is a debugging tool for reading results from the chip after
105
events have taken place.  In general, the scope records data until some
106 4 dgisselq
some (programmable) holdoff number of data samples after a trigger has taken
107
place.  Once the holdoff has been reached, the scope stops recording and
108
asserts an interrupt.  At this time, data may be read from the scope in order
109
from oldest to most recent.  That's the basics, now for two extra details.
110
 
111
First, the trigger and the data that the scope records are both implementation
112
dependent.  The scope itself is designed to be easily reconfigurable from one
113
build to the next so that the actual configuration may even be build dependent.
114
 
115 2 dgisselq
Second, the scope is built to be able to run off of a separate clock from the
116
bus that commands and controls it.  This is configurable, set the parameter
117 4 dgisselq
``SYNCHRONOUS'' to `1' to run off of a single clock.  When running off of two
118
clocks, it means that actions associated with commands issued to the scope,
119
such as manual triggering or being disabled or released, will not act
120
synchronously with the scope itself--but this is to be expected.
121 2 dgisselq
 
122
Third, the data clock associated with the scope has a clock enable line
123
associated with it.  Depending on how often the clock enable line is enabled
124
may determine how fast the scope is primed, triggered, and eventually completes
125
its collection.
126
 
127 4 dgisselq
Finally, and in conclusion, this scope has been an invaluable tool for
128
testing, for figuring out what is going on internal to a chip, and for fixing
129
such things.  I have fixed interactions over a PS/2 connection, Internal
130
Configuration Access Port (ICAPE2) interfaces, mouse controller interactions,
131
bus errors, quad-SPI flash interactions, and more using this scope.
132
 
133 2 dgisselq
% \chapter{Architecture}
134
\chapter{Operation}
135 4 dgisselq
 
136
So how shall one use the scope?  The scope itself supports a series of
137
states:
138
\begin{enumerate}
139
\item RESET
140 2 dgisselq
 
141 4 dgisselq
    Any write to the control register, without setting the high order bit,
142
    will automatically reset the scope.
143
\item PRIMED
144
 
145
    Following a reset, once the scope has filled its memory, it enters the
146
    PRIMED state.  Once it reaches this state, it will be sensitive to a
147
    trigger.
148
\item TRIGGERED
149
 
150
    The scope may be triggered either automatically, via an input port to
151
    the core, or manually, via a wishbone bus command.  Once a trigger
152
    has been received, the core will record a user configurable number of
153
    further samples before stopping.
154
 
155
\item STOPPED
156
 
157
    Once the core has stopped, the data within it may be read back off.
158
\end{enumerate}
159
 
160
Let's go through that list again.  First, before using the scope, the holdoff
161 2 dgisselq
needs to be set.  The scope is designed so that setting the scope control value
162
to the holdoff alone will reset the scope from whatever condition it was in,
163
freeing it to run.  Once running, then upon every clock enabled clock, one
164
sample of data is read into the scope and recorded.  Once every memory value
165
is filled, the scope has been {\tt PRIMED}.  Once the scope has been
166
{\tt PRIMED}, it will then be responsive to its trigger.  Should the trigger be
167
active on a clock--enabled input, the scope will then be {\tt TRIGGERED}.  It
168 4 dgisselq
will then count for the number of clocks in the holdoff before stopping
169
collection, placing it in the {\tt STOPPED} state.  If the holdoff is zero,
170
the last sample in the buffer will be the sample containing the trigger.
171
Likewise if the holdoff is one less than the size of the memory, the first
172
sample in the buffer will be the one containing the trigger.
173
 
174 2 dgisselq
There are two further commands that will affect the operation of the scope.  The
175 4 dgisselq
first is the {\tt MANUAL} trigger command/bit.  This bit may be set by writing
176
the holdoff to the control register while setting this bit high.  This will
177
cause the scope to trigger immediately.  If coupled with a {\tt RESET} command,
178
that is if the RESET_n bit isn't also set, then the trigger will first wait
179
until the scope enters its {\tt PRIMED} state before the manual trigger takes
180 2 dgisselq
effect.
181
 
182
The last command that can affect the operation of the scope is the {\tt DISABLE}
183 4 dgisselq
command/bit in the control register.  Setting this bit will prevent the scope
184
from triggering, or if triggered, it will prevent the scope from generating an
185
interrupt.
186 2 dgisselq
 
187 4 dgisselq
Finally, be careful how you set the clock enable line.  If the clock enable
188
line leaves the clock too often disabled, the scope might never prime in any
189
reasonable amount of time.
190
 
191
So, in summary, to use this scope you first set the holdoff value in the
192
control register.  Second, you wait until the scope has been triggered and
193
stopped.  Finally, you read from the data register once for every memory value
194
in the buffer and you can then sit back, relax, and study what took place
195
within the FPGA.
196
 
197 2 dgisselq
\chapter{Registers}
198
 
199
This scope core supports two registers, as listed in
200 4 dgisselq
Tbl.~\ref{tbl:reglist}: a control register and a data register.
201 2 dgisselq
\begin{table}[htbp]
202
\begin{center}
203
\begin{reglist}
204 4 dgisselq
WBSCOPE        & 0 & 32 & R/W & Configuration, control, and status of the
205
        scope.\\\hline
206
WBSCOPEDATA    & 1 & 32 & R/W & Read out register, to read out the data
207
        from the core.  Writes to this register reset the read address
208
        to the beginning of the buffer, but are otherwise ignored.
209
        \\\hline
210 2 dgisselq
\end{reglist}\caption{List of Registers}\label{tbl:reglist}
211
\end{center}\end{table}
212
Each register will be discussed in detail in this chapter.
213
 
214
\section{Control Register}
215
The bits in the control register are defined in Tbl.~\ref{tbl:control}.
216
\begin{table}[htbp]
217
\begin{center}
218
\begin{bitlist}
219
31 & R/W & RESET\_n.  Write a `0' to this register to command a reset.
220
        Reading a `1' from this register means the reset has not finished
221
        crossing clock domains and is still pending.\\\hline
222
30 & R & STOPPED, indicates that all collection has stopped.\\\hline
223
29 & R & TRIGGERRED, indicates that a trigger has been recognized, and that
224
        the scope is counting for holdoff samples before stopping.\\\hline
225
28 & R & PRIMED, indicates that the memory has been filled, and that the
226
        scope is now waiting on a trigger.\\\hline
227
27 & R/W & MANUAL, set to invoke a manual trigger.\\\hline
228
26 & R/W & DISABLE, set to disable the internal trigger.  The scope may still
229
        be triggered manually.\\\hline
230
25 & R & RZERO, this will be true whenever the scope's internal address
231
        register is pointed at the beginning of the memory.\\\hline
232
20--24 & R & LGMEMLEN, the base two logarithm of the memory length.  Thus,
233
        the memory internal to the scope is given by 1<<LGMEMLEN. \\\hline
234
0--19 & R/W & Unsigned holdoff\\\hline
235
\end{bitlist}
236
\caption{Control Register}\label{tbl:control}
237
\end{center}\end{table}
238 4 dgisselq
The register has been designed so that one need only write the holdoff value to
239
it, while leaving the other bits zero, to get the scope going.  On such a write,
240
the RESET\_n bit will be a zero, causing the scope to internally reset itself.
241
Further, during normal operation, the high order nibble will go from 4'h8
242
(a nearly instantaneous reset state) to 4'h0 (running), to 4'h1 (primed),
243
to 4'h3 (triggered), and then stop at 4'h7 (primed, triggered, and stopped).
244
Finally, user's are cautioned not to adjust the holdoff between the time the
245
scope triggers and the time it stops--just to guarantee data coherency.
246 2 dgisselq
 
247 4 dgisselq
While this approach works, the scope has some other capabilities.  For example,
248
if you set the MANUAL bit, the scope will trigger as soon as it is primed.
249
If you set the MANUAL bit and the RESET\_n bit, it will trigger immediately
250
if the scope was already primed.  If not, a reset will take place, the scope
251
will collect enough data to be primed, and then immediately trigger.
252
 
253
A second optional capability is to disable the scope entirely.  This might be
254
useful if, for example, certain irrelevant things might trigger the scope.
255
By setting the DISABLE bit, the scope will not automatically trigger.  It will
256
still record into its memory, and it will still prime itself, it will just
257
not trigger automatically.  The scope may still be manually triggered while
258
the DISABLE bit is set.  Likewise, if the DISABLE bit is set after the scope
259
has been triggered, the scope will continue to its natural stopped state--it
260
just won't generate an interrupt.
261
 
262
There are two other interesting bits in this control register.  The RZERO bit
263
indicates that the next read from the data register will read from the first
264
value in the memory, while the LGMEMLEN bits indicate how long the memory is.
265
Thus, if LGMEMLEN is 10, the FIFO will be (1<<10) or 1024 words long, whereas
266
if LGMEMLEN is 14, the FIFO will be (1<<14) or 16384 words long.
267
 
268 2 dgisselq
\section{Data Register}
269
 
270
This is perhaps the simplest register to explain.  Before the core stops
271
recording, reads from this register will produce reads of the bits going into
272
the core, save only that they have not been protected from any meta-stability
273
issues.  This is useful for reading what's going on when the various lines are
274
stuck.  After the core stops recording, reads from this register return values
275
from the stored memory.  Further, after recording has stopped, every read
276
increments an internal memory address, so that after $N$ reads (for however
277
long the internal memory is), the entire memory has been returned over the bus.
278
If you would like some assurance that you are reading from the beginning of the
279 4 dgisselq
memory, you may either check the control register's {\tt RZERO} flag which will
280
be `1' for the first value in the buffer, or you may write to the data register.
281
Such writes will be ignored, save that they will reset the read address back
282
to the beginning of the buffer.
283
 
284 2 dgisselq
\chapter{Clocks}
285
 
286
This scope supports two clocks: a wishbone bus clock, and a data clock.
287
If the internal parameter ``SYNCHRONOUS'' is set to zero, proper transfers
288
will take place between these two clocks.  Setting this parameter to a one
289 4 dgisselq
will save some flip flops and logic in implementation.  The speeds of the
290
respective clocks are based upon the speed of your device, and not specific
291
to this core.
292
 
293 2 dgisselq
\chapter{Wishbone Datasheet}\label{chap:wishbone}
294
Tbl.~\ref{tbl:wishbone}
295
\begin{table}[htbp]
296
\begin{center}
297
\begin{wishboneds}
298
Revision level of wishbone & WB B4 spec \\\hline
299
Type of interface & Slave, Read/Write, pipeline reads supported \\\hline
300
Port size & 32--bit \\\hline
301
Port granularity & 32--bit \\\hline
302
Maximum Operand Size & 32--bit \\\hline
303
Data transfer ordering & (Irrelevant) \\\hline
304
Clock constraints & None.\\\hline
305
Signal Names & \begin{tabular}{ll}
306
                Signal Name & Wishbone Equivalent \\\hline
307
                {\tt i\_wb\_clk} & {\tt CLK\_I} \\
308
                {\tt i\_wb\_cyc} & {\tt CYC\_I} \\
309
                {\tt i\_wb\_stb} & {\tt STB\_I} \\
310
                {\tt i\_wb\_we} & {\tt WE\_I} \\
311
                {\tt i\_wb\_addr} & {\tt ADR\_I} \\
312
                {\tt i\_wb\_data} & {\tt DAT\_I} \\
313
                {\tt o\_wb\_ack} & {\tt ACK\_O} \\
314
                {\tt o\_wb\_stall} & {\tt STALL\_O} \\
315
                {\tt o\_wb\_data} & {\tt DAT\_O}
316
                \end{tabular}\\\hline
317
\end{wishboneds}
318
\caption{Wishbone Datasheet}\label{tbl:wishbone}
319
\end{center}\end{table}
320
is required by the wishbone specification, and so
321
it is included here.  The big thing to notice is that this core
322
acts as a wishbone slave, and that all accesses to the wishbone scope
323 4 dgisselq
registers become 32--bit reads and writes to this interface.  You may also wish
324
to note that the scope supports pipeline reads from the data port, to speed
325
up reading the results out.
326
 
327 2 dgisselq
\chapter{IO Ports}
328
 
329
The ports are listed in Table.~\ref{tbl:ioports}.
330
\begin{table}[htbp]
331
\begin{center}
332
\begin{portlist}
333
i\_clk & 1 & Input & \\\hline
334
i\_ce & 1 & Input & Clock Enable.  Set this high to clock data in and
335 4 dgisselq
        out.\\\hline
336
i\_trigger & 1 & Input & An active high trigger line.  If this trigger is
337
        set to one on any clock enabled data clock cycle, once
338
        the scope has been primed, it will then enter into its
339
        TRIGGERED state.
340
        \\\hline
341
i\_data & 32 & Input & 32--wires of ... whatever you are interested in
342
        recording and later examining.  These can be anything, only
343
        they should be synchronous with the data clock.
344
        \\\hline
345 2 dgisselq
i\_wb\_clk & 1 & Input & The clock that the wishbone interface runs on.
346
                \\\hline
347
i\_wb\_cyc & 1 & Input & Indicates a wishbone bus cycle is active when high.
348
                \\\hline
349
i\_wb\_stb & 1 & Input & Indicates a wishbone bus cycle for this peripheral
350 4 dgisselq
        when high.  (See the wishbone spec for more details) \\\hline
351
i\_wb\_we & 1 & Input & Write enable, allows indicates a write to one of the
352
        two registers when i\_wb\_stb is also high.
353
        \\\hline
354 2 dgisselq
i\_wb\_addr & 1 & Input & A single address line, set to zero to access the
355
                configuration and control regiseter, to one to access the data
356
                register.  \\\hline
357
i\_wb\_data & 32 & Input & Data used when writing to the control register,
358
                ignored otherwise.  \\\hline
359
o\_wb\_ack & 1 & Output & Wishbone acknowledgement.  This line will go high
360
                on the clock after any wishbone access, as long as the wishbone
361
                {\tt i\_wb\_cyc} line remains high (i.e., no ack's if you
362
                terminate the cycle early).
363
                \\\hline
364
o\_wb\_stall & 1 & Output & Required by the wishbone spec, but always set to
365
                zero in this implementation.
366
                \\\hline
367
o\_wb\_data & 32 & Output & Values read, either control or data, headed back
368 4 dgisselq
        to the wishbone bus.  These values will be valid during any
369
        read cycle when the {\tt i\_wb\_ack} line is high.
370
        \\\hline
371 2 dgisselq
\end{portlist}
372
\caption{List of IO ports}\label{tbl:ioports}
373
\end{center}\end{table}
374 4 dgisselq
At this point, most of these ports should have been well defined and described
375
earlier in this document.  The only new things are the data clock, {\tt i\_clk},
376
the clock enable for the data, {\tt i\_ce}, the trigger, {\tt i\_trigger}, and
377
the data of interest itself, {\tt i\_data}.  Hopefully these are fairly self
378
explanatory by this point.  If not, just remember the data, {\tt i\_data},
379
are synchronous to the clock, {\tt i\_clk}.  On every clock where the clock
380
enable line is high, {\tt i\_ce}, the data will be recorded until the scope
381
has stopped.  Further, the scope will stop some programmable holdoff number
382
of clock enabled data clocks after {\tt i\_trigger} goes high.  Further,
383
{\tt i\_trigger} need only be high for one clock cycle to be noticed by the
384
scope.
385
 
386 2 dgisselq
% Appendices
387
% Index
388
\end{document}
389
 
390
 

powered by: WebSVN 2.1.0

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