OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [control/] [test_reset.sv] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
//==============================================================
2
// Test reset circuit
3
//==============================================================
4
`timescale 100 ns/ 100 ns
5
 
6
module test_reset;
7
 
8
// ----------------- CLOCKS AND RESET -----------------
9
`define T #2
10
bit clk = 1;
11 8 gdevic
initial repeat (40) #1 clk = ~clk;
12 3 gdevic
 
13
// Specific to FPGA, some modules in the schematic need to be pre-initialized
14
reg fpga_reset = 1;
15
always_latch
16
    if (clk) fpga_reset <= 0;
17
 
18
//----------------------------------------------------------
19
// Input reset from the pin; state from the sequencer
20
//----------------------------------------------------------
21
logic reset_in = 0;
22
logic M1 = 0;
23
logic T2 = 0;
24
 
25
wire clrpc;            // Load 0 to PC
26 13 gdevic
wire hold_clk_wait;    // Hold clrpc
27 3 gdevic
wire nreset;           // Internal inverted reset signal
28
 
29 13 gdevic
assign hold_clk_wait = 0; // Will not test this case
30
 
31 3 gdevic
// ----------------- TEST -------------------
32
initial begin
33
    // Test normal reset sequence - 3 clocks long
34
    `T reset_in = 1;
35
    `T `T `T reset_in = 0;
36 8 gdevic
    `T assert(nreset==0);
37
    // Out of the reset for several more cycles
38
    // Check that the clrpc is set for the next 2 1/2 cycles (see waveform)
39
    `T assert(nreset==1 && clrpc==1);
40
    `T assert(nreset==1 && clrpc==1);
41
    `T assert(nreset==1 && clrpc==0);
42
    `T assert(nreset==1 && clrpc==0);
43
    `T assert(nreset==1 && clrpc==0);
44
 
45 3 gdevic
    // Test special reset sequence: a reset pin is briefly
46
    // asserted at M1/T1 and CLRPC should hold until the next
47
    // M1/T2
48
    `T reset_in = 1; M1=1;
49
    `T reset_in = 0; M1=1; T2=1;
50
    `T               M1=1; T2=0;
51
    `T `T
52
    `T assert(nreset==1 && clrpc==1);
53
    `T               M1=1; T2=1;
54
    `T               M1=1; T2=0;
55
    `T assert(nreset==1 && clrpc==0);
56
 
57
    `T $display("End of test");
58
end
59
 
60
//--------------------------------------------------------------
61
// Instantiate DUT
62
//--------------------------------------------------------------
63
 
64
resets reset_block ( .* );
65
 
66
endmodule
67
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.