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

Subversion Repositories wbscope

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

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

powered by: WebSVN 2.1.0

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