-
Notifications
You must be signed in to change notification settings - Fork 0
/
bwe.sv
81 lines (67 loc) · 1.74 KB
/
bwe.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// record how many receiving IPDs are larger than or equal to sending IPDs
module bwe (
input clk,
input rst,
(* anyseq *) input pktArrival,
output reg [31:0] counter // comparator counter
);
reg [31:0] globalTimer;
reg [31:0] IPDTimer;
reg [31:0] pktCnt;
parameter pktNumber = 3,
senderIPD = 10,
totalCycles = 162,
rangeMax = totalCycles / pktNumber,
rangeMin = senderIPD;
//relative timer
always @(posedge clk) begin
if(rst || pktArrival)
IPDTimer <= 0;
else
IPDTimer <= IPDTimer + 1;
end
always @(posedge clk) begin
if(rst)
counter <= 0;
else
if (pktArrival && (IPDTimer >= senderIPD) )
counter <= counter + 1;
else
counter <= counter;
end
//absolute timer
always @(posedge clk) begin
if(rst) globalTimer<= 0;
else globalTimer <= globalTimer + 1;
end
always @(posedge clk) begin
if(rst)
pktCnt <= 0;
else
if(pktArrival)
pktCnt <= pktCnt + 1;
else
pktCnt <= pktCnt;
end
`ifdef FORMAL
always @(posedge clk) begin
if(!$initstate) begin
assume(rst == 0);
//IPDTimer belongs to the range (rangeMin, rangeMax)
assume(IPDTimer < rangeMax);
if(pktArrival) assume(IPDTimer > senderIPD);
if(globalTimer == totalCycles )assume(pktCnt == pktNumber);
//-----//
//Invariant
assume(counter <= pktCnt);
//verify a timing property
if(globalTimer == totalCycles) assert(counter == 3);
//verify the invariant
// assert(counter <= pktCnt);
end
else begin
assume(rst);
end
end
`endif
endmodule