generator quick fix
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
module generator_tb;
|
||||
|
||||
parameter DATA_WIDTH = 14;
|
||||
parameter ZERO_LEVEL = 8192;
|
||||
parameter CLK_PERIOD = 16;
|
||||
parameter ZERO_LEVEL = 0;
|
||||
parameter CLK_PERIOD = 8;
|
||||
|
||||
logic clk;
|
||||
logic rst;
|
||||
@ -17,10 +17,12 @@ module generator_tb;
|
||||
|
||||
logic pulse;
|
||||
logic [DATA_WIDTH-1:0] pulse_height_out;
|
||||
logic sample_done, sample_req;
|
||||
|
||||
// DUT
|
||||
generator #(
|
||||
.DATA_WIDTH(DATA_WIDTH)
|
||||
.DATA_WIDTH(DATA_WIDTH),
|
||||
.ZERO_LEVEL(ZERO_LEVEL)
|
||||
) dut (
|
||||
.clk_in(clk),
|
||||
.rst(rst),
|
||||
@ -30,7 +32,9 @@ module generator_tb;
|
||||
.pulse_height(pulse_height),
|
||||
.pulse_num(pulse_num),
|
||||
.pulse(pulse),
|
||||
.pulse_height_out(pulse_height_out)
|
||||
.pulse_height_out(pulse_height_out),
|
||||
.sample_done(sample_done),
|
||||
.sample_req(sample_req)
|
||||
);
|
||||
|
||||
// Clock
|
||||
@ -49,6 +53,7 @@ module generator_tb;
|
||||
pulse_period = 0;
|
||||
pulse_height = 0;
|
||||
pulse_num = 0;
|
||||
sample_done = 0;
|
||||
|
||||
repeat(5) @(posedge clk);
|
||||
rst = 0;
|
||||
@ -56,59 +61,67 @@ module generator_tb;
|
||||
// --- Test 1 ---
|
||||
// 3 clk 1, 5 clk 0, 4 pulses
|
||||
repeat(2) @(posedge clk);
|
||||
pulse_width = 3;
|
||||
pulse_period = 8;
|
||||
pulse_width = 1;
|
||||
pulse_period = 20;
|
||||
pulse_num = 4;
|
||||
pulse_height = 14'h3FF;
|
||||
#1;
|
||||
start = 1;
|
||||
|
||||
repeat(1) @(posedge clk);
|
||||
repeat(1) @(posedge clk);
|
||||
start = 0;
|
||||
|
||||
repeat(50) @(posedge clk);
|
||||
|
||||
// --- Test 2 ---
|
||||
$display("\n--- SECOND RUN ---\n");
|
||||
|
||||
wait(sample_req == 1);
|
||||
@(posedge clk);
|
||||
pulse_width = 2;
|
||||
pulse_period = 5;
|
||||
pulse_num = 3;
|
||||
pulse_height = 14'h155;
|
||||
start = 1;
|
||||
#1;
|
||||
sample_done = 1;
|
||||
wait(sample_req == 0)
|
||||
sample_done = 0;
|
||||
|
||||
@(posedge clk);
|
||||
start = 0;
|
||||
repeat(pulse_period*pulse_num+10) @(posedge clk);
|
||||
|
||||
// // --- Test 2 ---
|
||||
// $display("\n--- SECOND RUN ---\n");
|
||||
|
||||
repeat(40) @(posedge clk);
|
||||
// @(posedge clk);
|
||||
// pulse_width = 2;
|
||||
// pulse_period = 5;
|
||||
// pulse_num = 3;
|
||||
// pulse_height = 14'h155;
|
||||
// start = 1;
|
||||
|
||||
// @(posedge clk);
|
||||
// start = 0;
|
||||
|
||||
// repeat(40) @(posedge clk);
|
||||
|
||||
pulse_width = 3;
|
||||
pulse_period = 8;
|
||||
pulse_num = 4;
|
||||
pulse_height = 14'h3FF;
|
||||
start = 1;
|
||||
// pulse_width = 3;
|
||||
// pulse_period = 8;
|
||||
// pulse_num = 4;
|
||||
// pulse_height = 14'h3FF;
|
||||
// start = 1;
|
||||
|
||||
repeat(1) @(posedge clk);
|
||||
start = 0;
|
||||
// repeat(1) @(posedge clk);
|
||||
// start = 0;
|
||||
|
||||
repeat(5) @(posedge clk);
|
||||
start = 1;
|
||||
pulse_height = 14'h155;
|
||||
// repeat(5) @(posedge clk);
|
||||
// start = 1;
|
||||
// pulse_height = 14'h155;
|
||||
|
||||
repeat(1) @(posedge clk);
|
||||
start = 0;
|
||||
// repeat(1) @(posedge clk);
|
||||
// start = 0;
|
||||
|
||||
repeat(50) @(posedge clk);
|
||||
// repeat(50) @(posedge clk);
|
||||
|
||||
|
||||
$display("\n=== TEST FINISHED ===");
|
||||
$finish;
|
||||
end
|
||||
// $display("\n=== TEST FINISHED ===");
|
||||
// $finish;
|
||||
end
|
||||
|
||||
// Display
|
||||
always @(posedge clk) begin
|
||||
$display("t=%0t | pulse=%0b | height=%h",
|
||||
$time, pulse, pulse_height_out);
|
||||
end
|
||||
// // Display
|
||||
// always @(posedge clk) begin
|
||||
// $display("t=%0t | pulse=%0b | height=%h",
|
||||
// $time, pulse, pulse_height_out);
|
||||
// end
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user