-
Notifications
You must be signed in to change notification settings - Fork 3
/
cordic_tb.v
38 lines (34 loc) · 941 Bytes
/
cordic_tb.v
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
module cordic_tb();
/// parameters
parameter num_of_tests = 1000;
parameter word_SZ = 18; // width of input and output data
parameter frac_SZ = 16;
///
parameter period = 10;
localparam cycle = period/2;
parameter latency = 2*word_SZ*period;
localparam sim_duration = num_of_tests*period + latency;
// DUT assigning
reg clk;
reg [word_SZ-1:0] angle;
wire [word_SZ-1:0] out;
cordic cor(.angle(angle),.out(out),.clk(clk));
// Integer Declaration
integer op, op_out, k;
// File handling
initial
begin
$dispaly("Cordic tanh simulation started");
op=$fopen ("test.txt","r");
op_out=$fopen ("test_result.txt","w");
end
always @(posedge clk) k <= $fscanf (op, "%b \n", angle);
always @(posedge clk) $fwrite (op_out,"%b \n",out);
// clock generator
always
begin
clk = 0; #cycle; clk = 1; #cycle;
end
initial #sim_duration $stop;
initial #sim_duration $finish;
endmodule