KW11-P Programmable Clock Added
The w11
had from the very beginning a KW11-L
line frequency clock.
The KW11-L
is a mandatory device used by all operating
systems to define the system time.
And it is a very simple device, it just generates interrupts every
20 msec (w11 uses 50 Hz line frequency, simply because I live in Europe).
DEC offered for the UNIBUS
systems a more sophisticated device,
the KW11-P
, which can be used as a programmable high-precision
timer.
The central element is a 16 bit counter, which is advanced by one of four
selectable inputs
- 100 kHz clock
- 10 kHz clock
- line clock (in w11 50 Hz)
- external event
The KW11-P
can generate an interrupt when a configurable
value of the counter is reached, or just count and be used to measure time
with a resolution of down to 10 µs.
The DEC manual
DEC-11-HPWB-D describes many implementation details but lacks a
complete description of the functional behavior.
The remaining ambiguities were resolved by inspection of
- 2.11BSD clock initialization code in /usr/src/sys/pdp/clock.c
- simh
model of the
KW11-P
in PDP11/pdp11_pclk.c
The implementation is in
ibd_kw11p.vhd.
The external event port EXTEVT
is connected in
ibdr_maxisys.vhd
to the instruction decode signal IDEC
,
which is usually connected in the w11
top-level design to the
DM_STAT_EXP.se_idec
signal provided by
pdp11_sys70.
I added the KW11-P
with three use cases in mind:
- as a very fast interrupt source for test benches. With the external event mode, it is possible to generate an interrupt after a preset number of instructions. Presets of as low as 20 are feasible. This allows writing interrupt tests which execute in a few 100 instructions, very nice for fast behavioral simulations, like in Section B of test_kw11p_int.tcl.
- as a high-resolution timer for test benches. Using the 100 kHz mode allows to either measure elapsed times or generate interrupts with a precision of 10 µc. Very nice for tests of the I/O system.
- and as long shot: support 2.11BSD kernel profiling.
The 2.10BSD kernel had a very simple but very memory-effective
kernel profiling feature, which simply histogramed the PC value
when in kernel mode. This was never ported to 2.11BSD, but 2.10BSD code
pieces still linger around in the 2.11BSD code base, see
and just wait to be reactivated.
A port will for sure need a bit of work
- kernel overlays must be handled
- supervisor mode should be handled (the networking code)
- the interrupt code doing the sampling must be short
- the userland analysis code will certainly gain complexity