Hi, all,
Just an update on the HDMI thingy...
I've added an output flag to the code which detects whether the N64 is outputting an interlaced signal or not (480i / 576i)...
With the interlaced modes, on the first line (after the rising edge of vsync), the hsync pulse happens half-way through a line on alternate fields (as @calpis poiinted out),
but with progressive modes (240p / 288p), the rising edge of hsync happens at the same time as the rising edge of the vsync pulse...
So, to detect between interlaced and progressive, I just check the state of the hsync signal directly after vsync goes high.
If hsync toggles on alternate frames, the output is interlaced, if hsync is always high, it's progressive.
EDIT: Forgot image. Here is a SignalTap capture of the sync pulses (240p, Hsync always coincides with first Vsync)...
Oh, damn it!! Only just noticed...
Does that mean that the sync pulses are active-HIGH after all!! That explains a lot. :redface-new:
Might also explain why my line counting was a bit dodgy. lol
EDIT2: Ok, it seems that the "blue" coloured signals are post-fitting, so the software has inverted them after compilation.
It's nice to have another thing to worry about. lol So, The signals are active-LOW as originally thought. phew...
It seems Hsync actually stays LOW on the rising edge of Vsync for progressive signals. Fixed.
The PAL detection is also working (just checks if the total lines == 625).
I've assigned these signals to two LEDs on the FPGA board and it's interesting to see how often certain "hi-res" games switch modes...
With Vigilante 8: 2nd Offence, the title screen is hi-res and looks very nice, but as soon as the animation starts where the logo (tumbles) into the distance, it switches to low-res mode.
The attract demo is also low res, so it's only hi-res on the title screen, or in the game itself if you select hi-res.
(It looks like 480i modes are displaying fine because the two fields both belong to the same framebuffer frame.)
With PAL games, it's displaying OK but missing a small part of the image to the right and lower part of the screen.
This is just because I'm still using 480p output timings instead of 576p, but I'll fix this soon.
Also, I've managed to do a nice overclock on the RCP (and hence the CPU)...
Originally I tried generating the clock signal from the FPGA itself to run the RCP, but it was too unstable (wiring too long, impedance not matched etc)...
So I just changed crystal X1 to a 20MHz one. The result is that the RCP is now theoretically running at 85MHz instead of 60.852265MHz!
On a stock NTSC N64, X1 is normally 14.31818MHz (four times the NTSC carrier freq of 3.579545MHz). This gets internally multiplied by PLL chip U7, then divided by 5 to generate "VCLK"...
14.31818MHz * 17 / 5 = 48.681812MHz
This master "VCLK" clock supplies the video output timing + video DAC, possibly the audio master clock too?
The RCP then multiplies VCLK internally by 1.25 to generate the main graphics clock...
48.681812MHz * 1.25 = 60.852265MHz
AFAIK, this is what the RCP itself actually runs at.
The graphics clock is then supplied unchanged to the MIPS CPU's Masterclock input.
The CPU then multiplies this again by 1.5 to generate the CPU clock (assuming stock pin settings)...
60.852265MHz * 1.5 = 91.2783975MHz.
This is a bit lower than I expected, unless I'm missing something obvious (quite likely).
It looks like the CPU on a PAL console runs at 93.10599375MHz.
In this case, crystal X1 is 17.734475MHz (four times the PAL carrier freq of 4.43361875MHz), but the PLL chip only multiplies by 14 instead of 17.
OK, so to cut a long story short, my N64 is running fine with this...
XTAL = 20MHz
VCLK = 68MHz
RCP = 85MHz
CPU = 127.5MHz
The reason it doesn't screw up the video signal is because the FPGA can happily accept these different frequencies then outputs it as 480p.
All I need to do when I change the crystal is adjust the PLL in the FPGA slightly to keep the 480p / HDMI output timings happy.
The obvious problem with this "overclock" is that it speeds up the audio as well as the animation timing.
I haven't changed the RDRAM clock at all, so if it's causing any bottlenecks, it might actually be worse due to the CPU / RCP trying to cram more data through it per second.
The result is quite amusing though. The voices all sound like chipmunks and the music is faster too.
Everything apart from the RDRAM is overclocked to around 140%, so even the timing of MIDI sequences is faster.
I'll have to make a vid of it soon, it's quite amusing. :witless:
Although the effective frame rate is faster, it still looks like it's lagging at the same points (relative to the faster overall speed).
So, it's probably the RDRAM latency which causes the problem (eg. on things like Goldeneye multiplayer when lots of explosions are happening).
This is what many others had pointed out in the past - RDRAM was supposed to be revolutionary back in the day, but it was expensive and didn't survive very long in the PC market.
It might have fast peak throughput of data, but apparently had relatively poor latency performance?
I might try overclocking the RDRAM by a small amount as well.
UPDATE: I tried overclocking the RDRAM with a 16MHz crystal instead of the usual 14.7MHz to give 272MHz, but it froze quite often (as others have found).
The 14.7MHz crystal was obviously chosen so the RDRAM master clock was around 250MHz (X2 gets multiplied by 17).
So not much point trying to overclock the RDRAM, it's running at it's max speed already.
The real aim of all this is to patch the ROM images so the video framerate / animation and audio is back to normal speed, but the RCP keeps the better fill rate performance.
We might then have a bit more power for hi-res games. With Castlevania: Legacy of Darkness, the frame rate seems to keep up fine with the overclock.
This tells us that the RCP / RDP draw rate is often the limiting factor with hi-res frame rates.
OK, so that was fun to mess around with, but basically the HDMI output is looking very nice.
There are still some issues though - there's a roughly 1-in-4 chance that you'll get four thin vertical lines down the screen at switch on, I'll have to figure that out.
(if you keep switching off then on, you eventually get the lines to disappear).
It's also still not outputting each 240p / 288p "frame" on separate 480p frames (no line doubling), as it will be quite tricky to figure out with this setup.
Luckily, it looks fine on my TV. I do notice the odd mouse-teeth on very fast moving objects, but it's not bad.
OzOnE.