An Approach to the Specification and Verification of a Hardware Compilation Scheme Jonathan P. Bowen ([email protected]) South Bank University, Centre for Applied Formal Methods, School of Computing, Information Systems and Mathematics, Borough Road, London SE1 0AA, UK

He Jifeng ([email protected]) The United Nations University, International Institute for Software Technology, PO Box 3058, Macau Abstract. The use of Field Programmable Gate Arrays (FPGA) to rapidly produce custom hardware circuits using a completely software-based process is becoming increasingly widespread. Specialized Hardware Description Languages (HDL) are used to describe and develop the required circuits. In this paper, we advocate using an even more general purpose programming language, based on Occam, for the automatic compilation of high-level programs to low-level circuits. The parallel constructs of Occam can map directly to hardware as conveniently as to software, with potentially dramatic speed-up of highly parallel algorithms. We demonstrate that the compilation process can be verified using algebraic refinement laws, increasing the confidence in its correctness. Verification is particularly important in high-integrity systems where safety or security is paramount. A prototype compiler has also been produced very directly from the theorems using the logic programming language Prolog. Keywords: digital systems, formal specification, hardware compilation, parallel programming, programmable hardware, refinement, verification Abbreviations: HDL – Hardware Description Language FPGA – Field Programmable Gate Array VLSI – Very Large-Scale Integration

1. Background Developments in VLSI technology have made it possible to speed up task-specific software systems by implementing at least some of its modest-size core procedures in hardware circuits. While such practices are increasingly enticing and promising, it remains to be a daunting task to show that a target VLSI device, with size reaching one million transistors, does comply with a given source algorithm. This paper aims to bridge this gap by presenting a selection of transformation rules that converts a program which fulfills the logical specification of a circuit into a digital VLSI device [19]. Field Programmable Gate Arrays (FPGA) which can be dynamically reconfigured by software may be used for implementation. This enables the building of hardware c 2000 Kluwer Academic Publishers. Printed in the Netherlands.

hc-tjs.tex; 13/09/2000; 20:35; p.1

2

J.P. Bowen & He Jifeng

implementations for moderate-sized programs entirely by a software process. A significant feature of such hardware implementation is that a global clock is present to synchronize the activity of sub-components, i.e., update on latches can only take place at the end of each clock cycle. A high-level parallel programming language (such as Occam [26], for example) can be regarded in this context as a behavioural specification language for hardware devices, capable of being compiled directly into circuits [27]. An Occam-like program, together with its observation semantics, provides the abstract definition of what a hardware circuit should achieve, by means of the proper connection of its components such as latches and gates. Such an approach when automated has been dubbed ‘hardware compilation’ [6, 30]. A major advantage of Occam in this context is the inclusion of high-level parallel constructs that can map naturally to parallel hardware. Occam’s well-studied algebraic laws [26] also aid considerably in the verification of such a mapping. A Hardware Description Language (HDL, e.g., Verilog and VHDL [7, 9]), provides a way to express formally and symbolically the constituent components of a hardware circuit and their interconnections. A hardware description of a VLSI device can be checked against the silicon layout supplied by the designer, and it can also be used as an input to simulators. Hardware description languages are widely used in many computer-aided systems, allowing libraries of standard checked hardware modules to be assembled. The combination of all these techniques removes many errors from a silicon product, once the hardware description of a device has been constructed. In this paper a simple description language for globally clocked circuits will be given an observation-oriented semantics based on the states of the wires of a device. Algebraic laws [26] based on this semantics permit every circuit description to be expressed in a hardware normal form. This form is designed to guarantee absence of such errors as combinational cycles and conflicts. The necessary link with the higher abstraction level of the programming language is provided by an interpreter written in the programming language itself. A hardware normal form is a correct representation of a source program if its interpretation yields as good a result or a ‘better’ result than that described by the source program itself with respect to some refinement ordering. In this context, ‘better’ means more deterministic or applicable in more situations, for example. This is proved directly for each of the primitive components of the source language; and then a series of theorems show how the hardware form of a composite program can be constructed from the hardware which implements its components. Each theorem has the form of a

hc-tjs.tex; 13/09/2000; 20:35; p.2

Specification and Verification of a Hardware Compilation Scheme

3

transformation rule, which can be used directly or indirectly in the design of an automatic compiler. In this way we hope to demonstrate that by its very method of construction the compiler is correct. The hardware normal form is fairly close to the typical notation of a hardware ‘netlist’ language. This second level of translation is not the subject of this paper. This work builds upon results published in [6, 17, 25]. In particular, there is a strong relationship between our method and that used in software compilation [13]. However, our method handles parallel composition and preserves true concurrency in the implementations. Additionally, a simple FPGA description language is introduced to mimic the behaviour of a synchronous circuit, which can also be defined in the same semantical model used for the source language. Page has developed a compiler in the functional language SML which converts an Occam-like language, somewhat more expressive than the one presented here, to a netlist [25]. After further processing by vendor software the netlist can be loaded into Xilinx FPGA chips [31]. However, the algebraic approach in this paper offers the significant advantages of providing a provably correct compiling method, and it is also expected to support a wide range of design optimization strategies. Alternative approaches to digital hardware verification are available. For example, Milne’s Circal (CIRcuit CALculus) process algebra and system allows the specification and automatic verification of concurrent systems, including hardware circuits [10, 23]. Circal, like the delayinsensitive approaches above, can handle asynchronous hardware [28]. Our approach is aimed at synchronous (clocked) circuits since existing FPGAs (including Xilinx) use clocked circuitry. Asynchronous hardware has the advantage of less power consumption in general because circuits need only be activated when computation is required, whereas clocked circuits consume power at every clock cycle. Most digital electronic circuitry only consumes significant power when switching occurs; in the stable state (‘on’ or ‘off’) virtually no power is required. Clocked circuits can suffer from ‘clock skew’ problems which slow the potential clock speed, especially in larger circuits across several chips. However, asynchronous circuits require considerable extra circuitry for hand-shaking (typically about double the area of an equivalent synchronous circuit) and can be more difficult to test. Thus many engineers prefer synchronous circuits, and in practice many existing digital chips depend on a clock. Our approach is targeted at synchronous (specifically FPGA) circuits. In the future asynchronous FPGA may become available as the practical interest in asynchronous circuits increases.

