You can clearly contract any definable relationship. I'd be inclined to be careful on just one point.
As you've described it, the core property belongs to Company A. Company B created the software and (I presume) passed all rights in that software to Company B. So Company B has acquired knowhow, but some of what you describe, though natural enough, has potential for future disputes.
So I think (and I'm not a lawyer, and this is not legal advice!) company B contracts a license from company A for use of the IP encapsulated in the software, specifications etc, in the context of creating a SAAS service that builds on this original IP.
This can certainly be expressed as a percentage of revenues, or in practically any other way.
If I were in Company A's shoes, I'd want to get some fixed sum into the contract somewhere to represent a valuation of my original IP, even if this were realised under the percentage regime or triggered by some other event (e.g. if Company B had a change of ownership, or wished to engage other parties in some way). Or I might use that to set some targets for income from the SAAS, and have a right of termination if (say) those targets weren't achieved.
And if I were in Company B's shoes, I'd want some provision to 'buy out' Company A - a lump sum option to end the revenue split.
These two observations are complementary, but not totally 'same side of the table.' Negotiating that now is better than leaving it for the uncertain future.
Then there's the question of who owns what as the service is developed.
If the product and the SAAS are going to be related, then I think you need clarity on this point. And there are many ways you could capture this.
Company A could own all new property. That sounds a bit unnatural, but it's simple and manageable (there's no mixture, company B gets to manage its risk and is assured of its ongoing ability to generate income)
Company B could own all new property, end of story. This sounds simple, but it could be hard to unwind in future.
Company B could own new property in SAAS, and Company B could have the right to access and utilise these new properties back into the software product (for instance by having the right to review source and documentation, and to extract specifications). That could ultimately be unwound if the directions diverged, leaving A with the software product, B with the SAAS and a cross-license on everything encapsulated in each.
Company B might be obliged to review development of the SAAS and, on request, to build (applicable) features back into company A's software product
So I know you've already ruled other options out, but I have to say that my preference would be to do this a different way.
a) Company A could act as the lead in all cases, with Company B as the development partner (benefiting from revenue share or/and fees for the work), or
b) Create Company C with Company A and B as its owners, either as a vehicle to hold the IP, or as the vehicle for taking Company A's product into the SAAS domain, or
c) Company B buys the IP from Company A, who would retain a right to sell and further develop the original software product.
I always want think about the 'big success' and 'big flop' cases, and I am concerned that the arrangement you want isn't ideal for either of those scenarios.