Formal Modeling and Verification of Microprocessors
Formal Modeling and Verification of Microprocessors
JANUARY 1995
Abstruct- Formal verification has long been promised as a Formal models of VLSI designs are usually called specijica-
means of reducing the amount of testing required to ensure cor- tions; specifications provide a concise description of the behav-
rect VLSI devices. Verification requires at least two mathematical ior of the device that can be used by design engineers, layout
models: one that describes the structure of a computer system
and another that models its intended behavior. These models technicians, production engineers, test engineers, technical
are called specijkations. Verification is a mathematical analysis writers, and users. The application of symbolic mathematical
showing that the behavior follows from the structure. Formal analysis to these models is usually called verification.
verification of microprocessor designs has been quite successful. Verification is largely an exercise in demonstrating that
Indeed, several verified microprocessors have been presented in a design has certain properties. The primary property that
the literature, and one microprocessor where formal modeling
has been applied is commercially available. These efforts were concems us is functional correctness; that is, showing
virtuoso performances-largely academic exercises carried out that a design has an intended behavior. This paper is
by experts in logic and specification. largely concemed with verifying functional correctness,
This paper presents a methodology for microprocessor verifica- but other work by the author has been aimed at using
tion that significantly reduces the learning curve for performing specifications to demonstrate, for example, the integrity
verification. The methodology is formalized in the HOL theorem-
proving system. The paper includes a description of a large case of supervisory mode in a RISC-like microprocessor [20]
study performed to evaluate the methodology. and the correctness of rules used in instruction stream
The novel aspects of this research include the use of abstract reordering [22].
theories to formalize hardware models. Because our model is Correctness verification uses at least two descriptions of
described using abstract theories, it provides a framework for a system: one that describes how the circuit is constructed,
both the specification and the verification. This framework re-
duces the number of ad hoc modeling decisions that must be called the structural specification, and one that describes
made to complete the verification. Another unique aspect of what the circuit is supposed to do, called the behavioral
our research is the use of hierarchical abstractions to reduce specijication. Correctness is shown by demonstrating through
the number of difficult lemmas in completing the verification. mathematical proof that the former implies the latter. Design
Our formalism frees the user from directly reasoning about the faults are discovered as part of demonstrating correctness and
difficult aspects of modeling the hierarchy, namely the temporal
and data abstractions. are corrected as the verification proceeds. Thus, verification
We believe that our formalism, coupled with case studies and can be viewed as part of the design process itself, not as an ex
tools, allows microprocessor verification to be done by engineers post facto process that gives a seal of approval. Typically, some
with relatively little experience in microprocessor specification sort of mechanical proof tool is used in conjunction with the
or logic. We are currently testing that hypothesis by using the verification to reduce the tedium associated with manipulating
methodology to teach graduate students formal microprocessor
modeling. large specifications.
Treating microprocessor design formally can be a difficult
task. Avra Cohn, in 161, describes her specification of VIPER’s
I. INTRODUCTION EBM from informal descriptions supplied by VIPER’s design-
ers as follows:
C OMPUTERS are being used with increasing frequency
in areas in which the correct implementation of the
computer hardware is critical. Testing has traditionally been
VIPER’s top-level specification and its major-state level
were both supplied in a logical language; but its block-
used to exclude faults in computers; however, the effectiveness level model was given partly formally and partly pictori-
of testing is limited by the combinatorial explosion inherent in ally (as was natural). Combining these two parts required
any testing technique. The limitations of testing, coupled with both ingenuity and some guesswork. The guesses were
the ever-increasing size of VLSI devices, have led to a search based on the coincidence of line names, on the names
for alternatives to testing, such as mathematical modeling and of bound variables in the functional detinitions, and
analysis. on the annotations in the text of the definitions. None
of these notational devices can be regarded as formal
Manuscript received July 29, 1991; revised December 2, 1992; July 28, specific ation.
1993. This work was supported by NASA under Space Engineering Research
Center Grant NAGW-I406 and under Boeing Contract NASI-18586, Task This statement not only describes the difficulties of developing
Assignment No. 3. with NASA-Langley Research Center. formal specifications from the kinds of informal descriptions
The author is with the Laboratory for Applied Logic, Department of commonly in use, but it also alludes to the inadequacies of
Computer Science. Brigham Young University, Provo, UT 84602-6576 USA;
E-mail: [email protected]. those descriptions. After the specification is complete, verify-
IEEE Log Number 9407556. ing that the implementation meets the behavioral specification
0018-9340/95$04.00 0 1995 IEEE
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 55
is equally arduous, sometimes requiring the proof of hundreds build on the five axioms that form the basis of higher
of multipage theorems. order logic to derive a large number of theorems that
Every microprocessor verification done to date has been a follow from them.
virtuoso performance, carried out by experts in logic, spec- Rules of inference for higher order logic. These rules
ification, and mechanical reasoning. In contrast to this, we contain not only the eight basic rules of inference from
are striving to make microprocessor verification a viable tool higher order logic, but also a large body of derived
for VLSI design engineers. To that end, this paper presents a inference rules that allow proofs to be done using larger
methodology for verifying microprocessors. This methodology steps. The HOL system has rules that implement the
is embodied in a formalism for the HOL theorem prover, standard introduction and elimination rules for Predicate
providing tool support for a step-by-step approach to system Calculus as well as specialized rules for rewriting terms.
verification. In addition, we have produced several case studies A large collection of tactics to support goal-directed
and are working on additional examples of verified systems proof. Included in HOL are tactics that rewrite a goal
for use in instructing engineers in microprocessor verification. according to some previously proven theorem or defini-
The latter part of this paper presents a case study of the tion, remove unnecessary universally quantified variables
specification and verification of a microprocessor using our from the front of a goal, and split equalities into two
methodology. implicative subgoals.
Organizcition of the Paper: This paper consists of two A proof management system that records the state of an
parts. In the first part, Section I1 presenrs a brief introduction interactive proof session.
to the HOL theorem proving system, Section 111 contains a A metalanguage, ML, for programming and extending
mathematical model of interpreters, and Section IV contains the theorem prover. Using the metalanguage, tactics can
a formalization of that model in the HOL theorem-proving be combined to form more powerful tactics, new tactics
system. can be written, and theorems can be aggregated to form
The second part of the paper demonstrates the use of new theories for later use. The metalanguage makes the
the model in a case study involving the specification and verification system extremely flexible.
verification of a microprocessor called AVM-1. Section 5 For the most part, the notation of HOL is that of standard
presents an introduction to AVM-1, Section VI contains the logic: V.3,A,V, etc. have their usual meanings. A few con-
hierarchical specification of AVM-I in HOL, Section VI1 structs deserve special attention because that are used in this
presents the verification of AVM-I , and Section VI11 presents paper.
our observations about the case study. HOL types are identified by a prefixed colon. Built-
in types include :boo1 and :num.Function types are
11. A BRIEFINTRODUCTION TO HOL constructed using -+. HOL is polymorphic; type variables
are indicated by a type names beginning with an asterisk.
To ensure the accuracy of our specifications and proofs, The HOL conditional statement, written a h I c,
we used a mechanical verification system to develop them. means “if a, then b, else c”.
The mechanical system performs syntax and type checking The HOL list containing elements a , b , c , and d is
of the specifications and prevents the proofs from containing represented as [ a ;b ;c ;d]. A list that contains elements
logical mistakes. The HOL system was selected for this project with type x has the type : (x) list, where x can be
because it has higher order logic, generic specifications, and any valid type (including type variables since HOL is
polymorphic type constructs. These features directly affect the polymorphic).
expressibility of the specification language. Furthermore, HOL EL is a curried function that accepts two arguments, a
is widely available, robust, and has a growing international number, n, and a list, and returns the rith member of the
user base. However, nothing in our work requires that the list.
HOL theorem-proving system be used. Tuples are formed using a comma. Parentheses are only
HOL is a general theorem-proving system developed at the required when the scope of the comma is ambiguous.
University of Cambridge [3, 81 that is based on Church’s The function FST returns the first member of a tuple and
theory of simple types, or higher order logic [4]. Although S N D returns the second.
Church developed higher order logic as a foundation for The construct let v l = e x p r l and v2 = expr2
mathematics, it can be used for reasoning about computational and . . . i n simultaneously defines local variables v l ,
systems of all kinds. Similar to predicate logic in allowing v2, etc. with values expr L , e x p r 2 , etc.
quantification over variables, higher order logic also allows
quantification over predicates and functions, thus permitting
more general systems to be described. 111. FORMAL
MICROPROCESSOR
MODELING
HOL is not a fully automated theorem prover, but, it is more Numerous efforts have been made to formally model mi-
than simply a proof checker; it serves a\ a proof assistant. HOL croprocessors. The best known of these include J. Joyce’s
has several features that contribute to its use as a verification Tamarack microprocessor 1121, W. Hunt’s FM8501 micro-
environment. processor [lo], and A. Cohn’s VIPER microprocessor [51.
Several built-in theories, including booleans, individuals, Tamarack is a simple microprocessor with only 8 instructions.
numbers, products, sums, lists, and trees. These theories FM850I is larger (roughly the size of a PDP-I 1) but has
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
56 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. I , JANUARY 1995
not been implemented (a 32-bit version has been verified and TABLE I
implemented by Hunt et al. 1111). Perhaps the most interesting BASICTYPESFOR INTERPRETER DEFINITION
of these is VIPER, since even though VIPER is signifi-
cantly simpler than today’s general-purpose microprocessors, {true, false}
its verification provides a benchmark of the state-of-the-art in
microprocessor verification.
VIPER was designed by Britain’s Royal Signals and Radar M N-+B stores
Establishment (RSRE) at Malvem to provide a formally ver-
ified microprocessor for use in safety critical applications; it
is commercially available. VIPER is the first microprocessor
ii i
intended for commercial use where formal verification was
used. However, the verification has not been completed be-
cause of the large number of instruction cases and the size of
the proofs in each of the cases. This is not to say that the proof 0 0 0 0 0 0 0 0 0
could not be completed, but that it could be carried out only
t; tj t; 1; 1; t:- t; t; tio
at great expense. Recent work on hierarchical specification
[ 181, coupled with the work presented here, has overcome F F F T F T T F T
the problems that faced the VIPER verification team, and Fig. 1. The function, 7 ,which maps time at one level to another, can be
microprocessors significantly more complicated than VIPER defined in terms of a predicate, G, which is true only when the mapping occurs.
are now within the realm of formal treatment. The case study
in Sections V-VI1 is one example.
n-tuples representing state. These n-tuples have the type
The specifications for the microprocessors mentioned above
appear very different on the surface; in fact, the specification (a1 x a2 x .. . x an-l x a,)
for FM8501 is even in a different language than the specifica-
tions of Tamarack and VIPER. On closer inspection, however, where
we find that each of them (as well as many others) use the
same implicit behavioral model. In general, the model uses a
state transition system to describe the microprocessor. We call
this model an interpreter. Whether or not S is interpreted, we write S 5 S’ to indicate
The essence of verification is to relate mathematical models that S is an abstraction of S‘. When S is an abstraction of S’
at different levels of abstraction. The rest of this section there exists a function, S:S’ + S. The function S is called
gives a mathematical definition of the interpreter model and the state abstraction function.
shows how two interpreters are related. In the discussion that
follows, and for the rest of the paper, we speak of the “abstract C. Time
level” and the “concrete level,” but these terms are relative; In general, different levels in the interpreter hierarchy have
as we move up and down a hierarchy of interpreters, what different views of time. A temporal abstraction function maps
we call “abstract” at one level will be termed “concrete” with time at the abstract level to time at the concrete level [ 9 ] ,
respect to the level above it. As a matter of convention, we
[12], 1151. Fig. 1 shows a temporal abstraction function, 3.
will decorate variables that represent the concrete level with The circles represent clock ticks. Notice that the number of
primes. clock ticks required at the concrete level to produce one clock
tick at the abstract level is irregular.
A. Basic Zypes The temporal projection, 3, can be defined recursively
on time. We define F in terms of a predicate, E, which is
The basic types for our model are shown in Table I. In true whenever there is a valid abstraction from the concrete
addition to these basic types, we also use the following type level to the abstract level. In a microprocessor specification,
constructors: product, written ( a x 0); coproduct, (or G is usually a predicate that indicates when the lower level
+
sum) written ( a p); and function, written ( ( 2 -+ 0). An interpreter is at the beginning of its cycle-a condition that
n-tuple is indicated by (a1 x a2 x . . . x a,-1 x a,). is easy to test.
The function 3 is defined recursively so that F(G.0) is
B. State
the first time that 4 is true and F(G,(n 1)) is the next +
time after time n when S is true. The resulting function is
At times it is convenient to treat state as an object of type monotonically increasing. We use N to represent time. Thus,
S, where S is uninterpreted. This allows us to treat state in we define F:(N + B) x N -+ N such that
an abstract manner, even though we may know nothing of its
structure or content. \inm . ( 7 ~ > m ) =+ (.F(S.n ) > F(G>m ) )
Eventually, we will provide interpretations for S to model
a specific machine. To provide such an interpretation, we We refer the interested reader to the references given above
represent state using n,-tuples. We let be the domain of and to 1171 for the details of the temporal abstraction function.
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 51
E. Environments and
The environment represents the external world; it plays kt = K ( s t , e t )
an important part in our theory. The environment is where
interrupt requests originate, reset signals are generated, and In this equation, st(et) is the state (environment) in the
so on. In our model, the environment is used only for input; state (environment) stream s(e) at time t. The predicate, I,
output to the environment is assumed to be simply a function constrains the state of the interpreter at time t 1 to be +
of the state and environment. a function, N , of the state and environment at time t. The
At the abstract level, we treat the environment as an function is determined by applying the choice function, Cz, to
uninterpreted type. We know nothing about its structure or the key retumed by K for the state and environement at time t.
content. We denote it as E. Just as we defined S , the state
abstraction function, we define an environment abstraction G. Interpreter VeriJication
function, E , such that €:E’ -+ E. When we provide an Our goal is to prove a correctness relation between the
interpretation for E , we represent the environment using n- interpreters at different levels of a microprocessor abstraction.
tuples of booleans and bit-vectors. In particular, for two interpreters, 1, and It,we wish to show
We perform the same kinds of abstraction on the environ- that
ment as on states. Temporal abstraction is performed as it was
for states. We define abstraction for environment streams in e m ] * &[se, eel
L[-?,,
the same manner as we defined it for state streams. Thus we
write e 5 e‘ when e is an stream abstraction of e’ and define where s,(e,) is the state (environment) stream at level m
stream abstraction for environment streams as follows: and se ( e t ) is the state (environment) stream at level e. By
definition, we require that s t 5 s, and et 5 e,.
e 5 e’ E 3(E:E’ + E) . 3 ( F : N -+ N) . E o e’ o F =e When this implication is true, 1,is an abstraction of 2,
and I,,,is said to implement It.
The correctness theorem above follows from the following
F. The Interpreter Specijcation lemma: P‘
The preceding parts of this section have given preliminary
Vj ~~..~,(sm,e,,)~(j=Cz(lct))
definitions for concepts that are important in the mathematical
definition of interpreters. This section presents that definition. 3 3~ 0 Sm)(t+c) = j ( ( s0 Sm)tr (E 0 em)t)
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
58 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. 1 . JANUARY 1995
IV. A MODEL01;INTERPRETERS
IN HOL theory obligations-a set of predicates that define relationships
The similarities in past microprocessor verifications can be among members of the abstract representation. The abstract
exploited to form 8 methodology for microprocessor verifi- theory models any structure with objects and operations that
cation in general. To make this information usable, we have satisfy the predicates.
formalized the microprocessor specification model in the HOL The theory obligations axiomatize the theory. Using the
mechanical theorem-proving system. The formalization does obligations as axioms, we prove theorems of interest about the
several things. abstract objects and operations. The goal is to use the abstract
1) The formalization provides a step-by-step approach to theory to reason about specific objects by instantiating the
microprocessor specification by enumerating the impor- abstract theory with a concrete representation that has been
tant definitions that need to be made for any micropro- shown to meet the obligations. The instantiation specializes
cessor specification. the abstract theorems, producing a set of theorems about
2) Using the formalization, the verification tool can derive the concrete representation. The concrete representation is an
the lemmas that need to be verified from the specifica- instance of the abstract theory and represents a member of the
tion. class of abstract objects that the abstract theory describes.
3) After these lemmas have been established, the verifi- HOL, the verification environment used in the research
cation tool can use the formalization to automatically reported here, does not explicitly support abstract theories;
derive the final result from the lemmas. however, HOL’s metalanguage, ML, combined with higher
order logic, provides a framework sufficient for implementing
To formalize the model developed in the last section, we use
abstract theories [211. Several specification and verification
abstract theories. The next section discusses abstract theories
systems, such as EHDM [ 161, offer explicit support for abstract
and how they can be used to formalize mathematical models.
theories.
The remaining sections discuss the parts of the generic model.
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 59
The following abstract types are used in the representation. environment at the concrete level to produce a key for
: *state represents the state and corresponds to S from the concrete level.
the last section. begin denotes the beginning of the implementation
: *eriv represents the environment and corresponds to E clock cycle.
from the last section. The functions count and begin are used to implement the
: *key is type containing all of the keys and corresponds predicate G that indicates when time at the concrete and
to K from the last section. abstract levels correspond.
In addition to these abstract types, the representation makes We must emphasize once again that even though we have
use of several concrete types: :time, :num,and :bool.The spent several paragraphs defining what each of the members
1i s t and 4 (function) type constructors are used as well. We of the abstract representation mean, they are truly abstract
add primes to the types to indicate that they represent state, and have no meaning in the formal model other than the
time, etc., at the concrete rather than the abstract level of the relationships that are defined in the theory obligations.
hierarchy.
The abstract representation is divided into three parts. The
C . The Theory Obligations
first contains those operations concerned with the interpreter
proper. Theory obligations represent the semantics of the generic
instructions represents the instruction set, which model. Inside the model, the only thing we know about the
is represented by a list. Each member of the list is an abstract representation presented in the last section is what the
instruction that associates a key with * a state transition theory obligations say about it.
function. Throughout the rest of the paper, we make To prove the correctness result, we must know something
use of two selector functions, KEY and IFUNC,which about the implementation. Since the implementation is a
respectively select the key and state transition function member of the abstract representation, nothing is known about
from an instruction. instructions corresponds to 3 it except the requirements given in the theory obligations.
from the last section. Proving that the implementation implies the interpreter def-
select represents the function that selects a key based inition is typically done by case analysis on the instructions;
on the present state and environment. select corre- we show that when the conditions for an instruction’s selection
sponds to K from the last section. are right, the instruction is implied by the implementation. We
key maps an object of type : *key to a number. This call this the instruction correctness lemma.
number is used to index the list containing the instruc- The predicate INSTRUCTION-CORRECT expresses the
tions. key is used in conjunction with the EL function conditions that we require in the instruction correctness lemma.
(which selects the nth member of a list) to implement C INSTRUCTION-CORRECTis a good example of the kind of
from the last section. information that is captured in the generic model. Previous
microprocessor verifications created this lemma, or one similar
The second part contains the abstraction functions that relate
to it, in a largely adhoc manner. INSTRUCTION-CORRECT
the state and environment at the concrete level to the state and
expresses the correctness condition for a single instruction,
environment at the abstract level.
namely that under certain conditions it follows from the
substate is the state abstraction function for the inter- definition of the more concrete implementation.
preter. The domain of substat e is primed indicating The complete definition of INSTRUCTION-CORRECT is
that it is from the concrete level. substate corresponds given below:
to S from the last section. kdef INSTRUCTION-CORRECT s’ e ’ inst =
subenv is the environment abstraction function similar let s = ( A t . (substate ( s ’ t))) in
to substate. subenv corresponds to I from the last let e = ( A t . (subenv (e’ t))) in
section. let g = ( A t . (count (s’ t) (e’ t)
Because we want to prove correctness results about the in- = begin)) in (
terpreter, we must have an implementation to verify the (Imp1 s‘ e ’ ) 3
interpreter against. The third part of the abstract representation ( V t: time‘.
contains three functions that provide the necessary abstract (select(s t) (e t)= (KEY
definitions lor the implementation. (count(s’ t) (e’ t)= beg
Imp1 is the abstract implementation. We could have 3 c. Next g (t,t+c) A
chosen to make this function more concrete and define it ((IFUNC inst) (s t) (e t
as we do the interpreter, but doing so would require that = (s (t + c))))).
every implementation be an interpreter or at least have In the definition, s ‘ ( e ) represents the state (environment)
some pre-chosen structure. As we see in the example, the stream at the more concrete level; s (e) is the state
implementation need not be modeled as an interpreter at stream (environment) at the abstract level and is derived from
all. Thus we say nothing about it except to define its type; s ‘ ( e ’) using the function substate (subenv). The
its structure and operation are completely unknown. predicate g is the predicate D of Fig. 1 . Recall that 0 was
count is analogous to select except it operates at true whenever the states in the concrete and abstract levels
the concrete level. Notice that it uses the state and corresponded. In our model this happens whenever the counter
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
60 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. I , JANUARY 1995
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 61
imrnediate ’1
In supervisory mode
opcode dest ’ unused
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
62 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. I . JANUARY 1995
Calculation
cond c n t l
u
Fig. 4. A phase diagram for AVM- 1.
I Jr-,
Architectural Level
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 63
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
64 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. 1. JANUARY 1995
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 65
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
66 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. I , JANUARY 1995
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 61
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
68 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. 1, JANUARY 1995
mbr t,mpc t, alatch t , The Thmry Obligations: Just as at the architectural level,
blatch t ,ires-ff t , the theory obligations to be proven are automatically derived
iack-ff t,mir t, from the abstract theory obligations by HOL.
micro-rom,clk t)) The Instruction Correctness Lemma: To establish the first
( A t . (int-e t)) A theory obligation for the generic interpreter model, we first
(3 t. . clk t = F,F) 3 prove that the phase-level instruction correctness predicate
Micro-Int applies to each of the phases and then use these results to
( ( A t . (reg t,psw t,pc t,mem t,ivec t , establish that the predicate applies to every instruction.
ir t,mar t,mbr t,mpc t ) ) o The following theorem holds that the instruction correctness
(TempAbs(A t . clk t = F,F))) predicate applied to the first instruction, phds e-one,is a
( ( A t . (int-e t)) o tautology.
(TempAbs(A t . clk t = F,F))). PHASE-0VE -EBM-LEMMA =
The lambda expression k Phase-In t-1n st -Cor rect
( A t . (reg t,psw t,pc t,mem t,ivec t,ir t, ( A t . reg t - , p s w t,pc t,mem t,ivec t,ir
mar t,mbr t,mpc t)) t, mar t,mbr t,mpc t ,
in the above theorem models a state vector that is a function alatch t,blatch t , ireq-ff t ,
of time, or in other words, a state stream. This expression iack-ff t,mir t,urom,clk t))
represents a data abstraction of the phase-level state stream ( A t . (ireq-e t))
and is not a micro-level state stream until it is composed with ((F,F),phase-one).
the temporal abstraction function
(TempAbs(X t . clk t = F,F)) We also have to prove a similar lemma about each of the
that maps micro-level time onto phase-level time. other instructions in the phase-level specification. The proofs
The correctness result also contains the following assump- in each case are long but fairly straightforward. They are not,
tion: however, uniform and each must be dealt with individually.
(3 t . (:lk t = F , F ). After we have shown that the instruction correctness pred-
This assumption must be met for the correctness result to icate is true for each of the instructions, we can show that
be valid. That is, unless we can guarantee that at some time it is true for every instruction. This satisfies the first theory
the clock will be at the beginning of its cycle, we cannot say obligation
that the computer will function correctly. Of course, we can Phase-Int-Correct-LEMMA =
guarantee this using a reset button. EVERY
( Phase-Int-Inst-Correct
C. Verifvirig the Phase-Level ( A t . (reg t,psw t,pc t,mem t ,
The verification of the phase-level differs from the veri- ivec t,ir t,mar t,mbr t, mpc t,
fication of the architectural level and the micro-level in a alatch t,blatch t - , ireq-ff t ,
significant way: the implementation is a structural represen- iack-ff t , nir t,urom,(-lkt) )
tation of the electronic block model rather than a behavioral ( A t . (ireq-e t)))
representation. This makes some steps in the verification less [ (F,F),phase-one;(F,T),phase-two;(T,F),
uniform, but the overall process is essentially the same. phase-three;(T,T),phase-four1.
The Instruction Correctness Predicate: Each of the phase-
level instructions must satisfy the instruction correctness pred- The Length Lemma: The second theory obligation is easy
icate if we are to meet the theory obligations. We use the same to show. The theorem holds that the numeric value of a boolean
procedure that produced the phase-level interpreter specifica- 2-tuple is always less than the length of a four-element list.
tion to instantiate the generic correctness predicate. Phase-Int-LENGTH-LEMMA =
Phase-Int-Inst-Correct = t- V clk bt2-val clk <
FPhase-Int-Inst-Correct s f e‘ p = (LENGTH [ (F,F),phase-one;(F,T),phase-two;
EBM :s’ e ’ + (T,F),phase-three;(T,T), phase-four]).
(V t . The Order Lemma: The third theory obligation holds that
(GezPhaseClock (s‘ t)(e’ t ) = KEY p) A the numeric value of the first part of the pair denoting an
(GetEBMClock (s’ t ) (e‘ t) = EBM-Start) instruction is the index of that instruction in the instruction
(3 (I‘ ’ list (i.e., the list is correctly ordered). This lemma is also quite
Next(A t ’ . GetEBMClock (s’ t ‘ ) easy to show by case analysis.
(e’ t’) = EBM-Start)( t , t + c) A Phase-Int-ORDER-LEMMA =
(IFUNC p (s’ t) (e’ t) = s‘(t + c))) I- V clk . clk =
KEY (EL (bt2-val clk)
Because the instruction correctness predicate is derived from [(F,F),phase-one;(F,T),phase-two;
the specification rather than being developed in an ad hoc (T,F),phase-three;(T,T’) ,phase-four]) .
manner, it has the same form as the instruction correctness Instantiating the Correctness Theorem: Having proven the
predicate for the architectural level. theory obligations, we can now instantiate the generic inter-
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 69
preter model. The result of the instantiation can be simplified VIII. OBSERVATIONS
through minor rewriting and beta reduction. Having completed the formal specification and verification
PHASE-LEVEL-CORRECT-LEMMA = of AVM- 1, we make several observations.
FEBM ( A t .
We have shown how a variety of architectural and
(reg t,psw t,pc t,mem t,ivec t,ir t ,
mar t,mbr t,mpc t,alatch t, organizational features can be modeled using the generic
blatch t,ireq-ff t , iack-ff t , mir t , interpreter model. One should not assume that we claim
urom,clk t)) that every architectural feature will map onto the model
(A t . (ireq-e t)) + presented in Section IV. Indeed, many may not.
Phase-Int What does this say, then, for the utility of abstract
(A t . theories? Certainly, many interesting features, such as
(reg t,psw t,pc t,mem t,ivec t,ir t , interrupts, can be mapped onto the model given in this
mar t,mbr t,mpc t,alatch t , paper. Furthermore, formalizing new models is not a
blatch t , ireq-ff t , iack-ff t ,mir t , difficult process. We expect that our models will change
urom,clk t)) and new models will be developed to suit new features.
( A t . (ireq-e t)). The major utility of abstract theories-structuring the
proof-is not diminished.
The result states that the electronic block model implies We are currently exploring the application of the
the phase-level for the concrete state and environment in our generic interpreter theory to the verification of pipelined
model. architectures with feedback. In [23]. we show why
the model presented in this paper will not work for
pipelined microprocessors, describe what it means for a
D. AVM-I is Correct
microprocessor with an instruction pipeline to be correct,
We have successfully instantiated the generic interpreter and provide an example verification of a microprocessor
theory for each of the levels in our hierarchical decomposition. with a 5-stage instruction pipeline.
We establish Each of the interpreter levels uses a different concept
of key. The phase-level, for example, uses the value of
a polyphase clock as the instruction key. The micro-
level, on the other hand, uses location in memory, in
in stages by showing
our representation, as the key to select an instruction.
The architectural level uses an opcode as the key. Thus
a program that is thousands of instructions long at the
We will use the correctness results from each of the levels and micro-level implies that there are thousands of instruc-
Modus Ponens to prove the correctness result for the entire tions in the model. A program that is thousands of lines
CPU. long at the architectural level would still only use the
AVM-CORRECT = 30 instructions given here. For longer microprograms, a
I- let micro-abs = TempAbs different representation of keys would have to be chosen.
( A t . clk t = F,F) in Another interesting point concerning keys is their use
let abs = micro-abs o at the architectural level to distinguish between user
(TempAbs( A t . (mpc o instructions and pseudoinstructions. When specifying an
micro-abs)t = F,F,F,F,F,F))in interpreter, it is important to be flexible about the concept
EBM ( A t . (reg t,psw t,pc t,mem t, of an instruction. We would not have been able to model
ivec t,ir t,mar t,mbr t,mpc t, the external interrupts using the generic interpreter model
alatch t,blatch t , ireq-ff t , if we had not been willing to think of it as just another
iack-ff t,mir t,micro-rom,clk t)) instruction that is selected using an environment signal
(A t (ireq-e t) ) A instead of the program counter.
(3 t clk t = F,F) A The use of coproducts to specify the user instructions
(3 t (mpc o micro-abs)t = and pseudoinstruction keys also points out the utility
F,F,F,F,F,F) * of having a specification language that is powerful and
Arc h-Int ((A t . (reg t,psw t,pc t, expressive. Because HOL had coproducts, we were easily
mem t , ivec t )) o abs) able to specify the distinction between these two types of
( ( A t . (ireq-e t ) ) o abs)). instructions while continuing to use the opcode to select
user instructions.
This result is the same result that we would have proven In order to deal with detailed timing issues, gate-delays
had we not used hierarchical decomposition and the generic would have to be built into the models. There is nothing
interpreter model. However, the process by which we arrived to keep us from building specifications that model gate-
at this result was methodical-the generic interpreter theory delay; however, the models would be more complex and
guided the specification and verification at every level. the verification more difficult.
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
70 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. I . JANUARY 1995
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
WINDLEY: FORMAL MODELING AND VERIFICATION OF MICROPROCESSORS 71
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.
12 IEEE TRANSACTIONS ON COMPUTERS, VOL. 44, NO. I . JANUARY 1995
[I51 T. Melham, “Abstraction mechanisms for hardware verification,” in [23] P. J. Windley and M. Coe, “The formal verification of instruction
VLSI Specification, Verification and Synthesis, G . Birtwhistle and P. pipelines,” in Proceedings of the 1994 Conference on Theorem Provers
A. Subrahmanyam, Eds. New York: Kluwer Academic Publishers, in Circuir Design, Lecrure Notes in Compurer Science, R. Kumar and T.
1988. Kropf, Eds. New York: Springer-Verlag, Sept. 1994.
(161 SRI Int. Comput. Sci. Lab., EHDM Specification and Verijcafion Sys-
tem: User’s Guide, Version 4.1, 1988.
[17] P. J. Windley, “The Formal verification of generic interpreters,” Ph.D.
thesis, Univ. of California. Davis, Div. of Comput. Sci., June 1990. Phillip J. Windley received the Ph.D. degree in
[18] -, “A hierarchical methodology for the verification of micropro- computer science from the University of California,
grammed microprocessors,” in Proc. IEEE Symp. Security and Privacy, Davis, in 1990.
May 1990, pp. 345-359. He was a member of the faculty at the University
[19] -, “The verification of AVM-1, Tech. Rep. CSE-90-21, Univ. of of Idaho and a member of the technical staff at the
California, Davis, Div. of Comput. Sci., 1990. Department of Energy’s Division of Naval Reactors.
I201 -, “Using correctness results to verify behavioral properties of He is an Assistant Professor with the Department
microprocessors,” in Pmc. IEEE Comput. Assurance Con$, June 1991, of Computer Science at Brighdm Young University,
pp. 99-106. Provo, UT, where he directs the Laboratory for
[21] -, “Abstract theories in HOL.” in Proceedings of rhe 1992 Inter- Applied Logic. His research interests center on
national Worbhop on the HOL Theorem Prover and its Applications, L. the use of formal methods in computer science;
Claesen and M. J. C. Gordon, Eds. New York: North-Holland, Nov. particularly the specification and verification of hardware. He has taught
1992. numerous courses on the use of higher order logic and the HOL theorem
[22] -, “Instruction set commutivity,” in Proc. Fourfh Annu. prover in computer system verification. Dr. Windley is a member of the
IEEEITVIASA Symp. VLSI Design, Oct. 1992, pp. 6.5.1-6.5.11. Association for Computing Machinery.
Authorized licensed use limited to: Univ of Calif Santa Cruz. Downloaded on October 15,2024 at 21:07:37 UTC from IEEE Xplore. Restrictions apply.