hc-tjs.tex; 13/09/2000; 20:35; p.3

4

J.P. Bowen & He Jifeng

In general, verification efforts seek to check the correctness of a system in a post hoc manner and on an individual basis. Our approach seeks to be more generic; we wish to produce correct hardware by construction by proving that the method of construction is correct once for all the features required in the language. Most verification approaches must check the implementation against the specification each time a new specification and matching implementation are produced. In our approach, any set of connected hardware components produced via the verified compilation scheme is correct with respect to the original high-level (Occam-like) program description from which it has been compiled. Esterel [2] is a language for programming reactive systems and a compiler which translates programs into finite-state automata. The compiler can be used to generate a hardware or software implementation in the form of a netlist of gates or C code with extensive optimization. As such, the approach is similar to ours, although we have concentrated on proving the correctness of the compilation scheme for each language construct. There is also a growing interest in the problem of combined hardware/software co-design [12, 29]; see for example the POLIS system based around Finite State Machines, developed and used at UC Berkeley and elsewhere [1]. We have considered software and hardware compilation separately, but each in a similar manner with regard to the proof strategy. In the future it may be possible to combine the two compilation strategies. A major difficulty is choosing an efficient balance and interface between the software and hardware parts of an implementation. Normally this is a question of engineering judgement and automation is difficult; however automated support for an engineer may be a more feasible and useful route in practice. The rest of this paper is organized as follows. Section 2 briefly introduces the high-level programming language used. In Section 3 we investigate the observations of synchronous circuit together with a set of algebraic laws used to calculate and transform hardware devices. The concept of hardware normal form is introduced there, and an interpreter is built to simulate the behaviour of such circuits. Section 4 illustrates how to convert sequential programs into hardware. Section 5 presents a set of compilation scheme theorems for communicating processes. Finally, some conclusions are drawn.

hc-tjs.tex; 13/09/2000; 20:35; p.4

Specification and Verification of a Hardware Compilation Scheme

5

2. Programming Language This paper uses an Occam-like language, which has the benefit of an elegant set of associated algebraic laws [26]. A selection of constructs in the language will be presented. Further constructs can be found in [5]. Facilities of assignment, sequential composition, conditional, iteration, input and output communication, alternation, and timing operators have been specified. In order to model the behaviour of a clocked circuit we include generalized assignment (v :∈ (v 0 = e)) in the reasoning language, which allows the convenient manipulation of non-determinism. Let R(v , v 0 ) be a predicate relating the final value v 0 of the program variable v to its initial value v . For simplicity we assume that R is feasible, i.e. ∀ v ∃ v 0 • R. The notation v :∈ R represents a generalized assignment which assigns v a value such that the post-condition R holds at its termination. As an example, the following algebraic laws explore the relation between the ordinary assignment statements with the generalized ones: Law v := e = v :∈ (v 0 = e) Law (x := e; y := f ) = x , y :∈ ((x 0 = e) & (y 0 = f [x 0 /x ])).

3. Synchronous Circuits A digital circuit has one or more input and output wires connected to its environment. Its behaviour is usually described by a predicate on the values of these wires. There are only two stable values for a wire: either 0 standing for connection to the ground, or 1 standing for the presence of electrical potential. A synchronous circuit is equipped with a global clock which runs slow enough such that all the inputs of the circuit can become stable before being latched at the end of each clock cycle. In the rest of this paper, the unspecified duration of each cycle is taken as the unit of time. 3.1. Digital Elements Let W be a Boolean expression, and w be a wire name not used in the expression W . The notation w .Comb(W ) describes a combinational circuit where the value of the output wire w is defined by the value of W . This relationship cannot be guaranteed at all times, but only at regular intervals, at the end of each clock cycle. Let wt and Wt

hc-tjs.tex; 13/09/2000; 20:35; p.5

6

J.P. Bowen & He Jifeng

B E

x ........

Figure 1. A latch: x .Latch(B , E )

represent the values at time t of w and W respectively. The behaviour of the combinational circuit w .Comb(W ) is described by a predicate def

w .Comb(W ) = ∀ t • (wt = Wt ), where the range of t is here and later restricted to the natural numbers. This means that observations can be made at discrete intervals. Another hardware component is the Delay element l .Delay(L), where on each clock cycle, the voltage of its output wire l is the same as the value of the Boolean expression on the previous clock cycle, and initially the value of l is 0: def

l .Delay(L) = (l0 = 0 ∧ ∀ t • (lt+1 = Lt )) A latch x .Latch(B , E ) (see Figure 1) is a variation of the Delay element. Here, the value of the output wire x is changed on those clock cycles when the Boolean condition B is true; and then the value of E is taken as the new value of x . Otherwise the value of x remains unchanged. def

x .Latch(B , E ) = ∀ t • (xt+1 = (Et  Bt  xt )) 3.2. Input and Output Let D be a Boolean expression and d a wire name not mentioned in D. We use the notation d .Out(D) to stand for the combinational circuit d .Comb(D) where the output wire d is used to connect the circuit with its environment. We use the notation c.In to represent an input wire c whose value is solely decided by the environment. As a result, the wire c cannot be used as output of any hardware components of the circuit. Since the values of input wires are arbitrary; the behaviour of c.In is described by the non-deterministic assignment def

