-
Notifications
You must be signed in to change notification settings - Fork 0
/
sevsgbench.tfw
137 lines (126 loc) · 3.85 KB
/
sevsgbench.tfw
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995-2003 Xilinx, Inc.
// All Right Reserved.
////////////////////////////////////////////////////////////////////////////////
// ____ ____
// / /\/ /
// /___/ \ / Vendor: Xilinx
// \ \ \/ Version : 8.2i
// \ \ Application : ISE
// / / Filename : sevsgbench.tfw
// /___/ /\ Timestamp : Fri Oct 25 09:15:32 2019
// \ \ / \
// \___\/\___\
//
//Command:
//Design Name: sevsgbench
//Device: Xilinx
//
`timescale 1ns/1ps
module sevsgbench;
wire [6:0] f;
wire [3:0] sw;
reg sel0 = 1'b0;
reg sel1 = 1'b0;
reg WE = 1'b1;
reg x0 = 1'b0;
reg x1 = 1'b0;
reg x2 = 1'b0;
reg x3 = 1'b0;
sevensegmentnew UUT (
.f(f),
.sw(sw),
.sel0(sel0),
.sel1(sel1),
.WE(WE),
.x0(x0),
.x1(x1),
.x2(x2),
.x3(x3));
integer TX_FILE = 0;
integer TX_ERROR = 0;
initial begin // Open the results file...
TX_FILE = $fopen("results.txt");
#1000 // Final time: 1000 ns
if (TX_ERROR == 0) begin
$display("No errors or warnings.");
$fdisplay(TX_FILE, "No errors or warnings.");
end else begin
$display("%d errors found in simulation.", TX_ERROR);
$fdisplay(TX_FILE, "%d errors found in simulation.", TX_ERROR);
end
$fclose(TX_FILE);
$stop;
end
initial begin
// ------------- Current Time: 200ns
#200;
sel1 = 1'b1;
x0 = 1'b1;
// -------------------------------------
// ------------- Current Time: 250ns
#50;
CHECK_f(7'b0000000);
CHECK_sw(4'b1101);
// -------------------------------------
// ------------- Current Time: 300ns
#50;
sel1 = 1'b0;
x0 = 1'b0;
// -------------------------------------
// ------------- Current Time: 350ns
#50;
CHECK_f(7'b1000000);
CHECK_sw(4'b1110);
// -------------------------------------
// ------------- Current Time: 400ns
#50;
sel0 = 1'b0;
WE = 1'b0;
// -------------------------------------
// ------------- Current Time: 500ns
#100;
x2 = 1'b0;
// -------------------------------------
// ------------- Current Time: 600ns
#100;
sel0 = 1'b0;
sel1 = 1'b1;
// -------------------------------------
// ------------- Current Time: 650ns
#50;
CHECK_f(7'b0000000);
CHECK_sw(4'b1101);
// -------------------------------------
// ------------- Current Time: 700ns
#50;
sel1 = 1'b0;
// -------------------------------------
// ------------- Current Time: 750ns
#50;
CHECK_f(7'b1000000);
CHECK_sw(4'b1110);
end
task CHECK_f;
input [6:0] NEXT_f;
#0 begin
if (NEXT_f !== f) begin
$display("Error at time=%dns f=%b, expected=%b", $time, f, NEXT_f);
$fdisplay(TX_FILE, "Error at time=%dns f=%b, expected=%b", $time, f, NEXT_f);
$fflush(TX_FILE);
TX_ERROR = TX_ERROR + 1;
end
end
endtask
task CHECK_sw;
input [3:0] NEXT_sw;
#0 begin
if (NEXT_sw !== sw) begin
$display("Error at time=%dns sw=%b, expected=%b", $time, sw, NEXT_sw);
$fdisplay(TX_FILE, "Error at time=%dns sw=%b, expected=%b", $time, sw, NEXT_sw);
$fflush(TX_FILE);
TX_ERROR = TX_ERROR + 1;
end
end
endtask
endmodule