x86 software vs hardware clocks

Emulation of old PCs, PC hardware, or PC peripherals.

Re: x86 software vs hardware clocks

Postby superfury » 2017-12-08 @ 23:21

So, the ET3000 has the following clocks(converted from Dosbox-X VGA_tseng.cpp):
0:CLK_25=>25750kHz(UniPCemu: VGA standard clocks=25175kHz)
1:CLK_28=>28322kHz(UniPCemu: VGA standard clocks=28321kHz)
2:32400=>32514kHz?
3:35900=>36000kHz?
4:39900=>44900kHz?
5:44700=>44900kHz?
6:31400=>32514kHz?
7:37500=>44900kHz?

All UniPCemu's other ET3000/ET4000 clocks(everything but the VGA 25/28MHz clocks) match the ones at Dosbox-X.

Are those actual mappings correct? And what about the ET4000?

UniPCemu's VGA standard clocks are now:
Code: Select all
//25MHz: VGA standard clock
//#define VGA25MHZ (25.2 / 1.001)*1000000.0
#define VGA25MHZ 25175000.0
//28MHz: VGA standard clock
//#define VGA28MHZ (28.35 / 1.001)*1000000.0
#define VGA28MHZ 28321000.0


The EGA(clock #1(0-based)/MDA clocks are their rounded values(16.257MHz). The EGA(clock #0)/CGA 14MHz clocks uses the cycle-accurate 14MHz BUS clock(which also times most hardware based on that clock directly).
superfury
l33t
 
Posts: 2618
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: x86 software vs hardware clocks

Postby elianda » 2017-12-09 @ 02:40

superfury wrote:Are those actual mappings correct? And what about the ET4000?


See numbers
http://retronn.de/imports/hwgal/hw_grap ... 000ax.html
Retronn.de - Vintage Hardware Gallery, Drivers, Guides, HQ Videos.
Youtube Channel
FTP Server - Driver Archive and more
DVI2PCIe alignment and 2D image quality measurement tool
User avatar
elianda
l33t
 
Posts: 2225
Joined: 2006-4-21 @ 16:56
Location: Halle / Germany

Re: x86 software vs hardware clocks

Postby Jepael » 2017-12-09 @ 21:23

superfury wrote:UniPCemu's VGA standard clocks are now:
Code: Select all
#define VGA28MHZ 28321000.0



Why? Didn't we just went through a long discussion that the original and most widely used value is 28.322?
IBM VGA array was originally integrated on the motherboard of PS/2 models, so they were the first implementations, not VGA cards.
https://en.wikipedia.org/wiki/Video_Graphics_Array#/media/File:IBM_VGA_90X8941_on_PS55.jpg

superfury wrote:The EGA(clock #1(0-based)/MDA clocks are their rounded values(16.257MHz). The EGA(clock #0)/CGA 14MHz clocks uses the cycle-accurate 14MHz BUS clock(which also times most hardware based on that clock directly).


The 16.257 is not rounded, it's exactly 16.257.
https://upload.wikimedia.org/wikipedia/commons/4/47/IBM_PC_Original_Monochrome_Display_and_Parallel_Printer_Adapter.jpg
https://upload.wikimedia.org/wikipedia/commons/6/6b/IBM_EGA_card.jpg

Now, Hercules is another story. I think there are Hercules cards that have either 16.257 or 16.000 MHz clocks. I think Scali wrote a post on this some time ago.
Jepael
Oldbie
 
Posts: 1195
Joined: 2005-6-15 @ 19:28
Location: Finland

Re: x86 software vs hardware clocks

Postby superfury » 2017-12-10 @ 14:26

Just adjusted the VGA to use 28.322 and 25.175Mhz. The rest is unchanged(ET3/4K still Dosbox-X clocks).

Anyone figured out the exact 8/16 clocks of those? Are the Dosbox-X clocks already accurate? Or do they need adjusting to be using the clocks in the photo's?

I see 6 onboard clocks, but 16 documented? Anyone?

(S)VGA is odd: 640x480@60Hz is actually 59.94Hz?
superfury
l33t
 
Posts: 2618
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: x86 software vs hardware clocks

Postby Jepael » 2017-12-10 @ 20:20

superfury wrote:Anyone figured out the exact 8/16 clocks of those? Are the Dosbox-X clocks already accurate? Or do they need adjusting to be using the clocks in the photo's?


Clocks for 8MHz and 16MHz formats in ET3000 and ET4000?
That depends wildly, but let's assume ideal case first.
According to pictures and datasheets, there would be a nominal 32.514 MHz oscillator that internally can be divided by two to get 16.257 MHz for EGA formats.
There is also mentions of using 28.322MHz divided by two to get CGA formats - most likely 14.161 MHz is close enough for CGA, and the line width may be fine tuned if necessary.

superfury wrote:I see 6 onboard clocks, but 16 documented? Anyone?


In most ET3000 pictures, there really are separate oscillators for each frequency, so that's easy, just look at the pictures. However, the BIOS must know which oscillators are present and which frequencies they have to select correct oscillator for each mode, so which frequencies to emulate depends only on which video BIOS you are targeting.

In most ET4000 pictures, there are many different PLL chips used, so the actual frequency is whatever the PLL can do, so if you want to know the exact frequencies of a specific card you have in mind, you must look at what PLL chip it has and then read the PLL chip datasheet, and possibly also how the video BIOS sets up the PLL chip parameters. Although, many PLL chips had preprogrammed frequencies and ET4000 chip has three (four?) clock select wires, so it's possible that only the presets in the PLL are ever used.
As I explained in one of my previous posts, on a PLL-clocked ET4000 card, the clocks will not be exactly 25.175 and 28.322 for example, and can be far off.

So, There is no single answer to what frequencies are used and what are their exact values. Therefore, any approximation should be OK, or then just stick to emulating a single known card/bios combination.

superfury wrote:(S)VGA is odd: 640x480@60Hz is actually 59.94Hz?

It really is and should not be a surprise as it is a standardized format. 25175000/(800*525) is indeed very close to 59.94Hz, but not exact.
Most of the other video resolutions of interest can be found in standards as well.
Jepael
Oldbie
 
Posts: 1195
Joined: 2005-6-15 @ 19:28
Location: Finland

Re: x86 software vs hardware clocks

Postby superfury » 2017-12-12 @ 18:35

Those clocks are already modified.

I've improved IPS clocking to loop pending BIU cycles when in that mode(exception is when it's not spending cycles due to hardware waitstates(resulting in an infinite loop otherwise, hanging the app)). This causes the emulator, when in IPS cycle mode, to run at much higher speeds, with a 50% speed increase(that's quite a lot).
So, instead of the BIU ticking 15 actual cycles and then notify the hardware whether to tick or not(CPU.executed instead of CPU.cycles in cycle units), causing all empty 0 cycle hardware to be reduced to 0 cycle ticks for each instruction phase only(instead of every phase 2 or more times, which isn't required during IPS cycle exe execution(since the CPU cycle output is zeroed by multiplication anyways during all but the final instruction cycle(since it uses the finished flag instead of the 1 cycle constant execution anyways, which is 0 most if each instruction(3 zeroes followed by one 1 for a 4-cycle NOP, so all phases(read(s),writeback(s) times plus the final execution phase giving the terminating 1 now being reduced to 1 check each read/writeback phase instead of e.g. x2 checks on a 286 or x4 on a 8088, since all phases and delays are reduced to one hardware update instead only(like Doxbox after each instruction(any read/write/delay phase in UniPCemu being reduced to 1 hardware check now)).
The i7 is now running the 8086 at 75% speed in IPS mode(50% in cycle-accurate mode). On Android it's 25% and 15% instead.

So it looks like the BIU is very heavy on the real CPU, even though Visual Studio profiling reports memory accesses themselves instead?
Last edited by superfury on 2017-12-12 @ 20:01, edited 1 time in total.
superfury
l33t
 
Posts: 2618
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: x86 software vs hardware clocks

Postby Scali » 2017-12-12 @ 19:57

Jepael wrote:IBM VGA array was originally integrated on the motherboard of PS/2 models, so they were the first implementations, not VGA cards.


IBM also made a VGA ISA card, or as they call it, the "PS/2 feature adapter":
Image
Also 28.322 MHz crystal as you can see.

Jepael wrote:Now, Hercules is another story. I think there are Hercules cards that have either 16.257 or 16.000 MHz clocks. I think Scali wrote a post on this some time ago.


Yes, I have a real Hercules GB102 card, which has a 16.000 MHz crystal.
I believe all real Hercules cards do.
Various Hercules clones however use 16.257 MHz.
Scali
l33t
 
Posts: 3554
Joined: 2014-12-13 @ 14:24

Previous

Return to PC Emulation

Who is online

Users browsing this forum: No registered users and 2 guests