A Theory and Algorithmic Frame for Switch Level Simulation