1.65k likes | 1.83k Views
Structuring instruction-sets with higher-order functions. Byron Cook Advisor: John Launchbury. Microprocessor correctness. ISA: Simple machine. Lots of microarchitectural tricks. Microprocessor correctness. Speculative. Out-of-order. Superscalar. Pipelined. Microprocessor correctness.
E N D
Structuring instruction-sets with higher-order functions Byron Cook Advisor: John Launchbury
Microprocessor correctness ISA: Simple machine Lots of microarchitectural tricks
Microprocessor correctness Speculative. Out-of-order. Superscalar. Pipelined.
FV for microprocessor correctness • Approach to improving microprocessor quality: • Model the systems in logic • Prove that the microarchitecture implements the ISA. • Rich mixtures of automatic and manual proof strategies are common.
FV for microprocessor correctness • Research community has found many techniques to solve this problem. • Several papers prove correctness of “superscalar, out-of-order, and speculative” implementations of RISC ISAs.
The twist: ISAs are evolving • Domain-specific extensions. • example: MMX • Predication. • example: ARM • Concurrency instructions: • Example: IA-64 • Speculative instructions: • Example: IA-64
The twist: ISAs are evolving Extra structure to leverage
The twist: ISAs are evolving Should be carefully presented
The twist: ISAs are evolving • Opportunity for new axis of proof decomposition: • MMX: Can we first prove that the MMX execution unit correctly implements MMX • Predication: Can we prove just the MA predication machinery correct? • Concurrency instructions: Can we abstract over the underlying pipelines? • Speculative instructions: …………
Question that the dissertation answers Can higher-order functions help? • Facilitate architectural extension design? • Microarchitectural modeling of extensions? • Facilitate the correctness proof?
Overview • Background • Extensions and higher-order functions • Conclusion
Overview • Background • Extensions and higher-order functions • Conclusion
Overview • Background • Models and specifications • Correctness • Formal verification techniques • Extensions and higher-order functions • Conclusion
Models and specifications • In the literature: transition systems are used. • A transition system is a structure with: • A set of initial states. • A next state relation. • An “observation” function.
Models and specifications Let’s see an example………
Models and specifications t = (init,next,obs) init represents the initial states: init :: {s} next represents the next state relation: next :: i -> s -> {s} obs is the observation function: obs :: s -> o
Models and specifications type TS i s o = ( {s} , i->s->{s} , s->o ) t :: TS i s o t = (init,next,obs)
Models and specifications • {s} can sometimes mean a finite set of elements of s. • Sometimes infinite sets are used. • Sometimes, sets are not used at all.
Models and specifications type TS c i s o = ( c s , i->s->c s , s->o )
Models and specifications • Finite sets • t :: TS FSet i s o. • t :: ( FSet s , i->s->FSet s , s->o ) • Infinite sets: • t :: TS Set i s o. • t :: ( Set s , i->s->Set s , s->o ) • No sets: • t :: TS Id i s o. • t :: ( s , i->s->s , s->o )
Models and specifications data OPCODE = ADD Reg Reg Reg | SUB Reg Reg Reg . . Example: ADD r1 r2 r5 :: OPCODE
Example: An ISA specification risc :: TS FSet OPCODE RegFile (Obs RegFile) risc = (risc_init,risc_next,risc_obs) where risc_init = unit i_rf risc_next instr state = ……… risc_obs s = ………
Models and specifications data Obs x = Ready x | Busy | Stalled
Example: A pipelined model pipe :: TS FSet OPCODE (RegFile,PipeReg,PipeReg,PipeReg) (Obs RegFile) pipe = (pipe_init,pipe_next,pipe_obs) where pipe_init = unit (i_rf,empty,empty,empty) pipe_next instr (rf,r1,r2,r3) = ……… pipe_obs (rf,r1,r2,r3) = ………
Overview • Background • Models and specifications • Correctness • Formal verification techniques • Extensions and higher-order functions • Conclusion
What is correctness? n ? m
What is correctness? • Often a preorder relationship: • Bisimulation (BISIM). • Simulation (SIM). • Flush-point correctness (FP).
What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that
What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that init m
What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that init m init n
What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that init m R init n
What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that next m i init m R R init n
What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that next m i init m R R init n next n i
next m i R R next n i What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that init m R init n
next m i R R next n i What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that init m R R init n
next m i R R next n i What is simulation? “m” is the implementation, “n” is the specification. There exists an R such that obs m init m R R init n obs n
What is simulation? • (m,n)SIM iff R. • ainit m, binit n. (a,b)R • (a,b)R, i, a’next m i a. b’next n i b and (a’,b’)R • (a,b)R. obs m a = obs n b
What is bisimulation? “m” is the implementation, “n” is the specification. There exists an R such that, the same as before AND:
What is bisimulation? “m” is the implementation, “n” is the specification. There exists an R such that, the same as before AND: init n
What is bisimulation? “m” is the implementation, “n” is the specification. There exists an R such that, the same as before AND: init m init n
What is bisimulation? “m” is the implementation, “n” is the specification. There exists an R such that, the same as before AND: init m R init n
What is bisimulation? “m” is the implementation, “n” is the specification. There exists an R such that, the same as before AND: init m R R init n next n i
What is bisimulation? “m” is the implementation, “n” is the specification. There exists an R such that, the same as before AND: next m i init m R R init n next n i