Verification of Parameterised FPGA Circuit Descriptions with Layout ...

Verification of Parameterised FPGA Circuit Descriptions with Layout ... Verification of Parameterised FPGA Circuit Descriptions with Layout ...

24.04.2013 Views

CHAPTER 4. VERIFYING CIRCUIT LAYOUTS 82 SB ′ :: BlockEnv → Block → (SizeFunc × SizeFunc) SB ′ β block bid d1 . . . dn ∼ r attributes { height = h. width = w. } { τ1 id1 . . . τp idp. stmts } = let m = S ′ βstmts in (λd1 . . .dn r. let (id1, . . . , idp) = (ι(id1, . . .,idp). m) in w, λd1 . . . dn r. let (id1, . . . , idp) = (ι(id1, . . . , idp). m) in h) Figure 4.9: Converting Quartz size expressions into QuartzLayout size functions automatic. Figure 4.8 gives the definition of the function Bβ which gives the semantics of a block as a logical predicate. This function gives Quartz a formal semantics in HOL, using an environment β which maps block identifiers to their definitions. The function in Figure 4.8 is implemented in the Quartz compiler layout processing module. The only difference between the formal definition and the compiler implementation is that the function B ′ β is not executed, instead the modelling of block instantiation within QuartzLayout (Section 4.4.2) is used. For example, the semantics of the map n R combinator, as generated by the compiler, are described by: λ(n, R)io. ∀j. (0 ≤ j ∧ j ≤ n − 1) −→ B ′ βR(i[j], o[j]) In Isabelle’s ASCII syntax this is written as (note that “o” has been replaced with “o ” since “o” is a reserved keyword in Isabelle/HOL): % (n, R) i o . ALL (j::int). ((0

CHAPTER 4. VERIFYING CIRCUIT LAYOUTS 83 Isabelle defines arbitrary recursive functions using the recdef construct however functions defined this way require termination to be proved automatically and this is difficult for the theorem prover to do because of the way Quartz blocks are defined. Unfortunately recdef is a closed box and it is not possible to manually direct the proof and recdef compilation process to generate useful results. Luckily Isabelle does provide a (less general) recursive construct called primrec for imple- menting recursion over data structures. This can be used with the natural numbers type to write recursive equations for Quartz blocks in the form R0 = g and Rn+1 = f(Rn). This is limited to cases where the recursion of the block is controlled by a single integer parameter that decreases to zero, however this comfortably describes most recursively defined Quartz blocks. We have carried out the translation from recdef to primrec manually, however there is no reason why the process could not be automated. 4.5.3 Generating Proof Obligations The Quartz compiler also generates a series of proof obligations that check the correctness of a layout specification. The correctness theorems are split into three groups, representing proofs for validity, containment and intersection. These theorems are contained within the same theory file that defines the block’s semantic definition, height and width functions. This ensures that the theory of a block can only be loaded to support that of a block dependent on it once it has itself been proved correct. All theorems are universally quantified across all domain and range signals. Validity theorems are the simplest and are proved under the assumption that the size functions of all higher- order block parameters are also valid. Assertion pre-conditions asserted within the block’s body are also assumed and can be used in the proof. The general format of the height validity theorem for a block B of type d1 . . . dn ∼ r is:

CHAPTER 4. VERIFYING CIRCUIT LAYOUTS 83<br />

Isabelle defines arbitrary recursive functions using the recdef construct however functions<br />

defined this way require termination to be proved automatically and this is difficult for the<br />

theorem prover to do because <strong>of</strong> the way Quartz blocks are defined. Unfortunately recdef is a<br />

closed box and it is not possible to manually direct the pro<strong>of</strong> and recdef compilation process<br />

to generate useful results.<br />

Luckily Isabelle does provide a (less general) recursive construct called primrec for imple-<br />

menting recursion over data structures. This can be used <strong>with</strong> the natural numbers type to<br />

write recursive equations for Quartz blocks in the form R0 = g and Rn+1 = f(Rn). This is<br />

limited to cases where the recursion <strong>of</strong> the block is controlled by a single integer parameter<br />

that decreases to zero, however this comfortably describes most recursively defined Quartz<br />

blocks.<br />

We have carried out the translation from recdef to primrec manually, however there is no<br />

reason why the process could not be automated.<br />

4.5.3 Generating Pro<strong>of</strong> Obligations<br />

The Quartz compiler also generates a series <strong>of</strong> pro<strong>of</strong> obligations that check the correctness<br />

<strong>of</strong> a layout specification. The correctness theorems are split into three groups, representing<br />

pro<strong>of</strong>s for validity, containment and intersection. These theorems are contained <strong>with</strong>in the<br />

same theory file that defines the block’s semantic definition, height and width functions. This<br />

ensures that the theory <strong>of</strong> a block can only be loaded to support that <strong>of</strong> a block dependent<br />

on it once it has itself been proved correct.<br />

All theorems are universally quantified across all domain and range signals. Validity theorems<br />

are the simplest and are proved under the assumption that the size functions <strong>of</strong> all higher-<br />

order block parameters are also valid. Assertion pre-conditions asserted <strong>with</strong>in the block’s<br />

body are also assumed and can be used in the pro<strong>of</strong>. The general format <strong>of</strong> the height validity<br />

theorem for a block B <strong>of</strong> type d1 . . . dn ∼ r is:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!