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

Subversion Repositories rtcclock

[/] [rtcclock/] [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:     A Wishbone Controlled Real-Time clock Core
6
%%
7
%% Purpose:     This LaTeX file contains all of the documentation/description
8
%%              currently provided with this FPGA Real-time Clock Core.
9
%%              It's not nearly as interesting as the PDF file it creates,
10
%%              so I'd recommend reading that before diving into this file.
11
%%              You 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{Real-Time Clock}
46
\title{Specification}
47
\author{Dan Gisselquist, Ph.D.}
48 4 dgisselq
\email{dgisselq (at) opencores.org}
49 2 dgisselq
\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 5 dgisselq
0.2 & 7/11/2015 & Gisselquist & Date interface added\\\hline
72 2 dgisselq
0.1 & 5/25/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
Every FPGA project needs to start with a very simple core.  Then, working
81
from simplicity, more and more complex cores can be built until an eventual
82
application comes from all the tiny details.
83
 
84 5 dgisselq
This real time clock began with one such simple core.  All of the pieces to
85
this clock are simple.  Nothing is inherently complex.  However, placing this
86 2 dgisselq
clock into a larger FPGA structure requires a Wishbone bus, and being able
87
to command and control an FPGA over a wishbone bus is an achievement in
88
itself.  Further, the clock produces seven segment display output values
89
and LED output values.  These are also simple outputs, but still take a lot
90
of work to complete.  Finally, this clock will strobe an interrupt line.
91
Reading and processing that interrupt line requires a whole 'nuther bit of
92
logic and the ability to capture, recognize, and respond to interrupts.
93
Hence, once you get a simple clock working, you have a lot working.
94
\end{preface}
95
 
96
\chapter{Introduction}
97
\pagenumbering{arabic}
98
\setcounter{page}{1}
99
 
100
This Real--Time Clock implements a twenty four hour clock, count-down timer,
101 5 dgisselq
stopwatch and alarm.  It is designed to be configurable to adjust to whatever
102
clock speed the underlying architecture is running on, so with only minor
103
changes should run on any fundamental clock rate from about 66~kHz on up to
104 2 dgisselq
250~TeraHertz with varying levels of accuracy along the way.
105
 
106 5 dgisselq
Distributed with this clock is a similar Real--Time Date module.  This
107
second module can track the day, month, and year while properly accounting
108
for varying days in each month and leap years, when they happen.
109 2 dgisselq
 
110 5 dgisselq
Together, the clock and date module offer a fairly full feature set of
111
capability: date, time, alarms, a countdown timer and a stopwatch, all
112
features which are available from the wishbone bus.
113
 
114 2 dgisselq
Other interfaces exist as well.
115
 
116 5 dgisselq
Should you wish to investigate your clock's stability or try to guarantee
117
its fine precision accuracy, it is possible to provide a time hack pulse to
118
the clock and subsequently read what all of the internal registers were set
119
to at that time.
120 2 dgisselq
 
121
When either the count--down timer reaches zero or the clock reaches the alarm
122 5 dgisselq
time (if set), the clock module will produce an impulse which can be used as
123
an interrupt trigger.
124 2 dgisselq
 
125
This clock will also provide outputs sufficient to drive an external seven
126
segment display driver and 16 LED's.
127
 
128
Future enhancements may allow for button control and fine precision clock
129
adjustment.
130
 
131
The layout of this specification follows the format set by OpenCores.
132
This introduction is the first chapter.  Following this introduction is
133
a short chapter describing how this clock is implemented,
134
Chapt.~\ref{chap:arch}.  Following this description, the Chapt.~\ref{chap:ops}
135
gives a brief overview of how to operate the clock.  Most of the details,
136
however, are in the registers and their definitions.  These you can find in
137
Chapt.~\ref{chap:regs}.  As for the wishbone, the wishbone spec requires a
138
wishbone datasheet which you can find in Chapt.~\ref{chap:wishbone}.
139
That leaves the final pertinent information necessary for implementing this
140
core in Chapt.~\ref{chap:ioports}, the definitions and meanings of the
141
various I/O ports.
142
 
143
As always, write me if you have any questions or problems.
144
 
145
\chapter{Architecture}\label{chap:arch}
146
 
147
Central to this real time clock architecture is a 48~bit sub--second register.
148
This register is incremented every clock by a user defined 32~bit value,
149 5 dgisselq
{\tt CKSPEED}.  When the register turns over at the end of each second, a
150
second has taken place and all of the various clock (and date) registers are
151
adjusted.
152 2 dgisselq
 
153
Well, not quite but almost.  The 48~bit register is actually split into a
154
lower 40~bit register that is common to all clock components, as well as
155
separate eight bit upper registers for the clock, timer, and stopwatch.  In
156
this fashion, these separate components can have different definitions for
157
when seconds begin and end, and with sufficient precision to satisfy most
158
applications.
159
 
160
The next thing to note about this architecture is the format of the various
161
clock registers: Binary Coded Decimal, or BCD.  Hence an {\tt 8'h59} refers
162
to a value of 59, rather than 89.  In this fashion, setting the time to
163
{\tt 24'h231520} will set it to 23~hours, 15~minutes, and 20~seconds.  The
164
only exception to this BCD format are the subseconds fields found in the
165
stopwatch and time hack registers.  Seconds and above are all encoded as BCD.
166
 
167
\chapter{Operation}\label{chap:ops}
168
 
169
\section{Time}
170
To set the time, simply write to the clock register the current value of the
171
time.  If the seconds hand is written as zero, subsecond time will be cleared
172
as well.  The new clock value takes place one clock period after the value
173
is written to the bus.
174
 
175
To set only some parts of the time and not others, such as the minutes but
176
not seconds or hours, write all '1's to the seconds and hours.  In this way,
177
writing a {\tt 24'h3f17ff} will set the minutes to 17, but not affect the
178
rest of the clock.
179
 
180
This is also the way to adjust the display without adjusting time.  Suppose
181
you wish to switch to display option '1', just write a {\tt 32'h013fffff} to
182
the register and the display will switch without adjusting time.
183
 
184
\section{Count-down Timer}
185
To use the count down timer, set it to the amount of time you wish to count
186
down for.  When ready, or even in the same cycle, enable the count--down
187
timer by setting the RUN bit high.  At this point in time, the count--down
188
timer is running.  When it gets to zero, it will stop and trigger an interrupt.
189
You can tell if the alarm has been triggered by the TRIGGER bit being set.
190
Any write to the timer register will clear the alarm condition.
191
 
192
While the timer is running, writing a '0' to the timer register will stop it
193
without clearing the time remaining.  In this state, writing to the register
194
the RUN bit by itself will restart the timer, while anything else will set the
195
timer to a new value.  Further, if the timer is stopped at zero, then writing
196
zero to the timer will reset the timer to the last start time it had.
197
 
198
\section{Stopwatch}
199
The stop watch supports three operations: start, stop, and clear.  Writing a
200
'1' to the stop watch register will start the stopwatch, while writing a '0'
201
will stop it.  When it starts next, it will start where it left off unless the
202
register is cleared.  To clear the register and set it back to zero, write a
203
'2' to the register.  This will effectively stop the register and clear it in
204
one step.  If the register is already stopped, writing a '3' will clear and
205
start it in one step.  However, the register can only be cleared while stopped.
206
If the register is running, writing a '3' will have no effect.
207
 
208
\section{Alarm}
209
To set the alarm, just write the alarm time to the alarm register together
210
with alarm enable bit.  As with the time register, setting any field,
211
whether hours, minutes, or seconds, to {\tt 8'hff} has no effect on that
212
field.  Hence, the alarm may be activated by writing {\tt 25'h13fffff} to
213
the register and deactivated by writing {\tt 25'h03fffff}.
214
 
215
Once the alarm is tripped, the RTC core will generate an interrupt.  Further,
216
the tripped bit in the alarm register will be set.  To clear this bit and the
217
alarm tripped condition, either disable the alarm or write a '1' to this bit.
218
 
219
\section{Time Hacks}
220
 
221
For finer precision timing, the RTC module allows for setting a time
222
hack and reading the value from the device.  On the clock following the
223
time hack being high, the internal state, to include the time and the 48~bit
224
counter, will be recorded and may then be read out.  In this fashion,
225
it is possible to capture, with as much precision as the device offers,
226
the current time within the device.
227
 
228
It is the users responsibility to read the time hack registers before a
229
subsequent time hack pulse sets them to new values.
230
 
231 5 dgisselq
\section{Date}
232
The Real--Time Date module is really a separate module from the Real--Time
233
Clock module, but that doesn't prevent it from working just like the others.
234
To set the date, just write the new date value to the address of the date.
235
Further, as with the clock time, setting any particular field of the date to
236
all ones, such as setting the month to {\tt 8'hff}, will cause that portion of
237
the date to retain it's current value.  In this way, one part of the date
238
may be set and not others.
239
 
240 2 dgisselq
\chapter{Registers}\label{chap:regs}
241
This RTC clock module supports eight registers, as listed in
242
Tbl.~\ref{tbl:reglist}.  Of these eight, the first four have been so placed
243
as to be the more routine or user used registers, while the latter four are
244
more lower level.
245
\begin{table}[htbp]
246
\begin{center}
247
\begin{reglist}
248
CLOCK   & 0 & 32 & R/W & Wall clock time register\\\hline
249
TIMER   & 1 & 32 & R/W & Count--down timer\\\hline
250
STPWTCH & 2 & 32 & R/W & Stopwatch control and value\\\hline
251
ALARM   & 3 & 32 & R/W & Alarm time, and setting\\\hline\hline
252
CKSPEED & 4 & 32 & R/W & Clock speed control.\\\hline
253
HACKTIME &5 & 32 & R & Wall clock time at last hack.\\\hline
254
HACKCNTHI&6 & 32 & R & Wall clock time.\\\hline
255
HACKCNTLO&7 & 32 & R & Wall clock time.\\\hline
256
\end{reglist}\caption{List of Registers}\label{tbl:reglist}
257
\end{center}\end{table}
258
Each register will be discussed in detail in this chapter.
259
 
260 5 dgisselq
The Date module supports an additional register, listed in
261
Tbl.~\ref{tbl:datereg}.
262
\begin{table}[htbp]
263
\begin{center}
264
\begin{reglist}
265
DATE    & 0 & 32 & R/W & Calendar date register\\\hline
266
\end{reglist}\caption{Date Register}\label{tbl:datereg}
267
\end{center}\end{table}
268
This register will be discussed after we discuss the time registers.
269
 
270 2 dgisselq
\section{Clock Time Register}
271
The various bit fields associated with the current time may be found in
272
the {\tt CLOCK} register, shown in Tbl.~\ref{tbl:clockreg}.
273
\begin{table}[htbp]\begin{center}
274
\begin{bitlist}
275
28--31 & R & Always return zero.\\\hline
276
24--27 & R/W & Seven Segment Display Mode.\\\hline
277
22--23 & R & Always return zero.\\\hline
278
16--21 & R/W & Current time, BCD hours\\\hline
279
8--15 & R/W & Current time, BCD minutes\\\hline
280
0--7 & R/W & Current time, BCD seconds\\\hline
281
\end{bitlist}
282
\caption{Clock Time Register Bit Definitions}\label{tbl:clockreg}
283
\end{center}\end{table}
284
This register contains six clock digits: two each for hours, minutes, and
285
seconds.  Each of these digits is encoded in Binary Coded Decimal (BCD).
286
Therefore, 23~hours would be encoded as 6'h23 and not 6'h17.  Writes to each
287
of the various subcomponent registers will set that register, unless the
288
write value is a 8'hff.  The behaviour of the clock when non--decimal
289
values are written, other than all F's, is undefined.
290
 
291
Separate from the time, however, is the seven segment display mode.  Four
292
values are currently supported: 4'h0 to display the hours and minutes,
293
4'h1 to display the timer in minutes and seconds, 4'h2 to display the
294
stopwatch in lower order minutes, seconds, and sixteenths of a second, and
295
4'h3 to display the minutes and seconds of the current time.  In all cases,
296
the decimal point will appear to the right of the lowest order digit
297
and will blink with the second hand.  That is, the decimal will be high for
298
the second half of any second, and low at the top of the second.
299
 
300
\section{Countdown Timer Register}
301
The countdown timer register, whose bit--wise values are shown in
302
Tbl.~\ref{tbl:timer},
303
\begin{table}[htbp]
304
\begin{center}
305
\begin{bitlist}
306
26--31 & R & Unused, always read as '0'.\\\hline
307
25 & R/W & Alarm condition.  Write a '1' to clear.\\\hline
308
24 & R/W & Running, stopped on '0'\\\hline
309
16--23 & R/W & BCD Hours\\\hline
310
8--15 & R/W & BCD Minutes\\\hline
311
0--7 & R/W & BCD Seconds\\\hline
312
\end{bitlist}
313
\caption{Count--down Timer register}\label{tbl:timer}
314
\end{center}\end{table}
315
controls the operation of the count--down timer.  To use this timer, write
316
some amount of time to the register, then write zeros with bit 24 set.  The
317
register will then reach an alarm condition after counting down that amount
318
of time.  (Alternatively, you could set bit 24 while writing the register,
319
to set and start it in one operation.)  To stop the register while it is
320
running, just write all zeros.  To restart the register, provided more than a
321
second remains, write a {\tt 26'h1000000} to set it running again.  Once
322
the timer alarms, the timer will stop and the alarm condition will be set.
323
Any write to the timer register after the alarm condition has been set will
324
clear the alarm condition.
325
 
326
\section{Stopwatch Register}
327
The various bits of the stopwatch register are shown in
328
Tbl.~\ref{tbl:stopwatch}.
329
\begin{table}[htbp]
330
\begin{center}
331
\begin{bitlist}
332
24--31 & R & Hours\\\hline
333
16--23 & R & Minutes\\\hline
334
8--15 & R & Sub Seconds\\\hline
335
1--7 & R & Sub Seconds\\\hline
336
1 & W & Clear\\\hline
337
 
338
\end{bitlist}
339
\caption{Stopwatch Register}\label{tbl:stopwatch}
340
\end{center}\end{table}
341
Of note is the bottom bit that, when set, means the stop watch is running.
342
Set this bit to '1' to start the stopwatch, or to '0' to stop the stopwatch.
343
Further, while the stopwatch is stopped, a '1' can be written to the clear
344
bit.  This will zero out the stopwatch and set it back to zero.
345
 
346
\section{Alarm Register}
347
The various bits of the alarm register are shown in Tbl.~\ref{tbl:alarm}.
348
\begin{table}[htbp]
349
\begin{center}
350
\begin{bitlist}
351
26--31 & R & Always reads zeros. \\\hline
352
25 & R/W & Alarm tripped.  Write a '1' to this register to clear any alarm
353
        condition.  (A tripped alarm will not trip again.)\\\hline
354
24 & R/W & Alarm enabled\\\hline
355
16--23 & R & Alarm time, BCD hours\\\hline
356
8--15 & R & Alarm time, BCD minutes\\\hline
357
0--7 & R/W & Alarm time, BCD Seconds\\\hline
358
\end{bitlist}
359
\caption{Alarm Register}\label{tbl:alarm}
360
\end{center}\end{table}
361
Basically, the alarm register consists a time and two more bits.  The extra
362
two bits encode whether or not the alarm is enabled, and whether or not it has
363
been tripped.  The alarm will be {\em tripped} whenever it is enabled, and the
364
time changes to equal the alarm time.  Once tripped, the alarm will stay
365
in the alarmed or tripped condition until either a '1' is written to the
366
tripped bit, or the alarm is disabled.
367
 
368
As with the clock and timer registers, writing eight ones to any of the
369
BCD fields when writing to this register will leave those fields untouched.
370
 
371
\section{Clock Speed Register}
372
The actual speed of the clock is controlled by the {\tt CKSPEED} register,
373
shown in Tbl.~\ref{tbl:ckspeed}.
374
\begin{table}[htbp]
375
\begin{center}
376
\begin{bitlist}
377
0--31 & R/W & 48~bit counter time increment\\\hline
378
\end{bitlist}
379
\caption{Clock Speed Register}\label{tbl:ckspeed}
380
\end{center}\end{table}
381
This register contains a simple 32~bit unsigned value.  To step the clock,
382
this value is extended to 48~bits and added to the fractional seconds value.
383
 
384
This value should be set to $2^{48}$ divided by the clock frequency of the
385
controlling clock.  Hence, for a 100~MHz clock, this value would be set to
386
{\tt 32'd2814750}.  For clocks near 100~MHz, this allows adjusting speed
387
within about 40~clocks per second.  For clocks near 500~MHz, this allows
388
time adjustment to an accuracy of about about 800~clocks per second.  In
389
both cases, this is good enough to maintain a clock with less than a
390
microsecond loss over the course of a year.  Hence, this RTC module provides
391
more logical stability than most hardware clocks on the market today.
392
 
393
\section{Time--hack time}
394
To support finer precision clock control, the time--hack capability exists.
395
This capability consists of three registers, the time--hack time register
396
shown in Tbl.~\ref{tbl:hacktime},
397
\begin{table}[htbp]
398
\begin{center}
399
\begin{bitlist}
400
24--31 & R & BCD Hours.\\\hline
401
16--23 & R & BCD Minutes.\\\hline
402
8--15 & R & BCD seconds.\\\hline
403
0--7 & R & Subseconds, encoded in 256ths of a second\\\hline
404
\end{bitlist}
405
\caption{Time Hack Time Register}\label{tbl:hacktime}
406
\end{center}\end{table}
407
and two registers (Tbls.~\ref{tbl:hackcnthi}
408
\begin{table}[htbp]
409
\begin{center}
410
\begin{bitlist}
411
0--31 & R & Upper 32 bits of the internal 40~bit counter.\\\hline
412
\end{bitlist}
413
\caption{Time Hack Counter, High}\label{tbl:hackcnthi}
414
\end{center}\end{table}
415
and~\ref{tbl:hackcntlo})
416
\begin{table}[htbp]
417
\begin{center}
418
\begin{bitlist}
419
24--31 & R & Bottom 8~bits of the internal 40~bit counter.\\\hline
420
0--23 & R & Always read as '0'.\\\hline
421
\end{bitlist}
422
\caption{Time Hack Counter, Low}\label{tbl:hackcntlo}
423
\end{center}\end{table}
424
capturing the contents of the 40~bit internal counter at the time of the hack.
425
 
426
The time--hack time register is perhaps the simplest to understand.  This
427
captures the time of the time--hack in hours, minutes, seconds, and 8~fractional
428
subsecond bits.  The top 24~bits of this register will match the bottom 24~bits
429
of the clock~time register at the time of the time hack.  The bottom eight
430
bits are the top eight bits of the 48~bit subsecond time counter.  The
431
rest of those 48~bits may then be returned in the other two time hack counter
432
registers.
433
 
434
At present, this functionality isn't yet truly fully featured.  Once fully
435
featured, there will (should) be a mechanism for adjusting this counter based
436
upon information gleaned from the hack time.  Implementation details have
437
to date prevented this portion of the design from being implemented.
438
 
439 5 dgisselq
\section{Date Register}
440
The year, month, and day of month fields may all be found within the
441
{\tt DATE} register of the Real--Time Date module, shown in
442
Tbl.~\ref{tbl:datebits}.
443
\begin{table}[htbp]\begin{center}
444
\begin{bitlist}
445
30--31 & R & Always return zero.\\\hline
446
16--29 & R/W & Four digit BCD year\\\hline
447
13--15 & R & Always return zero.\\\hline
448
8--12 & R/W & Two digit BCD month\\\hline
449
6--7 & R & Always return zero.\\\hline
450
0--5 & R/W & Two digit BCD day of month\\\hline
451
\end{bitlist}
452
\caption{Date Register Bit Definitions}\label{tbl:datebits}
453
\end{center}\end{table}
454
Further, according to the common calendar convention, the minimum day and month
455
are one and not zero.
456
 
457 2 dgisselq
\chapter{Wishbone Datasheet}\label{chap:wishbone}
458
Tbl.~\ref{tbl:wishbone}
459
\begin{table}[htbp]
460
\begin{center}
461
\begin{wishboneds}
462
Revision level of wishbone & WB B4 spec \\\hline
463
Type of interface & Slave, Read/Write \\\hline
464
Port size & 32--bit \\\hline
465
Port granularity & 32--bit \\\hline
466
Maximum Operand Size & 32--bit \\\hline
467
Data transfer ordering & (Irrelevant) \\\hline
468
Clock constraints & Faster than 66~kHz \\\hline
469
Signal Names & \begin{tabular}{ll}
470
                Signal Name & Wishbone Equivalent \\\hline
471
                {\tt i\_clk} & {\tt CLK\_I} \\
472
                {\tt i\_wb\_cyc} & {\tt CYC\_I} \\
473
                {\tt i\_wb\_stb} & {\tt STB\_I} \\
474
                {\tt i\_wb\_we} & {\tt WE\_I} \\
475
                {\tt i\_wb\_addr} & {\tt ADR\_I} \\
476
                {\tt i\_wb\_data} & {\tt DAT\_I} \\
477
                {\tt o\_wb\_ack} & {\tt ACK\_O} \\
478
                {\tt o\_wb\_stall} & {\tt STALL\_O} \\
479
                {\tt o\_wb\_data} & {\tt DAT\_O}
480
                \end{tabular}\\\hline
481
\end{wishboneds}
482
\caption{Wishbone Datasheet}\label{tbl:wishbone}
483
\end{center}\end{table}
484
is required by the wishbone specification, and so
485 5 dgisselq
it is included here.  The big thing to notice is that both the real time clock
486
and the real time date modules act as wishbone slaves, and that all accesses
487
to the registers of either module are 32--bit reads and writes.  The address
488
bus does not offer
489 2 dgisselq
byte level, but rather 32--bit word level resolution.  Select lines are not
490
implemented.  Bit ordering is the normal ordering where bit~31 is the most
491
significant bit and so forth.  Although the stall line is implemented, it is
492
always zero.  Access delays are a single clock, so the clock after a read or
493
write is placed on the bus the {\tt i\_wb\_ack} line will be high.
494
 
495
\iffalse
496
\chapter{Clocks}\label{chap:clocks}
497
 
498
This core is based upon the Basys--3 design.  The Basys--3 development board
499
contains one external 100~MHz clock, which is sufficient to run this
500
core.  The logic within the core can also be run faster, or slower, as is
501
necessary to meet the timing constraints associated with the internal
502
operations of the core and it's surrounding environment.  See
503
Table.~\ref{tbl:clocks}.
504
\begin{table}[htbp]
505
\begin{center}
506
\begin{clocklist}
507
i\_clk & External & 250~THz & 66~kHz & System clock.\\\hline
508
\end{clocklist}
509
\caption{List of Clocks}\label{tbl:clocks}
510
\end{center}\end{table}
511
 
512
\fi
513
 
514
\chapter{I/O Ports}\label{chap:ioports}
515 5 dgisselq
The I/O ports for this clock are shown in Tbls.~\ref{tbl:iowishbone}
516 2 dgisselq
\begin{table}[htbp]
517
\begin{center}
518
\begin{portlist}
519 5 dgisselq
i\_clk & 1 & Input & System clock, used for time and wishbone interfaces.\\\hline
520 2 dgisselq
i\_wb\_cyc & 1 & Input & Wishbone bus cycle wire.\\\hline
521
i\_wb\_stb & 1 & Input & Wishbone strobe.\\\hline
522
i\_wb\_we & 1 & Input & Wishbone write enable.\\\hline
523
i\_wb\_addr & 5 & Input & Wishbone address.\\\hline
524
i\_wb\_data & 32 & Input & Wishbone bus data register for use when writing
525
        (configuring) the core from the bus.\\\hline
526
o\_wb\_ack & 1 & Output & Return value acknowledging a wishbone write, or
527
                signifying valid data in the case of a wishbone read request.
528
                \\\hline
529
o\_wb\_stall & 1 & Output & Indicates the device is not yet ready for another
530
                wishbone access, effectively stalling the bus.\\\hline
531
o\_wb\_data & 32 & Output & Wishbone data bus, returning data values read
532
                from the interface.\\\hline
533
\end{portlist}
534
\caption{Wishbone I/O Ports}\label{tbl:iowishbone}
535
\end{center}\end{table}
536
and~Tbl.~\ref{tbl:ioother}.
537
\begin{table}[htbp]
538
\begin{center}
539
\begin{portlist}
540
o\_sseg & 32 & Output & Lines to control a seven segment display, to be
541
                sent to that display's driver.  Each eight bit byte controls
542
                one digit in the display, with the bottom bit in the byte
543
                controlling the decimal point.\\\hline
544
o\_led & 16 & Output & Output LED's, consisting of a 16--bit counter counting
545
                from zero to all ones each minute, and synchronized with each
546
                minute so as to create an indicator of when the next minute
547
                will take place when only the hours and minutes can be
548
                displayed.\\\hline
549
o\_interrupt & 1 & Output & A pulsed/strobed interrupt line.  When the
550
                clock needs to generate an interrupt, it will set this line
551
                high for one clock cycle.  \\\hline
552 5 dgisselq
o\_ppd & 1 & Output & A `pulse per day' signal which can be fed into the
553
        real--time date module.  This line will be high on the clock before
554
        the stroke of midnight, allowing the date module to turn over to the
555
        next day at exactly the same time the clock module turns over to the
556
        next day.\\\hline
557 2 dgisselq
i\_hack & 1 & Input & When this line is raised, copies are made of the
558
        internal state registers on the next clock.  These registers can then
559
        be used for an accurate time hack regarding the state of the clock
560
        at the time this line was strobed.\\\hline
561
\end{portlist}
562
\caption{Other I/O Ports}\label{tbl:ioother}
563
\end{center}\end{table}
564
Tbl.~\ref{tbl:iowishbone} reiterates the wishbone I/O values just discussed in
565
Chapt.~\ref{chap:wishbone}, and so need no further discussion here.
566
 
567
This clock is designed for command and control via the wishbone.  No other
568
registers, beyond the wishbone bus, are required.  However, several other
569
may be valuable.  These other registers are listed in Tbl.~\ref{tbl:ioother}.
570
We'll discuss each of these in turn.
571
 
572
First of the other I/O registers is the {\tt o\_sseg} register.  This register
573
encodes which outputs of a seven segment display need to be turned on to
574
represent the value of the clock requested.  This register consists of four
575
eight bit bytes, with the highest order byte referencing the highest order
576
display segment value.  In each byte, the low order bit references a decimal
577
point.  The other bits are ordered around the zero, with the top bit being
578
the top bar of a '0', the next highest order bit and so on following the
579
zero clockwise.  The final bit of each byte, the bit in the two's place,
580
encodes whether or not the middle line is to be displayed.  When either timer
581
or alarm is triggered, this display will blink until the triggering conditions
582
are cleared.
583
 
584
This output is expected to be the input to a seven segment display driver,
585
rather than being the output to the display itself.
586
 
587
The next output lines are the 16~lines of the {\tt o\_led} bus.  When connected
588
with 16~LED's, these lines will create a counting display that will count up
589
to each minute, synchronized to the minute.  When either timer or alarm has
590
triggered, all of the LED's will flash together until the triggered condition
591
is reset.
592
 
593
The third other line is the {\tt o\_interrupt} line.  This line will be
594
strobed by the RTC module any time the alarm is triggered or the timer runs
595
out.  The line will not remain high, but neither will it trigger a second
596
time until the underlying interrupt is cleared.  That is, the timer will only
597
trigger once until cleared as will the alarm, but the alarm may trigger after
598
the timer has triggered and before the timer clears.
599
 
600 5 dgisselq
As a fourth additional line, the clock module produces a one pulse per day
601
signal, {\tt o\_ppd}.  This signal is designed to be the only necessary
602
coordinated input between the clock and date module.  Feeding it straight
603
into the date module will keep the two synchronized.
604
 
605 2 dgisselq
The final other I/O line is a simple input line.  This line is expected to be
606
strobed for one clock cycle any time a time hack is required.  For example,
607
should you wish to read and synchronize to a GPS PPS signal, strobe the device
608
with the PPS (after dealing with any metastability issues), and read the time
609
hacks that are produced.
610
 
611 5 dgisselq
The real--time date module has a similar set of I/O ports to the clock.  These
612
are listed in Tbl.~\ref{tbl:iodate}.
613
\begin{table}[htbp]
614
\begin{center}
615
\begin{portlist}
616
i\_clk & 1 & Input & The system clock.\\\hline
617
i\_ppd & 1 & Input & The one pulse per day strobe from the clock module.\\\hline
618
i\_wb\_cyc & 1 & Input & Wishbone bus cycle.\\\hline
619
i\_wb\_stb & 1 & Input & Wishbone strobe.\\\hline
620
i\_wb\_we & 1 & Input & Wishbone write enable.\\\hline
621
i\_wb\_data & 32 & Input & Wishbone bus data register for use when writing
622
        (configuring) the core from the bus.\\\hline
623
o\_wb\_ack & 1 & Output & Equal to the bus cycle line anded with the strobe
624
                line, and delayed by one clock---essentially acknowledging any
625
                wishbone access.\\\hline
626
o\_wb\_stall & 1 & Output & Fixed to zer.\\\hline
627
o\_wb\_data & 32 & Output & Wishbone data bus, returning data values read
628
                from the interface.\\\hline
629
\end{portlist}
630
\caption{Wishbone I/O Ports}\label{tbl:iodate}
631
\end{center}\end{table}
632
There are two big things to notice.  The first is the {\tt i\_ppd} signal.
633
This should be connected straight from the clock module's {\tt o\_ppd} signal
634
into this module.  The second difference is the lack of any address lines.
635
This is appropriate since the date module provides a single register only.
636
 
637 2 dgisselq
% Appendices
638
% Index
639
\end{document}
640
 
641
 

powered by: WebSVN 2.1.0

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