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

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [bus/] [test_bus.sv] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
//==============================================================
2
// Test address latch and increment block
3
//==============================================================
4
`timescale 1us/ 100 ns
5
 
6
module test_bus;
7
 
8
// ----------------- CLOCKS AND RESET -----------------
9
// Define one full T-clock cycle delay
10
`define T #2
11
bit clk = 1;
12 8 gdevic
initial repeat (26) #1 clk = ~clk;
13
reg nreset;
14 3 gdevic
 
15
// ----------------------------------------------------
16
// Bi-directional bus that can also be tri-stated
17
reg  [15:0] abusw;          // Drive it using this bus
18
wire [15:0] abus;           // Read it using this bus
19
wire [15:0] address;        // Final address ouput
20
 
21
// ----------------- INPUT CONTROL -----------------
22
reg ctl_al_we;              // Write enable to address latch
23
reg ctl_bus_inc_oe;         // Write incrementer onto the internal data bus
24
reg ctl_apin_mux;           // Selects mux1
25
reg ctl_apin_mux2;          // Selects mux2
26
 
27
// ----------------- INC/DEC -----------------
28
reg ctl_inc_dec;            // Perform decrement (1) or increment (0)
29
reg ctl_inc_limit6;         // Limit increment to 6 bits (for incrementing IR)
30
reg ctl_inc_cy;             // Address increment, carry in value (+/-1 or 0)
31 8 gdevic
reg clrpc;                  // Force zero (to clear PC/IR)
32 3 gdevic
 
33
// ----------------- OUTPUT/STATUS -----------------
34
wire address_is_1;          // Signals when the final address is 1
35
 
36
// ----------------- TEST -------------------
37
`define CHECK(arg) \
38
   assert(address==arg);
39
 
40
initial begin
41 8 gdevic
    nreset = 0;
42 3 gdevic
    abusw = 'z;
43
    ctl_al_we = 0;
44
    ctl_bus_inc_oe = 0;
45
    ctl_inc_dec = 0;
46
    ctl_inc_limit6 = 0;
47
    ctl_inc_cy = 0;
48 8 gdevic
    clrpc = 0;
49 3 gdevic
    ctl_apin_mux = 0;
50
    ctl_apin_mux2 = 0;
51
 
52
    //------------------------------------------------------------
53 8 gdevic
    `T  nreset = 1;
54
 
55
    //------------------------------------------------------------
56 3 gdevic
    // Perform a simple increment and decrement
57
    `T  abusw = 16'h1234;
58
        ctl_al_we = 1;          // Write value to the latch
59
        ctl_apin_mux = 1;       // Output incrementer to the address bus
60
        ctl_inc_cy = 1;         // +1  show "1235"
61
    `T `CHECK(16'h1235);
62
        ctl_inc_dec = 1;        // -1  show "1233"
63
    `T `CHECK(16'h1233);
64
    // ...through overflow
65
        abusw = 16'hffff;
66
        ctl_inc_dec = 0;
67
        ctl_inc_cy = 1;         // +1  show "0"
68
    `T `CHECK(16'h0000);
69
        ctl_inc_dec = 1;        // -1  show "FFFE"
70
    `T `CHECK(16'hFFFE);
71
        abusw = 16'h0;
72
        ctl_inc_dec = 0;
73
        ctl_inc_cy = 1;         // +1  show "1"
74
    `T `CHECK(16'h0001);
75
        ctl_inc_dec = 1;        // -1  show "FFFF"
76
    `T `CHECK(16'hFFFF);
77
        ctl_inc_cy = 0;         // show "0000"
78
    `T `CHECK(16'h0000);
79
        ctl_inc_dec = 0;        // show "0000"
80
 
81
    //------------------------------------------------------------
82
    // Test the address latch and the mux
83
    `T  abusw = 16'hAA50;
84
        ctl_al_we = 1;          // Write AA55 to the latch
85
        ctl_inc_cy = 1;
86
    `T  ctl_al_we = 0;          // show "AA51"
87
    `T `CHECK(16'hAA51);
88
        ctl_apin_mux = 0;
89
        ctl_apin_mux2 = 1;
90
 
91
    //------------------------------------------------------------
92
    // Test the tri-state db
93
    `T  abusw = 'z;
94
        ctl_bus_inc_oe = 1;     // Output latched value (AA50)
95
    `T `CHECK(16'hAA50);
96
 
97
    `T  $display("End of test");
98
end
99
 
100
// Drive 3-state bidirectional bus with these statements
101
assign abus = abusw;
102
 
103
//--------------------------------------------------------------
104
// Instantiate address latch block
105
//--------------------------------------------------------------
106
 
107
address_latch address_latch_( .* );
108
 
109
endmodule

powered by: WebSVN 2.1.0

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