c.In = ∀ t • (ct = 0 ∨ ct = 1)

hc-tjs.tex; 13/09/2000; 20:35; p.6

7

Specification and Verification of a Hardware Compilation Scheme

x0

x1 ........

x2 ........

···

xn−1

xn ........

Figure 2. A shift register: x1 .Delay(x0 ) & x2 .Delay(x1 ) & · · · & xn .Delay(xn−1 )

Obviously we have c.In = true. In the following we will use InWire(C ) and OutWire(C ) to represent the sets of input wires and output wires of the circuit C respectively. 3.3. Composite Design To assemble hardware components to form a network, both parallel composition of components and hiding of internal wires are desirable. A pair of synchronous circuit devices (C 1, C 2) with distinct output wires can be assembled by connecting output wires of each of the devices C 1 and C 2 to like-named input wires of the other device, making sure that any cycle of connection is cut by a latch. Since the value observed on the input end of a wire is the same as that produced on the output end, the combinational behaviour of an assembly of hardware can then be described by the conjunction of the description predicates of its individual components, C 1 & C 2. Example 1 (Shift register) A shift register can be described as a composition of a sequence of delay elements each of which has the output of its predecessor as its input (see Figure 2), where delivery of the value of the input wire x0 to the output wire xn takes n clock cycles. Clearly the ordering in which we assemble a set of hardware components is irrelevant. Law 1.

C 1 & C 2 = C 2 & C 1.

Law 2.

(C 1 & C 2) & C 3 = C 1 & (C 2 & C 3).

To explain hiding, let w be a wire used in a circuit C connecting its components. If the environment has no concern with the value of such a wire, we can apply the hiding operator to conceal its value completely: ∃w : C The hiding operator obeys the following law: Law 3. ∃ w : (C 1 & C 2) = (∃ w : C 1) & C 2 if the wire w is not used in C 2.

hc-tjs.tex; 13/09/2000; 20:35; p.7

8

J.P. Bowen & He Jifeng

The following laws can be employed to simplify the description of circuitry associated with latches by removing extraneous combinational gates: Law 4.

x .Latch(B , E ) = x .Latch(B , B ∧E ) = x .Latch(B , B ⇒ E ).

Law 5. If [B 1 ∧ B 2 = 0], then x .Latch(B 1, E 1) = x .Latch((B 1 ∨ B 2), (B 1 ∧ E 1 ∨ B 2 ∧ x )). 3.4. Hardware Normal Form Let w be a list of wire names and W a list of Boolean expressions of the same length as w . We will use the notation w .Comb(W ) to represent the network of combinational circuits w1 .Comb(W1 ) & . . . & w#w .Comb(W#W ) where #w is the length of the list w . Later we will adopt the same convention for the network of Delay elements and latches. Let B and E be lists of Boolean expressions with the same length as the list x of latch names. For notational simplicity, we use the notation E B x to stand for the list of conditionals {(E1  B1  x1 ), . . . , (E#x  B#x  x#x )} Let c be a list of input wire names, and d a list of output wire names. Let x be a list of latch names, l a list of Delay names, and w a list of combinational gate names. The circuit 

def

C (s, f ) = ∃ l1 , . . . l#l , w1 , . . . w#w

l .Delay(L)  & w .Comb(W )    & x .Latch(B , E ) :   & c.In   & d .Out(D) & f .Delay(F )

        

is a network where − s is an input wire from which an impulse given by the environment triggers the circuit.

hc-tjs.tex; 13/09/2000; 20:35; p.8

Specification and Verification of a Hardware Compilation Scheme

9

− f is an output wire to which an output generated by the circuit signals the end of its operation.

Definition (Normal Form) The circuit C (s, f ) is a hardware normal form if it satisfies the following conditions (NF-1) : The output wire f is not used as an input of any hardware components of the network. (NF-2) : All the latches xi .Latch(Bi , Ei ) have Ei = (Bi & Ei ). (NF-3) : None of the Boolean expressions L, W , D, B and F is true in the case when all wires l , w and s have the value 0. The first condition states that the wire f acts only as a link between the circuit C with its environment. From the law 6 we know that the condition NF-2 is not a serious restriction. The condition NF-3 characterizes a specific kind of synchronous circuits where only the rising edges of the control signals are used to stimulate their activities. 3.5. Multiplexer When circuits resulting from software translation are put together, we need some method of allowing them to share their latches, input wires and output wires. Let Ci (i = 1, 2) be a network def

Ci = ∃ v i : ( w i .Comb(Wi ) & l i .Delay(Li ) & x i .Latch(B i , E i ) & c i .In & d i .Out(D i ) ) where v i ⊆ (w i ∪ l i ). Assume that C1 and C2 do not share wire names except latches, input and output devices, and also avoid combinational cycles. The notation Merge(C1 , C2 ) represents a network produced by using multiplexers to merge the like-named latches and output devices in C1 and C2 , namely − If x .Latch(B1 , E1 ) and x .Latch(B2 , E2 ) are used in C1 and C2 separately, then the combined network Merge(C1 , C2 ) will contain the latch x .Latch(B1 ∨ B2 , E1 ∨ E2 ); − If C1 and C2 contain the output devices d .Out(D1 ) and d .Out(D2 ), then the network Merge(C1 , C2 ) includes d .Out(D1 ∨ D2 ) as an output device.

hc-tjs.tex; 13/09/2000; 20:35; p.9

10

J.P. Bowen & He Jifeng

In general, the circuit Merge(C1 , C2 ) is defined by 



