09.08.2013 Views

Design and Verification of Adaptive Cache Coherence Protocols ...

Design and Verification of Adaptive Cache Coherence Protocols ...

Design and Verification of Adaptive Cache Coherence Protocols ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

s1 if p (s1)<br />

! s2<br />

where s1 <strong>and</strong> s2 are terms, <strong>and</strong> p is a predicate.<br />

We can use a rule to rewrite a term if the rule's left-h<strong>and</strong>-side pattern matches the term<br />

or one <strong>of</strong> its subterms <strong>and</strong> the corresponding predicate is true. The new term is generated in<br />

accordance with the right-h<strong>and</strong>-side <strong>of</strong> the rule. If several rules apply, then any one <strong>of</strong> them<br />

can be applied. If no rule applies, then the term cannot be rewritten any further <strong>and</strong> is said<br />

to be in normal form. In practice, we <strong>of</strong>ten use abstract data types such as arrays <strong>and</strong> FIFO<br />

queues to make the descriptions more readable.<br />

As an example, the Euclides algorithm for computing the greatest common divisor <strong>of</strong> two<br />

numbers can be expressed as follows:<br />

GCD(x,y) if x < y ! GCD(y,x)<br />

GCD(x,y) if x y ^y 6= 0 ! GCD(x-y,y)<br />

The SK combinatory system, which has only two rules <strong>and</strong> a simple grammar for generating<br />

terms, provides a small but fascinating example <strong>of</strong> term rewriting. These two rules are su cient<br />

to describe any computable function.<br />

K-rule: (K.x).y ! x<br />

S-rule: ((S.x).y).z ! (x.z).(y.z)<br />

We canverify that, for any subtermx, the term ((S.K).K).x can be rewritten to (K.x).(K.x)<br />

by applying the S-rule. We can rewrite the term further to x by applying the K-rule. Thus,<br />

if we read the dot as a function application, then the term ((S.K).K) behaves as the identity<br />

function. Notice the S-rule rearranges the dot <strong>and</strong> duplicates the term represented by x on the<br />

right-h<strong>and</strong>-side. For architectures in which terms represent states, rules must be restricted so<br />

that terms are not restructured or duplicated as in the S <strong>and</strong> K rules.<br />

We say term s1 can be rewritten to term s2 in zero or more steps (s1 ! s2) ifs1 <strong>and</strong> s2 are<br />

identical or there exists a term s 0 such that s1 can be rewritten to s 0 in one step (s1 ! s 0 )<strong>and</strong><br />

s 0 can be rewritten to s2 in zero or more steps (s 0 ! s2). A TRS is con uent ifforanyterms1,<br />

if s1 ! s2 <strong>and</strong> s1 ! s3, then there exists aterms4 such that s2 ! s4 <strong>and</strong> s3 ! s4. ATRSis<br />

strongly terminating if a term can always be rewritten to a normal form regardless <strong>of</strong> the order<br />

in which the rules are applied. More information about TRSs can be found elsewhere [14, 69].<br />

2.2 The AX Instruction Set<br />

We use AX, a minimalist RISC instruction set, to illustrate all the processor examples in this<br />

chapter. The TRS description <strong>of</strong> a simple AX architecture also provides a good introductory<br />

example to the TRS notation. In the AX instruction set (Figure 2.1), all arithmetic operations<br />

27

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

Saved successfully!

Ooh no, something went wrong!