~ubuntu-branches/ubuntu/lucid/fceux/lucid

« back to all changes in this revision

Viewing changes to fceu/documentation/tech/exp/vrcvi.txt

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-12-14 08:05:17 UTC
  • Revision ID: james.westby@ubuntu.com-20091214080517-abi5tj8avthfan7c
Tags: upstream-2.1.2+repack
ImportĀ upstreamĀ versionĀ 2.1.2+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
                               VRCVI CHIP INFO
 
2
                               ----- ---- ----
 
3
 
 
4
                                     By:
 
5
 
 
6
 
 
7
                                Kevin Horton
 
8
                             khorton@iquest.net
 
9
                             
 
10
                             
 
11
                             
 
12
                             
 
13
                             The RENES Project:
 
14
                             Reverse-engineering
 
15
                                 the world.
 
16
 
 
17
 
 
18
 
 
19
 
 
20
V1.01 08/31/99 teeny fix 
 
21
V1.00 08/31/99 Complete Version
 
22
 
 
23
 
 
24
 
 
25
VRCVI (VRC6)  (48 pin standard 600mil wide DIP)
 
26
------------ 
 
27
This chip is used in such games as Konami's CV3j and Madara.  It's unique
 
28
because it has some extra sound channels on it that get piped through the
 
29
Famicom (note this is a fami-only chip and you will not find one in any
 
30
NES game).  "VI" of "VRCVI" is "6" for the roman numeral challenged.
 
31
 
 
32
 
 
33
This chip generates its audio via a 6 bit R2R ladder.  This is contained 
 
34
inside a 9 pin resistor network like so:
 
35
 
 
36
 
 
37
                  3K     3K     3K     3K     3K            2K
 
38
        /------*-\/\/-*-\/\/-*-\/\/-*-\/\/-*-\/\/-*------*-\/\/-\
 
39
        |      |      |      |      |      |      |      |      |
 
40
        \      \      \      \      \      \      \      |      |
 
41
        /      /      /      /      /      /      /      |      |
 
42
        \ 6K   \ 6K   \ 6K   \ 6K   \ 6K   \ 6K   \ 6K   |      |
 
43
        /      /      /      /      /      /      /      |      |
 
44
        |      |      |      |      |      |      |      |      |
 
45
        O      O      O      O      O      O      O      O      O
 
46
 
 
47
       GND     D0     D1     D2     D3     D4     D5  Aud In  Aud Out
 
48
 
 
49
 
 
50
Legend:
 
51
-------
 
52
 
 
53
(s) means this pin connects to the System
 
54
(r) this only connects to the ROM
 
55
(w) this is a SRAM/WRAM connection only
 
56
AUD : these pass to the resistor network
 
57
CHR : these connect to the CHR ROM and/or fami's CHR pins
 
58
PRG : these connect to the PRG ROM and/or fami's PRG pins
 
59
WRAM : this hooks to the WRAM
 
60
CIRAM : the RAM chip which is on the fami board 
 
61
 
 
62
                                  .----\/----.
 
63
                            GND - |01      48| - +5V
 
64
                        AUD  D1 - |02      47| - AUD  D0   
 
65
                        AUD  D3 - |03      46| - AUD  D2
 
66
                        AUD  D5 - |04      45| - AUD  D4
 
67
                    (s) PRG A12 - |05      44| - PRG A16 (r)
 
68
                    (s) PRG A14 - |06      43| - PRG A13 (s)
 
69
                         (s) M2 - |07      42| - PRG A17 (r)
 
70
                    (r) PRG A14 - |08      41| - PRG A15 (r)
 
71
                *1  (s) PRG  A1 - |09      40| - PRG A13 (r)
 
72
                *1  (s) PRG  A0 - |10      39| - PRG  D7 (s)
 
73
                    (s) PRG  D0 - |11      38| - PRG  D6 (s)
 
74
                    (s) PRG  D1 - |12      37| - PRG  D5 (s)
 
75
                    (s) PRG  D2 - |13      36| - PRG  D4 (s)
 
76
                    (r) PRG /CE - |14      35| - PRG  D3 (s)
 
77
                        (s) R/W - |15      34| - PRG /CE (s)
 
78
                *2 (w) WRAM /CE - |16      33| - /IRQ (s)
 
