Logic Coverage Exercise - PowerPoint PPT Presentation

1 / 62
About This Presentation
Title:

Logic Coverage Exercise

Description:

Logic Coverage Exercise. 1. input(A,B) if (A 0) OR (B 0) then. A := A 5. end_if ... Path condition for 1,2,3,5 : Logic Coverage Exercise (a) 1. 2. 3. 4. 5 ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 63
Provided by: smthe
Learn more at: https://www.cise.ufl.edu
Category:

less

Transcript and Presenter's Notes

Title: Logic Coverage Exercise


1
Logic Coverage Exercise
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
2
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,2,3,5gt
3
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,2,3,5gt

4
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,2,3,5gt (Agt0) V (Blt0) ?

5
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,2,3,5gt (Agt0) V (Blt0) ?

6
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,2,3,5gt (Agt0) V (Blt0) ?

(A5B0) V ((A5)B0)
7
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,3,4,5gt
8
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,3,4,5gt

9
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,3,4,5gt (A0) ? (B0) ?

10
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,3,4,5gt (A0) ? (B0) ?

11
Logic Coverage Exercise (a)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

1
2
3
4
5
Path condition for lt1,3,4,5gt (A0) ? (B0) ?
(ABgt0)
? (ABlt0)
12
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
13
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
14
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

T
F
statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
15
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

T
F
statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
16
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

T
F
statement branch condition
comp. cond. path
1
2
3
T
F
4
5
test case 1 A1, B3
17
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

T
F
statement branch condition
comp. cond. path
1
2
3
T
F
4
5
test case 1 A1, B3
18
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition
comp. cond. path
T
F
1
2
3
T
F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
19
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition
comp. cond. path
T, F
F, T
1
2
3
T
F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
20
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition
comp. cond. path
T, F
F, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
21
Logic Coverage Exercise (b)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition ? comp.
cond. path
T, F
F, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
22
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition ? comp. cond.
path
T, F
F, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
23
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
24
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
25
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
26
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement ? branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
27
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement ? branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
28
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement ? branch condition ? comp. cond.
path
T, F, T, F
F, T, T, F
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
29
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement ? branch condition ? comp. cond.
path
T, F, T, F
F, T, T, F
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
30
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

statement ? branch condition ? comp. cond.
path
T, F, T, F
F, T, T, F
1
2
3
T, F, T, F
F, T, T, F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
31
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

T, F, T, F
F, T, T, F
statement ? branch ? condition ? comp.
cond. path
1
2
3
T, F, T, F
F, T, T, F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
32
Logic Coverage Exercise (c)
  • 1. input(A,B)
  • if (Agt0) OR (Blt0) then
  • A A5
  • end_if
  • 3. if (ABgt0) AND (ABlt0) then
  • 4. B AB
  • end_if
  • 5. output(A,B)

T, F, T, F
F, T, T, F
statement ? branch ? condition ? comp.
cond. ? path
1
2
3
T, F, T, F
F, T, T, F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
33
While Loop Verification Exercise
  • y gt 0
  • z x
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy

34
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy

35
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • initialization PgtI

36
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • initialization PgtI
  • Does (ygt0 ? zx ? ny) ? (zx(y1-n) ? n1)?

37
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • initialization PgtI
  • Does (ygt0 ? zx ? ny) ? (zx(y1-n) ? n1)?
  • Yes. Clearly, if zx and ny, it follows that
  • zx(y1-n)
  • Similarly, if nygt0, it follows that n1.

38
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I

39
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1

40
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1

41
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
  • z zx

42
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
  • z zx
  • zx(y2-n) ? ngt1

43
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
  • z zx
  • zx(y2-n) ? ngt1
  • n n-1

44
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
  • z zx
  • zx(y2-n) ? ngt1
  • n n-1
  • zx(y2-(n1)) ? (n1)gt1

45
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • preservation I?b s I
  • zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
  • z zx
  • zx(y2-n) ? ngt1
  • n n-1
  • zx(y2-(n1)) ? (n1)gt1
  • zx(y1-n) ? n1 I

46
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • finalization (I?b) gt Q

47
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • finalization (I?b) gt Q
  • Does (zx(y1-n) ? n1 ? n1) ? zxy?

48
While Loop Verification Exercise
  • y gt 0 I z x(y1-n)
  • z x ? n 1
  • n y
  • while ngt1 do
  • z zx
  • n n-1
  • end_while
  • z xy
  • finalization (I?b) gt Q
  • Does (zx(y1-n) ? n1 ? n1) ? zxy?
  • Yes, since (zx(y1-n) ? n1 ? n1) ? (n1?
    zx(y1-1)) ? zxy

49
While Loop Verification Exercise
  • n 0
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n

50
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n

51
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • initialization PgtI

52
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • initialization PgtI
  • Does (n0 ? p1 ? k0) ? (p2k? kn)?

53
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • initialization PgtI
  • Does (n0 ? p1 ? k0) ? (p2k? kn)?
  • Yes. Clearly, if p1 and k0, it follows that
  • p2k
  • Similarly, if n0 and k0 it follows that kn.

54
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • preservation I?b s I
  • p2k? kn ? kltn

55
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • preservation I?b s I
  • p2k? kn ? kltn p2k? kltn

56
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • preservation I?b s I
  • p2k? kn ? kltn p2k? kltn
  • p 2p

57
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • preservation I?b s I
  • p2k? kn ? kltn p2k? kltn
  • p 2p
  • p2k1? kltn

58
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • preservation I?b s I
  • p2k? kn ? kltn p2k? kltn
  • p 2p
  • p2k1? kltn
  • k k1

59
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • preservation I?b s I
  • p2k? kn ? kltn p2k? kltn
  • p 2p
  • p2k1? kltn
  • k k1
  • p2k? kn I

60
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • finalization (I?b) gt Q

61
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • finalization (I?b) gt Q
  • Does (p2k? kn ? kn) ? p2n?

62
While Loop Verification Exercise
  • n 0 I p 2k? k n
  • p 1
  • k 0
  • while kltn do
  • p 2p
  • k k1
  • end_while
  • p 2n
  • finalization (I?b) gt Q
  • Does (p2k? kn ? kn) ? p2n?
  • Yes, since (p2k? kn ? kn) ? (kn ? p2k) ?
    p 2n
Write a Comment
User Comments (0)
About PowerShow.com