w 1 .Comb(W 1 )  & w .Comb(W )    2 2   def   & l 1 .Delay(L1 ) Merge(C1 , C2 ) = ∃ v 1 , v 2 :    & l 2 .Delay(L2 )     & x .Latch(B , E )  & c.In& d .Out(D) where {x .Latch(B1 , E1 ) | x ∈ x 1 \ x 2 } def x .Latch(B , E ) = & {x .Latch((B1 ∨B2 ), (E1 ∨E2 )) | x ∈ x 1 ∩ x 2 } & {x .Latch(B2 , E2 ) | x ∈ x 2 \ x 1 } and c represents the union of c 1 and c 2 , and {d .Out(D1 ) | d ∈ d 1 \ d 2 } def d .Out(D) = & {d .Out(D1 ∨ D2 ) | d ∈ d 1 ∩ d 2 } & {d .Out(D2 ) | d ∈ d 2 \ d 1 } From the above definition, it is easy to prove the following laws: Law 6.

Merge(C1 , C2 ) = Merge(C2 , C1 )

Law 7. Merge(C1 , Merge(C2 , C3 )) = Merge(Merge(C1 , C2 ), C3 ). These two laws allow us to treat Merge as a unary operator with a set of networks as its argument. 3.6. Interpreter The normal form C (s, f ) described in the previous section starts its operation after being triggered by an input signal from the wire s. Initially, all its Delay elements are reset to 0 (fortunately a feature of latches in many FPGAs, including those from Xilinx), and the combinational components enter their stable states immediately afterward. The initialization phase of C (s, f ) can thus be described by a generalized assignment Init (standing for initialization): def

Init = s, l , w , c, d , f :∈ (s 0 = 1) & (l 0 = 0) & (w 0 = W 0 ) & (d 0 = D 0 ) & (f 0 = 0) We do not make any assumptions about the values of x 0 latches holding variable state information at initialization above, although many FPGAs would ensure that these are reset to 0 as well as the Delay elements. Since the input wires c are included in the left hand side of

hc-tjs.tex; 13/09/2000; 20:35; p.10

Specification and Verification of a Hardware Compilation Scheme

11

the above assignment, the execution of this statement ensures that the unpredictable input values of c have been taken into account in setting up the initial state of the wires in C (s, f ). The activity of the normal form C (s, f ) over one clock cycle is simply described by a delay statement together with a generalized assignment: def

Step = busy 1 ; (s, l , w , x , c, d , f :∈ (s 0 = 0) & (l 0 = L) & (w 0 = W 0 ) & (x 0 = E  B  x ) & (d 0 = D 0 ) & (f 0 = F )) where − The delay statement busy 1 behaves like skip except that its execution takes one clock cycle. − The generalized assignment describes the change on the output wires of C (s, f ) and the input wire c at the end of the cycle. It resets the input wire s to 0 to model the behaviour of the environment which guarantees never sending another impulse to the wire s when C (s, f ) is in operation. The operation phase of the network C can then be modelled by the iteration while ¬f do Step. The circuit C signals the completion of its operation by sending an output impulse to the wire f . In order to cease the activity of C , as specified in condition NF-3 of the normal form, it is required that all the values of the wires w and l all become 0 at the time when the voltage of f is rising. Such a requirement can be represented by an assertion Final (standing for finalization): def

Final = (¬w & ¬l )⊥ When both l and w are empty lists of wires we end with Final = (true)⊥ = skip. In summary the behaviour of the normal form C (s, f ) can be described by the following interpreter: def

hs, C , f i = var s, f , l , w ; Init while ¬f do Step ; Final ; end s, f , l , w C (s, f ) is a correct implementation of a program P if

hc-tjs.tex; 13/09/2000; 20:35; p.11

12

J.P. Bowen & He Jifeng

P v hs, C , f i In what follows we will only deal with hardware normal forms. The remainder of the paper demonstrates how to transform an Occam-like program into a hardware normal form.

4. Sequential Programs This section investigates a subset of programming language where no communication is involved. We deal with communicating processes in the next section. It is clear that the process ⊥ can be implemented by any circuit since its behaviour is totally unpredictable. Theorem 1

(Chaotic Process)

⊥ v hs, C , f i Let b be a Boolean expression. The assignment (∆ 1; x := b) assigns the value of b to x , and terminates after at most one time unit. The target circuit of x := b is shown in Theorem 2. Since the expression b evaluates within one clock cycle, the control circuitry should cause the data register x to load the value of b at the end of the clock period in which the start signal on the wire s is present. Here we assume that the alphabet of the assignment does not contain any channel name. The assignment with channels will be examined in the next section. Theorem 2

(Assignment) 

(∆1; x := b) v hs,

x .Latch(s, s ∧ b) & f .Delay(s)



, fi

Proof. We demonstrate the algebraic style of proof used for verifying theorems in Figure 3. The simplest compositional construct is sequential composition, the implementation of which is shown in Theorem 3. The start pulse on the input wire s triggers the first component. On its termination, the first component will trigger its successor by sending a pulse to the wire h. The composite system terminates when the finish signal along the wire f is generated. In addition, the multiplexers are installed to merge those latches used to represent program variables.

hc-tjs.tex; 13/09/2000; 20:35; p.12

Specification and Verification of a Hardware Compilation Scheme

13

