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

Subversion Repositories wbscope

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

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

powered by: WebSVN 2.1.0

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