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

Subversion Repositories wbscope

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

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

powered by: WebSVN 2.1.0

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