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 3. GENERATING PARAMETERISED LIBRARIES WITH LAYOUT 44 Where a single block is instantiated the width and height functions are extracted from the σ environment and are returned after the application of curried parameters p1 . . . pn. The size of a parallel composition of blocks is calculated as though the blocks are arranged vertically, with the overall height being the sum of the height of each individual block and the overall width being the maximum width of any block in the composition. The size of a series composition of blocks is calculated as though the blocks are arranged horizontally in a similar manner. Series composition is represented as a fully associative binary operator (an n-size composition can be represented as nested series compositions) for convenience. The series composition size function internal signal s is defined in terms of the ι definite description operator. This operator, in the form ιx. P(x) can be read as “the x such that P(x) holds”. In this case the internal signal s is the one such that it obeys the predicates produced by the application of function B ′ to the two blocks. This is made necessary by the relational nature of Quartz blocks which means it is not possible to state whether block b1 or block b2 generates the value s (or some combination of the two, if it is a tuple of values). This logical nicety is practically irrelevant for us in this chapter since we will convert relational Quartz descriptions into functional ones during compilation while evaluating any size functions. The grey boxes with dotted outlines in Figure 3.5 illustrate the sizes calculated for series and parallel compositions diagrammatically. 3.4.3 Size Inference As noted in the previous section each type of statement has a particular layout interpretation and we can exploit that to describe the size of each type of statement recursively. The size of an entire block can then be described in terms of the sizes of its constituent statements. The function SB, shown in Figure 3.6, returns a pair of expressions describing the height and width of a block in terms of its domain, range and internal signals. Unlike the SI function we described previously this function is directly implementable since it does not use the definite description operator or refer explicitly to internal signals. Note also that this function does not infer size functions for the block, it infers size expressions in terms of the block’s local environment. These size expressions can be converted into

CHAPTER 3. GENERATING PARAMETERISED LIBRARIES WITH LAYOUT 45 SB :: Block → (Exp × Exp) SB block bid d1 . . . dn ∼ r { τ1 id1 . . . τq idq. stmts } = SS ′ stmts SS ′ :: StmtList → (Exp × Exp) SS ′ stmt1 . . . stmtn = let (w1, h1) = SSstmt1 in . let (wn, hn) = SSstmtn in (max(w1, . . .,wn), max(h1, . . . , hn)) SS :: Stmt → (Exp × Exp) SS assert e str = (0, 0) SS e1 = e2 = (0, 0) SS if e { stmts1 } else { stmts2 } = let (w1, h1) = SS ′ stmts1 in let (w2, h2) = SS ′ stmts2 in (if(e, w1, w2), if(e, h1, h2)) SS for i = e1..e2 { stmts } = let (w, h) = SSstmts in (maxf(i = e1..e2, w), maxf(i = e1..e2, h)) SS a ; blkinst ; b at (x, y) = (width(a ; blkinst ; b) + x, height(a ; blkinst ; b) + y) Figure 3.6: Inferring the size of a block functions in terms of the block’s domain and range variables by binding any local variables to values determined through an ι operator and the semantic meaning function for the block’s statements, however we will not pursue this approach in this chapter. This introduces a slight divergence between the function SI which is parameterised by a SizeEnv environment of block size functions and the size inference function, which produces expressions, however for the purposes of our implementation this is desirable - we take an alternative approach to implementing these semantics during the compilation process. In Chapter 4 we will return to using size functions for verification purposes and Figure 4.9 on page 82 illustrates how size expressions can be converted into size functions. The key concept this function implements is that a block’s size is the top right corner of a bounding box that encloses all sub-blocks instantiated within it. This is found by selecting the maximum value for each statement then selecting the maximum of all statements for the block as a whole. It is important to note that because max has been added to the set of available expression operators, the expressions that describe the height and width can remain fully parameterised in terms of a block’s signals and the max function can be evaluated exactly during full elaboration of the design rather than forcing the compiler to select a (possibly

CHAPTER 3. GENERATING PARAMETERISED LIBRARIES WITH LAYOUT 44<br />

Where a single block is instantiated the width and height functions are extracted from the σ<br />

environment and are returned after the application <strong>of</strong> curried parameters p1 . . . pn. The size <strong>of</strong><br />

a parallel composition <strong>of</strong> blocks is calculated as though the blocks are arranged vertically, <strong>with</strong><br />

the overall height being the sum <strong>of</strong> the height <strong>of</strong> each individual block and the overall width<br />

being the maximum width <strong>of</strong> any block in the composition. The size <strong>of</strong> a series composition<br />

<strong>of</strong> blocks is calculated as though the blocks are arranged horizontally in a similar manner.<br />

Series composition is represented as a fully associative binary operator (an n-size composition<br />

can be represented as nested series compositions) for convenience. The series composition<br />

size function internal signal s is defined in terms <strong>of</strong> the ι definite description operator. This<br />

operator, in the form ιx. P(x) can be read as “the x such that P(x) holds”. In this case<br />

the internal signal s is the one such that it obeys the predicates produced by the application<br />

<strong>of</strong> function B ′ to the two blocks. This is made necessary by the relational nature <strong>of</strong> Quartz<br />

blocks which means it is not possible to state whether block b1 or block b2 generates the value<br />

s (or some combination <strong>of</strong> the two, if it is a tuple <strong>of</strong> values). This logical nicety is practically<br />

irrelevant for us in this chapter since we will convert relational Quartz descriptions into<br />

functional ones during compilation while evaluating any size functions.<br />

The grey boxes <strong>with</strong> dotted outlines in Figure 3.5 illustrate the sizes calculated for series and<br />

parallel compositions diagrammatically.<br />

3.4.3 Size Inference<br />

As noted in the previous section each type <strong>of</strong> statement has a particular layout interpretation<br />

and we can exploit that to describe the size <strong>of</strong> each type <strong>of</strong> statement recursively. The size<br />

<strong>of</strong> an entire block can then be described in terms <strong>of</strong> the sizes <strong>of</strong> its constituent statements.<br />

The function SB, shown in Figure 3.6, returns a pair <strong>of</strong> expressions describing the height<br />

and width <strong>of</strong> a block in terms <strong>of</strong> its domain, range and internal signals.<br />

Unlike the SI function we described previously this function is directly implementable since<br />

it does not use the definite description operator or refer explicitly to internal signals. Note<br />

also that this function does not infer size functions for the block, it infers size expressions<br />

in terms <strong>of</strong> the block’s local environment. These size expressions can be converted into

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

Saved successfully!

Ooh no, something went wrong!