1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-17 20:02:53 +08:00
oh/common/dv/dv_ctrl.v

65 lines
1.2 KiB
Coq
Raw Normal View History

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;
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
reg nreset;
reg start;
reg clk=0;
2016-01-10 15:58:28 -05:00
//RESET
2015-11-03 14:16:50 -05:00
initial
begin
#(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
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");
$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
endmodule // dv_ctrl
2015-11-03 14:16:50 -05:00
2015-11-06 11:25:05 -05:00