sim: Push the global frequency management code into C++.