2016-01-11 15:05:21 -05:00
|
|
|
/* verilator lint_off STMTDLY */
|
2015-11-03 14:16:50 -05:00
|
|
|
module dv_ctrl(/*AUTOARG*/
|
|
|
|
// Outputs
|
|
|
|
nreset, clk, start,
|
|
|
|
// Inputs
|
|
|
|
dut_active, stim_done, test_done
|
|
|
|
);
|
|
|
|
|
|
|
|
parameter CLK_PERIOD = 10;
|
|
|
|
parameter CLK_PHASE = CLK_PERIOD/2;
|
2016-01-13 15:32:15 -05:00
|
|
|
parameter TIMEOUT = 5000;
|
2015-11-03 14:16:50 -05:00
|
|
|
|
|
|
|
output nreset; // async active low reset
|
|
|
|
output clk; // main clock
|
|
|
|
output start; // start test (level)
|
|
|
|
|
|
|
|
input dut_active; // reset sequence is done
|
|
|
|
input stim_done; //stimulus is done
|
|
|
|
input test_done; //test is done
|
|
|
|
|
|
|
|
//signal declarations
|
2016-01-11 20:47:06 -05:00
|
|
|
reg nreset;
|
2015-11-03 19:56:27 -05:00
|
|
|
reg start;
|
2016-01-11 20:47:06 -05:00
|
|
|
reg clk=0;
|
2015-11-03 19:56:27 -05:00
|
|
|
|
2016-01-10 15:58:28 -05:00
|
|
|
//RESET
|
2015-11-03 14:16:50 -05:00
|
|
|
initial
|
|
|
|
begin
|
2016-01-11 20:47:06 -05:00
|
|
|
#(1)
|
|
|
|
nreset = 'b0;
|
2015-11-03 14:16:50 -05:00
|
|
|
#(CLK_PERIOD*20) //hold reset for 20 cycles
|
2016-01-10 15:58:28 -05:00
|
|
|
nreset = 'b1;
|
2015-11-03 14:16:50 -05:00
|
|
|
end
|
|
|
|
|
2016-01-10 15:58:28 -05:00
|
|
|
//START TEST
|
2015-11-03 14:16:50 -05:00
|
|
|
always @ (posedge clk or negedge nreset)
|
|
|
|
if(!nreset)
|
|
|
|
start = 1'b0;
|
|
|
|
else if(dut_active)
|
|
|
|
start = 1'b1;
|
|
|
|
|
2016-01-10 15:58:28 -05:00
|
|
|
//STOP SIMULATION
|
2015-11-03 19:56:27 -05:00
|
|
|
always @ (posedge clk)
|
|
|
|
if(stim_done & test_done)
|
|
|
|
#(TIMEOUT) $finish;
|
2016-01-10 15:58:28 -05:00
|
|
|
|
|
|
|
//CLOCK GENERATOR
|
2015-11-03 14:16:50 -05:00
|
|
|
always
|
|
|
|
#(CLK_PHASE) clk = ~clk;
|
|
|
|
|
2016-01-10 15:58:28 -05:00
|
|
|
//WAVEFORM DUMP
|
2015-11-03 14:16:50 -05:00
|
|
|
//Better solution?
|
2016-01-11 15:05:21 -05:00
|
|
|
`ifndef VERILATOR
|
2015-11-03 14:16:50 -05:00
|
|
|
initial
|
|
|
|
begin
|
2016-01-10 15:58:28 -05:00
|
|
|
$dumpfile("waveform.vcd");
|
2016-01-11 20:47:06 -05:00
|
|
|
$dumpvars(0, dv_top);
|
2015-11-03 14:16:50 -05:00
|
|
|
end
|
2016-01-11 15:05:21 -05:00
|
|
|
`endif
|
2016-01-10 15:58:28 -05:00
|
|
|
|
2015-11-03 19:56:27 -05:00
|
|
|
endmodule // dv_ctrl
|
2015-11-03 14:16:50 -05:00
|
|
|
|
|
|
|
|
2015-11-06 11:25:05 -05:00
|
|
|
|