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 3

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

powered by: WebSVN 2.1.0

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