RHS = {definition ofhs, C , f i} var s, f ; s, f :∈ (s 0 = 1) & (f 0 = 0); while ¬ f do (busy 1; (s, x , f :∈ (s 0 = 0) & (x 0 = b) & (f 0 = s))) ; end s, f = {(v :∈ v 0 = e) = (v := e)} var s, f ; s, f := 1, 0; while ¬ f do (busy 1; (s, x , f := 0, b, s)) ; end s, f = {unfolding loop: while b do p = (p ; (while b do p))  b  skip} var s, f ; s, f := 1, 0; ((busy 1); (s, x , f := 0, b, s); while ¬ f do (busy 1; (s, x , f := 0, b, s))) 6 f  skip ; end s, f = {distributing an assignment over conditional: (x := e); (p  b  q) = (x := e; p)  b[e/x ]  (x := e; q) and eliminating conditional: (p  false  q) = q } var s, f ; s, f := 1, 0; ((busy 1); (s, x , f := 0, b, s); end s, f = {reducing the scope of local variables and merging assignments} var s, f ; s, f := 0, 1; end s, f ; (busy 1); x := b w {(busy 1 w ∆ 1), and (var v ; v := e; end v ) = skip} LHS Figure 3. Proof of Theorem 2 (Assignment)

Theorem 3

(Sequence)

If ({s} ∪ l 1 ∪ w 1) ∩ ({f } ∪ l 2 ∪ w 2) = ∅, then hs, C1 , hi ; hh, C2 , f i v hs, ∃ h : Merge(C1 , C2 ), f i Theorem 4 for conditional statements and Theorem 5 for iteration may be found in [5]. In the target circuit of a conditional, the incoming start pulse is steered to one of two controlled components, depending on the value of a Boolean expression. Like the sequential statement, the data latches used by two components of the conditional are merged. In the implementation of the loop construct, the control pulse (either recirculated on an intermediate finish wire, or the initial one on the start wire of the construct) is directed back to the controlled statement via an intermediate start wire or to the final finish wire of the construct, again depending on the current value of a Boolean expression.

hc-tjs.tex; 13/09/2000; 20:35; p.13

14

J.P. Bowen & He Jifeng

5. Parallel Communicating Processes This section shows how to implement the synchronized communication of programs by a clocked circuit. Here the input and output wires (such as c.In and d .Out) in a hardware normal form are used to convey messages across hardware components within a network. Let ch be a channel name and x a program variable name. The input process ch?x becomes ready to receive a message from the channel ch by raising the flag ch.inready immediately after it starts. It observes the readiness of the partner residing at the other end of the channel ch via the variable ch.outready, and signals the synchronization on ch by rising the flag ch.synch. Once the communication takes place, the variable x will be assigned the data received from the channel ch. For simplicity we assume that the alphabet of ch?x consists of Chan = {ch?, c?, dh!} and Var = {x , y, . . . z } where ch and c are input channel names and dh is an output channel name, and x , y and z are variable names. The target circuit of c?x is shown in Theorem 6, where the start signal sets a latch l to remember that the communication is pending. Once the output partner raises the flag ch.outready signaling its willingness for interaction, the ch.synch signal is issued to indicate that both ends of the channel ch are ready to communicate at that time. After a one clock delay, the circuit stores the value received from the channel ch in the latch x . Theorem 6

(Input)

ch?x v hs, Input(s, ch, x , f ), f i where Input(s, ch, x , f ) represents the network 



l .Delay((s ∨ l ) ∧ ¬ch.outready.In)  & f .Delay((s ∨ l ) ∧ ch.outready.In)     & ch.inready.Out(s ∨ l )      ∃ l :  & ch.synch.Out((s ∨ l ) ∧ ch.outready.In)     & x .Latch((s ∨ l ) ∧ ch.outready.In,     (s ∨ l ) ∧ ch.outready.In ∧ ch.In)  & Idle({c?, dh!}) and def

Idle(Chan) =

&c?∈Chan c.inready.Out(0) & c.synch.Out(0) &d!∈Chan d .outready.Out(0)

Theorem 7 for output is similar to Theorem 6 and can be found in [5].

hc-tjs.tex; 13/09/2000; 20:35; p.14

Specification and Verification of a Hardware Compilation Scheme

15

The deadlock process stop runs forever with all channels remaining silent. The implementation of stop receives a start pulse from the wire s, and never generates a finish pulse on the output wire f . Theorem 8

(Deadlock process)

Let Chan be the set of channels used by stop. Then 

stop v hs,

f .Delay(0) & Idle(Chan)



, fi

The alternation construct makes a choice on its input guards, and executes one of those guarded statements whose guard becomes ready. Theorem 9 shows an implementation of the alternation construct with two input guards, where the start pulse sets the latch l to indicate that both inputs are pending. The guarded statement is activated once the output partner of its input guard signals its willingness for communication. When both input guards become available simultaneously, the target circuit chooses its first alternative . Theorem 9

(Alternation)

Assume that for i = 1, 2: def

Hi (hi , fi ) = ∃ v i : fi .Delay(Fi ) & Ci If H1 and H2 do not share output wires except latches and delay devices, then: alt[b?x → hh1 , H1 , f1 i,c?y → hh2 , H2 , f2 i] delay t latency1 v ALT(s, b, c, s1 , s2 )    Input(s1 , b, x , h1 ),             Input(s2 , c, y, h2 ),     hs, ∃ s1 , s2 , l , h1 , h2 :  & Merge C1 , C2 , , fi           c.inready.Out(s ∨ l ),        d .inready.Out(s ∨ l ) & f .Delay(F1 ∨ F2 ) where l .Delay((s ∨ l ) ∧ ¬b.outready.In   ∧ ¬c.outready.In)  def   ALT(s, b, c, s1 , s2 ) =  & s1 .Comb((s ∨ l ) ∧ b.outready.In)    & s2 .Comb((s ∨ l ) ∧ c.outready.In  ∧ ¬s1 ) 



Further theorems for time-in and time-out constructs, extensions of the alternation construct with times, and a parallel construct have also been formulated [5].

hc-tjs.tex; 13/09/2000; 20:35; p.15

16

J.P. Bowen & He Jifeng

6. Conclusion Much further optimization of the resulting circuits could be undertaken compared to the simple compilation scheme presented here. Some of the compilation schemes here could be improved with alternative schemas (each involving a further theorem to be proved). In addition, subsequent optimization using basic Boolean laws has been found to reduce the size of the circuit substantially (typically by up to a half in practice) using a more robust but unverified compiler called Handel-C [11]. This has been used successfully on applications such as video games, selfvalidating sensors, cryptography, string matching, speech processing, video decompression and video motion tracking. A prototype compiler based very directly on the compiling theorems has been developed using the logic programming language Prolog, allowing an extra check on the validity of the theorems [5]. The coding for each clause is of a very similar size and form to the original specification. However, support clauses are also required for constraints, although these can be coded compactly. The subset of Prolog used is relatively pure (e.g., there are no cuts and negation is used very sparingly and only when it is ‘safe’ to do so to maintain the soundness properties). Thus the declarative semantics of Prolog may be assumed to hold and it could be possible to perform a formal proof of the correctness of the Prolog compiler itself. The output from an optimizing compiler will be considerably more difficult to deal with than the simple example presented here. Much further optimization of the resulting circuits could be undertaken. Some of the compilation schemes presented here could be improved. In addition, subsequent optimization using Boolean laws could reduce the size of the circuit substantially (typically by up to a third in practice). This is an area where formal methods [8, 18] might usefully be used to verify more complicated optimization transformations, in which many compilation errors occur in practice. A strategy for handling optimization could be to prove theorems for the same language construct compiled into a number of different hardware circuits. An actual hardware compiler would choose one of these, perhaps depending on whether circuit size of speed is of greatest importance for example. The compiling relation could also be composed with optimizations at the netlist level (similar to machine code level optimizations on a software compiler), which could be proved to respect the refinement ordering. For examples of optimization for software compilation, see [13, 16]. The hardware compilation approach presented here has been used in practice in the commercialization of the Handel-C compiler [11],

hc-tjs.tex; 13/09/2000; 20:35; p.16

Specification and Verification of a Hardware Compilation Scheme

17

marketed by Embedded Solutions Ltd. However, this language has not been formally specified and proved correct in the manner presented in this paper. The language has a C-like syntax to make it more acceptable in industry, but the semantics is close to that of Occam in practice, including parallel constructs. Xilinx-based FPGA [31] boards are also available as targets for the compiled netlist output. This demonstrates the commercial viability of the hardware compilation approach presented in this paper. Of course, the commercial compiler includes considerably more optimization than the compilation scheme presented here, but it has not been verified. A goal for the future could be to attempt to verify a much more optimized compilation scheme like that used by the Handel-C compiler. For wider use, it may be necessary to interface to Hardware Description Languages (HDLs) in general industrial use such as Verilog and VHDL [7, 9]. There is much interest and research in the area of hardware/software co-design from both the theoretical and the practical point of view [14, 15, 21, 22, 24]. In the future, hardware/software ‘co-compilation’ may become increasingly feasible. A major problem is the decision on the split between hardware and software implementation. Typically it may be best to implement inner loops in hardware (where many programs tend to spend most of their time executing), leaving other lesser used parts in software (e.g., initialization). However, the hardware/software division is normally a difficult engineering decision to ensure good use of resources and it is probable that some guidance from the engineer, perhaps with information on resources issues provided by a tool) will normally be required. The approach presented in this paper may be most applicable in high-integrity systems [8] where correctness is paramount. For example, in safety-critical applications, the non-use of techniques for fault avoidance by engineers (as well as more traditional fault removal techniques such as testing) may even be deemed unethical [4].

