Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 10-31-2017, 01:22 AM   #1
TCR_500
Biblical Creationist
Default Best Function for CPU Emulation Loop

I'm working on a CPU design and I'm wondering what the best vessel API function would be to run the CPU simulation on. The emulator will need to simulate thousands to tens of thousands of CPU cycles per second while simultaneously being able to call Orbiter API functions to interact with the Orbiter-default ship systems. What's the best API function to use for this?
TCR_500 is offline   Reply With Quote
Old 10-31-2017, 06:46 AM   #2
Artlav
Aperiodic traveller
 
Artlav's Avatar

Default

In Linux MFD ( https://www.orbiter-forum.com/showthread.php?t=23939 ) i had the CPU running in opcPreStep, independent of vessels. The MFD itself was just a terminal.
If you want vessel-specific MFDs, then something like pre or post step call.
You wold also need to calibrate the amount of cycles you run per call, so as to have it reasonably fast without lagging the system.

Also, time accel is a PITA for such things.
Artlav is offline   Reply With Quote
Thanked by:
Old 10-31-2017, 06:58 AM   #3
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

I would consider shoving the emulation into a worker thread... but doing this is not easy as I can tell from refactoring the SSU GPC emulation right now. A lot of thinking about events that happen in parallel. Without caring for the historic ballast of the Space Shuttle DPS, you could maybe do it easier though.

Also, nobody prevents you from using a JIT compiler like LLVM for optimising the emulation by compiling the emulated CPU instructions into x86 code before execution.
Urwumpe is offline   Reply With Quote
Thanked by:
Old 10-31-2017, 01:20 PM   #4
TCR_500
Biblical Creationist
Default

Quote:
Originally Posted by Artlav View Post
Pretty impressive to port an entire operating system into Orbiter.
Quote:
Originally Posted by Artlav View Post
 i had the CPU running in opcPreStep, independent of vessels. The MFD itself was just a terminal.
If you want vessel-specific MFDs, then something like pre or post step call.
You wold also need to calibrate the amount of cycles you run per call, so as to have it reasonably fast without lagging the system.
Speed is definitely a concern for me. Orbiter doesn't seem to be able to maintain a realtime simulation at a fixed time step. The last time I wrote an emulator was for a game where everything is scripted in LUA. 1 kHz (if I remember correctly) used up ~0.5% of the available scripting time. 1 loop iteration = 1 CPU clock cycle. Longest instruction = 4 CPU clock cycles.
Quote:
Originally Posted by Artlav View Post
 Also, time accel is a PITA for such things.
I have no clue how I'm going to accommodate time acceleration. Simply going by the time step will cause Orbiter's framerate to drop. Dividing it by the time acceleration factor would make the CPU unrealistically slow! Too bad I can't dedicate an entire real CPU core to my emulation.

Quote:
Originally Posted by Urwumpe View Post
 I would consider shoving the emulation into a worker thread... but doing this is not easy as I can tell from refactoring the SSU GPC emulation right now. A lot of thinking about events that happen in parallel. Without caring for the historic ballast of the Space Shuttle DPS, you could maybe do it easier though.
That's probably what I'm going to do. Then it's just a matter of starting and stopping the thread. The only problem that I can think of here is stuff like what happens when the CPU calls an API function? And there's also the issue of the only thing I know about for having multiple threads use the same data set is the "volatile" keyword.
Quote:
Originally Posted by Urwumpe View Post
 Also, nobody prevents you from using a JIT compiler like LLVM for optimising the emulation by compiling the emulated CPU instructions into x86 code before execution.
I have no experience with JIT compilers.
TCR_500 is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 10:27 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.