79
                    (r) CHR /CE - |17      32| - CIRAM /CE (s)
 
80
                    (s) CHR /RD - |18      31| - CHR A10 (s)
 
81
                   (s) CHR /A13 - |19      30| - CHR A11 (s)
 
82
                    (r) CHR A16 - |20      29| - CHR A12 (s)
 
83
                    (r) CHR A15 - |21      28| - CHR A17 (r)
 
84
                    (r) CHR A12 - |22      27| - CHR A14 (r)
 
85
                    (r) CHR A11 - |23      26| - CHR A13 (r)
 
86
                            GND - |24      25| - CHR A10 (r)
 
87
                                  |          |
 
88
                                  `----------'
 
89
 
 
90
                                     VRCVI
 
91
 
 
92
 
 
93
*1: On some VRCVI carts, these are reversed.  This affects some registers.
 
94
 
 
95
*2: This passes through a small pulse shaping network consisting of a 
 
96
    resistor, diode, and cap.
 
97
 
 
98
 
 
99
Registers:  (sound related only)
 
100
----------  
 
101
 
 
102
regs 9000-9002 are for pulse channel #1
 
103
regs a000-a002 are for pulse channel #2
 
104
regs b000-b002 are for the phase accumulator channel (sawtooth)
 
105
 
 
106
(bits listed 7 through 0)
 
107
 
 
108
9000h: GDDDVVVV
 
109
 
 
110
        D - Duty Cycle bits:
 
111
 
 
112
          000 - 1/16th  ( 6.25%)
 
113
          001 - 2/16ths (12.50%)
 
114
          010 - 3/16ths (18.75%)
 
115
          011 - 4/16ths (25.00%)
 
116
          100 - 5/16ths (31.25%)
 
117
          101 - 6/16ths (37.50%)
 
118
          110 - 7/16ths (43.75%)
 
119
          111 - 8/16ths (50.00%)
 
120
 
 
121
        V - Volume bits. 0000b is silence, 1111b is loudest.  Volume is 
 
122
        linear.  When in "normal" mode (see G bit), this acts as a general 
 
123
        volume control register.  When in "digitized" mode, these act as a 
 
124
        4 bit sample input.
 
125
 
 
126
        G - Gate bit. 0=normal operation, 1=digitized.  In digi operation, 
 
127
        registers 9001h and 9002h are totally disabled.  Only bits 0-3 of 
 
128
        9000h are used.  Whatever binary word is present here is passed on 
 
129
        as a 4 bit digitized output.
 
130
 
 
131
 
 
132
9002h: FFFFFFFF 
 
133
 
 
134
        F - Lower 8 bits of frequency data
 
135
 
 
136
 
 
137
9003h: X---FFFF
 
138
 
 
139
        X - Channel disable.  0=channel disabled, 1=channel enabled.
 
140
 
 
141
        F - Upper 4 bits of frequency data
 
142
 
 
143
 
 
144
A000h-A002h are identical in operation to 9000h-9002h.  One note: this chip
 
145
will mix both digitized outputs (if the G bits are both set) into one
 
146
added output. (see in-depth chip operation below)
 
147
 
 
148
B000h: --PPPPPP
 
149
 
 
150
        P - Phase accumulator input bits
 
151
 
 
152
B001h: FFFFFFFF 
 
153
 
 
154
        F - Lower 8 bits of frequency data
 
155
 
 
156
B002h: X---FFFF
 
157
 
 
158
        X - Channel disable. 0=channel disabled, 1=channel enabled.
 
159
 
 
160
        F - Upper 4 bits of frequency data
 
161
 
 
162
 
 
163
 
 
164
How the sounds are formed:
 
165
--------------------------
 
166
 
 
167
This chip is pretty cool.  It outputs a 6 bit binary word for the sound
 
168
which is passed through a DAC and finally to the NES/Fami.  Because of this,
 
169
the sound can be emulated *very* close to the original.
 
170
 
 
171
 
 
172
I used my scope to figure all this out as well as my meter and logic probe
 
173
so it should be 100% accurate.
 
174
 
 
175
 
 
176
 
 
177
Block diagrams of the VRCVI: (as reverse engineered by me)
 
178
----------------------------
 
179
 
 
180
 
 
181
             |   F bits  |       | D bits|       | V bits |
 
182
             |    (12)   |       |  (3)  |       |  (4)   |
 
183
             \___________/       \_______/       \________/
 
184
+-----+   +----------------+   +-----------+   +------------+
 
185
|     |   |                |   |           |   |            |--\
 
186
| OSC |-->|Divider (12 bit)|-->| Duty Cycle|-->|  AND array |(4)> chan out
 
187
|(M2) |   |                |   | Generator |   |            |--/
 
188
+-----+   +----------------+   +-----------+   +------------+
 
189
                                   ^    ^
 
190
                                   |    |
 
191
                                   |    |
 
192
                                   G    X
 
193
 
 
194
                  One Pulse channel (both are identical)
 
195
                  --------------------------------------
 
196
 
 
197
 
 
198
How it works:  The oscillator (in the NES, the clock arrives on the M2 line 
 
199
and is about 1.78Mhz) generates our starting frequency.  This is passed
 
200
first into a divide by 1 to 4096 divider to generate a base frequency.
 
201
This is then passed to the duty cycle generator. The duty cycle generator
 
202
generates the desired duty cycle for the output waveform.  The "D" input 
 
203
controls the duty cycle generator's duty cycle.  If the "G" bit is 
 
204
a "1", it forces the output of the duty cycle generator to a "1" also.  If 
 
205
the "X" bit is "0", it forces the output of the duty cycle generator to "0",
 
206
which effectively disables the channel.  Note that this input has precidence
 
207
over the "G" bit.
 
208
 
 
209
The AND array is just that- an array of 4 AND gates.  If the output of
 
210
the duty cycle generator is a "0", then the "chan out" outputs will all be
 
211
forced to "0".  If the output of the duty cycle generator is a "1", then
 
212
the chan out outputs will follow the V bit inputs.
 
213
 
 
214
Note that the output of this generator is a 4 bit binary word. 
 
215
 
 
216
 
 
217
---
 
218
 
 
219
 
 
220
             |   F bits  |       | P bits|
 
221
             |    (12)   |       |  (6)  |
 
222
             \___________/       \_______/
 
223
+-----+   +----------------+   +-----------+
 
224
|     |   |                |   |           |--\
 
225
| OSC |-->|Divider (12 bit)|-->|   Phase   |(5)> chan out
 
226
|(M2) |   |                |   |Accumulator|--/
 
227
+-----+   +----------------+   +-----------+
 
228
                                        ^
 
229
                                        |
 
230
                                        |
 
231
                                        X
 
232
 
 
233
                        The Sawtooth (ramp) channel
 
234
                        ---------------------------
 
235
 
 
236
 
 
237
This one is pretty similar to the above when it comes to frequency selection.
 
238
The output frequency will be the same relative to the square wave channels.
 
239
OK, the tough part will be explaining the phase accumulator. :-)  What it is
 
240
is just an adder tied to a latch.  Every clock it adds a constant to the
 
241
latch.  In the case of the VRCVI, what you do is this:
 
242
 
 
243
The ramp is generated over the course of 7 evenly spaced cycles, generated
 
244
from the divider.  Every clock from the divider causes the phase accumulator
 
245
to add once.  So... let's say we have 03h in the P bits.  Every 7 cycles
 
246
the phase accumulator (which is 8 bits) is reset to 00h.  
 
247
 
 
248
 
 
249
cycle: accumulator:  chan out: notes:
 
250
-----------------------------------------
 
251
0      00h           00h       On the first cycle, the acc. is reset to 0 
 
252
1      03h           00h       We add 3 to 0 to get 3
 
253
2      06h           00h       We add 3 to 3 to get 6
 
254
3      09h           01h
 
255
4      0ch           01h
 
256
5      0fh           01h
 
257
6      12h           02h
 
258
7      00h           00h       Reset the acc. back to 0 and do it again
 
259
 
 
260
 
 
261
This will look like so: (as viewed on an oscilloscope)
 
262
 
 
263
 
 
264
 
 
265
      -      -      - 2
 
266
   ---    ---    ---  1
 
267
---    ---    ---     0
 
268
                      |
 
269
012345601234560123456-+
 
270
 
 
271
 
 
272
 
 
273
Note: if you enter a value that is too large (i.e. 30h) the accumulator
 
274
*WILL WRAP*. Yes, this doesn't sound very good at all and you no longer
 
275
have a sawtooth. ;-)
 
276
 
 
277
 
 
278
The upper 5 bits of said accumulator are run to the "chan out" outputs.  
 
279
The lower 3 bits are not run anywhere.
 
280
 
 
281
"X" disables the phase accumulator and forces all outputs to "0".
 
282
Note that the output of this generator is a 5 bit word.
 
283
 
 
284
 
 
285
---
 
286
 
 
287
Now that the actual sound generation is out of the way, here's how the
 
288
channels are combined into the final 6 bit binary output:
 
289
 
 
290
 
 
291
+---------+
 
292
|  Pulse  |
 
293
|Generator|
 
294
|   #1    |     Final 6 Bit 
 
295
+---------+       Output
 
296
  | (4) |        /     \
 
297
  \     /        | (6) |
 
298
+---------+    +---------+    +---------+
 
299
|  4 Bit  |--\ |  5 Bit  | /--|Sawtooth |
 
300
|  Binary |(5)>|  Binary |<(5)|Generator|
 
301
|  Adder  |--/ |  Adder  | \--|         |
 
302
+---------+    +---------+    +---------+
 
303
  /     \
 
304
  | (4) |
 
305
+---------+
 
306
|  Pulse  |
 
307
|Generator|
 
308
|   #2    |
 
309
+---------+
 
310
 
 
311
                        Channel Combining
 
312
                        -----------------
 
313
 
 
314
 
 
315
The three channels are finally added together through a series of adders
 
316
to produce the final output word. The two pulse chans are most likely added
 
317
first since they are 4 bit words, and that 5 bit result is most likely
 
318
added to the sawtooth's output. (The actual adding order is not known,
 
319
but I can make a *very* good guess.  The above illustrated way uses the least
 
320
amount of transistors).  In the end it does not matter the order in which
 
321
the words are added; the final word will always be the same.
 
322
 
 
323
The final 6 bit output word is run through an "R2R" resistor ladder which
 
324
turns the digital bits into a 64 level analog representation.  The ladder
 
325
is binarally weighted and works like the DAC on your soundcard. :-)
 
326
(so take heart emulator authours: just run the finished 6 bit word to
 
327
your soundcard and it will sound right ;-).
 
328
 
 
329
 
 
330
 
 
331
Frequency Generation:
 
332
---------------------
 
333
 
 
334
The chip generates all its output frequencies based on M2, which is
 
335
colourburst divided by two (1789772.7272Hz).  This signal is passed
 
336
directly into the programmable dividers (the 12 bit frequency regs).
 
337
 
 
338
Squares:
 
339
--------
 
340
 
 
341
These take the output of the programmable divider and then run it through
 
342
the duty cycle generator, which in the process of generating the duty cycle,
 
343
divides the frequency by 16.  
 
344
 
 
345
 
 
346
To calculate output frequency:
 
347
 
 
348
         1789772.7272
 
349
Fout = ----------------
 
350
       (freq_in+1) * 16
 
351
 
 
352
 
 
353
This will tell you the exact frequency in Hz. (note that the * 16 is to
 
354
compensate for the divide by 16 duty cycle generator.)
 
355
 
 
356
Saw:
 
357
----
 
358
 
 
359
This is similar to the above, however the duty cycle generator is replaced
 
360
with a phase accumulator which divides the output frequency by 14.
 
361
 
 
362
 
 
363
To calculate output frequency:
 
364
 
 
365
         1789772.7272
 
366
Fout = ----------------
 
367
       (freq_in+1) * 14
 
368
 
 
369
 
 
370
This will tell you the exact frequency in Hz. (note that the * 14 is to
 
371
compensate for the phase accumulator.)
 
372
 
 
373
 
 
374
 
 
375
So how accurate is this info, anyways?
 
376
--------------------------------------
 
377
 
 
378
I believe the info to be 100% accurate.  I have extensively tested the 
 
379
output of the actual VRCVI chip to this spec and everything fits perfectly.
 
380
I did this by using a register dump and a QBASIC program I wrote which
 
381
takes the register dump and produces a WAV file.  All frequency and
 
382
duty cycle measurements were taken with a Fluke 83 multimeter, and all
 
383
waveform data was culled from my oscilloscope measuring the real chip.
 
384
 
 
385
 
 
386
 
 
387
 
 
388
---EOF---