Notes

1. Further information relevant to the subject matter of this paper may be found linked from the website of the Centre for Applied Formal Methods:

http://www.cafm.sbu.ac.uk/ 2. For information on the United Nations University Institute for Software Technology (UNU/IIST), see: http://www.unu.iist.edu/

hc-tjs.tex; 13/09/2000; 20:35; p.17

18

J.P. Bowen & He Jifeng

Acknowledgements Thanks are due to Prof. Sir Tony Hoare, Zheng Jianping, Ian Page and Wayne Luk for inspiration. The comments of one of the anonymous referees were especially helpful.

References 1.

2.

3. 4. 5.

6. 7.

8.

9.

10.

11. 12. 13.

F. Balarin, M. Chiodo, P. Giusto, H. Hsieh, A. Jurecska, L. Lavagno, C. Passerone, A. Sangiovanni-Vincentelli, E. Sentovich, K. Suzuki and B. Tabbara. Hardware-software Co-design of Embedded Systems: The Polis approach, Kluwer International Series in Engineering and Computer Science, 1997. G. Berry. The foundations of Esterel. In G. Plotkin, C. Stirling and M. Tofte, eds., Proof, language and interaction: Essays in honour of Robin Milner, MIT Press, 2000. J.P. Bowen, ed. Towards Verified Systems, Real-Time Safety Critical Systems series, Vol. 2, Elsevier Science, 1994. J.P. Bowen. The ethics of safety-critical systems. Communcations of the ACM, 43(4):91–97, April 2000. J.P. Bowen and He Jifeng. Hardware compilation: Verification and rapidprototyping. Technical Report RUCS/1999/TR/012/A, Department of Computer Science, The University of Reading, UK, October 1999. J.P. Bowen, He Jifeng and I. Page. Hardware compilation. In [3], Chapter 10, pp. 193–207, 1994. J.P. Bowen, He Jifeng and Xu Qiwen. An animatable operational semantics of the Verilog Hardware Description Language. In Shaoying Liu, J.A. McDermid and M.G. Hinchey, eds., Proc. ICFEM2000: 3rd IEEE International Conference on Formal Engineering Methods, York, UK, 4–6 September 2000, pp. 199-207. IEEE Computer Society Press, 2000. J.P. Bowen and M.G. Hinchey. High-Integrity System Specification and Design, Formal Approaches to Computing and Information Technology (FACIT) series, Springer-Verlag, 1999. P.T. Breuer, N. Madrid, C. Delgado Kloos, J.P. Bowen, R. France and M. Petrie. Reasoning about VHDL and VHDL-AMS using denotational semantics. In D. Borrione, ed., DATE’99: Design, Automation & Test in Europe, Munich, Germany, 9–12 March 1999, pages 346–352, ACM, 1999. A. Cerone, A.J. Cowie and G.J. Milne. The Circal system. In Proc. 6th International Conference on Algebraic Methodologies and Software Technology (AMAST’97), Sydney, Australia, 13–17 December 1997. Lecture Notes in Computer Science, Vol. 1349, pp. 563–564. Springer-Verlag, 1997. Embedded Solutions Ltd. Handel-C v2.1: Product Information Sheet, Milton Park, Abingdon, Oxfordshire, UK, 1999. URL: http://www.embeddedsol.com/ L. Garber and D. Sims. In pursuit of hardware-software codesign. IEEE Computer, 31(6):12–14, June 1998. He Jifeng. Provably Correct Systems: Modelling of Communication Languages and Design of Optimized Compilers, McGraw-Hill International Series in Software Engineering, 1995.

