-
Notifications
You must be signed in to change notification settings - Fork 2
/
tb_M.v.bak
103 lines (88 loc) · 1.58 KB
/
tb_M.v.bak
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
`timescale 1ns / 1ns
module tb_M;
// Inputs
reg clk;
reg rst;
reg start;
// Outputs
//wire [3:0] parallel_data;
//wire serial_in;
//wire data_flag;
//wire [15:0] sin, cos;
wire [19:0] mixed_output;
integer mixed_out;
// DUT
top_level top(
.clk(clk),
.rst(rst),
.start(start),
.mixed_output(mixed_output)
);
/*data_generator dat_gen(
.clk(clk),
.rst(rst),
.enable(start),
.serial_in(serial_in),
.data_flag(data_flag)
);
serial_2_parallel dut (
.clk(clk),
.rst(rst),
.start(start),
.serial_in(serial_in),
.data_flag(data_flag),
.parallel_data(parallel_data)
);
local_oscillator lo(
.clk(clk),
.rst(rst),
.start(start),
.sin(sin),
.cos(cos)
);
modulator md(
.clk(clk),
.rst(rst),
.start(start),
.parallel_data(parallel_data),
.sin(sin),
.cos(cos),
.mixed_output(mixed_output)
);*/
initial begin
// Initialize Inputs
clk = 0;
rst = 0;
start = 1;
// Wait 10 ns for global reset to finish
#10;
rst = 1;
end
always #5
clk <= ~clk;
integer i = 0;
always @(posedge clk) begin
if(i) begin $fwrite(mixed_out,"%b \n", mixed_output); i = 0;end
else i = 1;
end
initial begin
#40850
mixed_out = $fopen("mixed_out.txt");
#652800
$fclose(mixed_out);
end
initial begin
#700000
$stop;
end
/*always @(posedge clk) begin
data_flag = 0;
if(i == 7) begin
serial_in = $unsigned($random)%2;
data_flag = 1;
i = i-1;
end
else if(i == 0) i = 7;
else i = i-1;
end*/
endmodule