hc-tjs.tex; 13/09/2000; 20:35; p.18

Specification and Verification of a Hardware Compilation Scheme

14.

15.

16. 17.

18.

19. 20. 21. 22.

23.

24. 25.

26. 27.

28. 29. 30. 31.

19

He Jifeng. A common framework for mixed hardware/software systems. In K. Araki, A. Galloway and K. Taguchi, eds., IFM 99: Proceedings of the 1st International Conference on Integrated Formal Methods, York, 28–29 June 1999, pp. 1–15. Springer-Verlag, 1999. He Jifeng. A behavioral model for co-design. In J.M. Wing, J. Woodcock and J. Davis, eds., FM’99 – Formal Methods, Lecture Notes in Computer Science, Vol. 1709, pp. 1420–1438. Springer-Verlag, 1999. He Jifeng and J.P. Bowen. Specification, verification and prototyping of an optimized compiler. Formal Aspects of Computing, 6(6):643–658, 1994. He Jifeng, I. Page and J.P. Bowen. Towards a provably correct hardware implementation of Occam. In G.J. Milne and L. Pierre, eds., Correct Hardware Design and Verification Methods, Lecture Notes in Computer Science, Vol. 683, pp. 214–226. Springer-Verlag, 1993. M.G. Hinchey and J.P. Bowen, eds. Industrial-Strength Formal Methods in Practice, Formal Approaches to Computing and Information Technology (FACIT) series, (Springer-Verlag, 1999. C.A.R. Hoare. The logic of engineering design. Microprocessing and Microprogramming, 41(8–9):525–539, 1996. C.A.R. Hoare and He Jifeng. Unifying Theories of Programming, Prentice Hall Series in Computer Science, 1998. C.A.R. Hoare and I. Page. Hardware and software: Closing the gap. Transputer Communications, 2(2):69–90, June 1994. J. Iyoda, A. Sampaio and L. Silva. ParTS: A partitioning transformation system. In J.M. Wing, J. Woodcock and J. Davis, eds., FM’99 – Formal Methods, Lecture Notes in Computer Science, Vol. 1709 pp. 1400–1419. Springer-Verlag, 1999. G. Milne. CIRCAL and the representation of communication, concurrency and time. ACM Transactions on Programming Languages and Systems, 7(2):270– 298, 1985. I. Page. Constructing hardware-software systems from a single description. Journal of VLSI Signal Processing, 12(1):87–107, 1996. I. Page and W. Luk. Compiling Occam into Field-Programmable Gate Arrays. In W. Moore and W. Luk, eds., FPGAs, pp. 271–284. Abingdon EE&CS Books, Abingdon, UK, 1991. A.W. Roscoe and C.A.R. Hoare. Laws of Occam programming. Theoretical Computer Science, 60:177–229, 1988. P. Shaw. A Generic Approach to Compiling Occam into Circuits. PhD thesis, Department of Computer Science, University of Strathclyde, UK, December 1994. P. Shaw and G. Milne. A highly parallel FPGA-based machine and its formal verification. In Proc. FPL92, pp. 162–173, 1992. J. Staunstrup and W. Wolf, eds. Hardware/Software Co-design: Principles and practice, Kluwer Academic Publishers, 1997. N. Wirth. Hardware compilation: Translating programs into circuits. IEEE Computer, 31(6):25–31, June 1998. Xilinx, Inc. Spartan Series FPGAs, San Jose, California, USA, 1999. URL: http://www.xilinx.com/products/spartan.htm

hc-tjs.tex; 13/09/2000; 20:35; p.19

20

J.P. Bowen & He Jifeng

Authors’ Vitae Jonathan P. Bowen Prof. Bowen is at South Bank University, London, UK, where he is Professor of Computing and heads the Centre for Applied Formal Methods. From 1995 to March 2000, Bowen was a lecturer at the Department of Computer Science, University of Reading where he led the Formal Methods and Software Engineering Group. Previously he was a senior researcher at the Oxford University Computing Laboratory Programming Research Group where he worked under the guidance of Sir Tony Hoare. Between 1979 and 1984 he worked at Imperial College, London as a research assistant, latterly in the interdepartmental Wolfson Microprocessor Laboratory. He has been involved with the fields of electronics and computing in both industry (including Marconi Instruments, Logica and Silicon Graphics Inc.) and academia since 1977. His interests include formal methods, safety-critical systems, the Z notation, provably correct systems, rapid prototyping using logic programming, decompilation, hardware compilation, software/hardware co-design, the history of computing and on-line museums. He has produced over 150 publications, 11 books and has served on around 30 programme committees. He is a member of the ACM and IEEE Computer Society, and holds an MA degree in Engineering Science from Oxford University. He Jifeng Prof. He has been a Senior Research Fellow at the United Nations University International Institute for Software Technology (UNU/IIST) in Macau since 1998. Between 1984 and 1998 he was a senior researcher at the Oxford University Computing Laboratory Programming Research Group in England where he worked extensively with Sir Tony Hoare. His research interest lies in the sound methods of specification of computer systems, communications, application and standards, and the techniques for designing and implementing those specifications in software and/or hardware, with high reliability and at low cost. He has authored books on Provably Correct Systems and (with Tony Hoare) Unifying Theories of Programming as well as numerous research papers. He is Professor of Computer Science at two Chinese universities, East China Normal University since 1986 and Shanghai Jiao Tong University since 1996.

hc-tjs.tex; 13/09/2000; 20:35; p.20

An Approach to the Specification and Verification of a ...

systems where safety or security is paramount. A prototype ..... Composite Design. To assemble hardware components to form a network, both parallel ...... Hoare. Between 1979 and 1984 he worked at Imperial College, Lon- don as a research ...

224KB Sizes 2 Downloads 196 Views

Recommend Documents

A Framework for Systematic Specification and E cient Verification of ...
then a description of an abstract level (such as the assembly language level), while its .... In section 6 we give veri cation benchmarks, and we last conclude.

An Approach to Verifiable Compiling Specification and Prototyping
Systems." yFunded by the ESPRIT BRA ProCoS project: no. 3104, \Provably Correct Systems." zOn leave from the .... represents the data space available to the ML0 program. ..... can be found using the psi clause (see later for more details).

An approach for automating the verification of KADS- based expert ...
Our study indicates that in order to verify an expert system, it is necessary to have a ... provides principled mapping to the symbol level necessary for V&V (2). 4. .... the user, database when the value is queried from a database, derived when the

An approach for automating the verification of KADS ...
knowledge base development environment upon which we build our verification tool. Section 5 ... In such applications, there is a possibility of great financial.

Specification and Verification of Object Models with TLA ...
this to state machines for objects and sequence diagrams for modelling object collaboration. Further we have checked consistency between all these models for specific examples. However, this is outside the scope of this paper. 5 Case Study: A Library

Specification and verification challenges for sequential ...
The specification challenge of dealing with computer versus infinite arithmetic (A.1) has been addressed in the con- ..... modifier is supported by Spec#, but not by the current version of JML. Listing ...... Journal of the ACM, 52(3):365–473, 2005

Specification and verification challenges for sequential ...
Side effects in expressions (B.2) as well as aliasing (C.3) are handled by ...... for instance a method C.caller that calls D.middle, which in turn calls C.callee.

An Approach For Integrity Verification In Multi Cloud Storage ... - IJRIT
using virtual infrastructure management (VIM) , a multi-cloud allows clients to easily ... These tools help cloud providers construct a distributed cloud storage ...

An Author Verification Approach Based on Differential ...
We propose a machine learning approach based on a number of different features that characterize documents ... The latter index is computed as c@1 = nc n. + nunc n2 ..... Chang, C.C., Lin, C.J.: Libsvm: a library for support vector machines.

An Approach For Integrity Verification In Multi Cloud Storage ... - IJRIT
IJRIT International Journal of Research in Information Technology, Volume 2, Issue 7, July 2014, Pg: 100-105. Vinitha Varghese ... In this paper, we address the ... Since cloud computing environment is constructed based on open architectures ...

An Approach to the Better Understanding of the ...
E-mail: [email protected] [email protected] [email protected]. Abstract: The ... types, the relative arc length and humidity [2]. In [3],. [4] the current ...

An Institutionwide Approach to Redesigning Management of ...
rest events occur annually in the United States.1 Despite widespread training ... achieve the highest likelihood of success, the emergency must be identified, and ...

using simio for the specification of an integrated automated weighing ...
This paper focuses on the use of a discrete simulation tool (SIMIO) in the logistic system design of a ce- ment plant. ... This specification will then help the design phase of the whole plant and will contribute for the ra- ... more than 50 tons of

A Static Verification Approach for Architectural ...
the interface signals (voltage, current for analog pins and logic level for digital pins). (2) Mode sequence charts are ..... is a mixed signal circuit consisting of a digital controller and an analog driver circuit. The digital controller ... voltag

Specification of a Component-based Domotic System to ...
of distributed services and a system that manipulates .... can provided by several service providers. Each service provider is bound to concrete component interfaces (often .... Conf. on AINA, Niagara Falls, Canada, 596-603, May. 2007. IEEE.

An Interactionist Approach to the Social Construction of Deities.pdf ...
An Interactionist Approach to the Social Construction of Deities.pdf. An Interactionist Approach to the Social Construction of Deities.pdf. Open. Extract. Open with.

An interdisciplinary approach to the treatment of ...
affected boy with a long history of the disease, manifesting a great lot of all possible complications, this approach ... A 13-year-old boy with the diagnosis of Crohn's disease in a progressive state over the last 9.5 years. .... Farmer M, Petras RE

An Interactionist Approach to the Social Construction of Deities.pdf ...
processes may expand existing religious and interactionist studies. Keywords: deities, religion, generic processes, identity work, supernat- ural phenomena. Since its inception, sociology has grappled with the influence of varied deities (i.e.,. gods

Towards A Unified Modeling and Verification of Network and System ...
be created by users or services running on top of hosts in the network. The services in our model can also transform a request into another one or more requests ...

Specification of a Component-based Domotic System to Support User ...
more, scenario integration in the system should be au- tomatic and dynamic, in ... Few systems support more complex users requirements, but are based on ...