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

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [bus/] [test_pins.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 and data pins blocks
3
//==============================================================
4
`timescale 1us/ 100 ns
5
 
6
module test_pins;
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
// ------------------------ ADDRESS PINS ---------------------
15
logic [15:0] ab;            // Internal address bus
16
logic ctl_ab_we;            // Write enable to address pin latch
17
logic pin_control_oe;        // Output enable to address pins; otherwise tri-stated
18
wire [15:0] apin;           // Output address bus to address pins
19
 
20
// ------------------------ DATA PINS ------------------------
21
logic ctl_db_we;            // Write enable to data pin output latch
22
logic ctl_db_oe;            // Output enable to internal data bus
23
logic ctl_db_pin_re;        // Read from the data pin into the latch
24
logic ctl_db_pin_oe;        // Output enable to data pins; otherwise tri-stated
25
logic ctl_pin_oe;
26
 
27
// ----------------------------------------------------
28
// Bidirectional internal data bus
29
logic  [7:0] db_w;          // Drive it using this bus
30
wire [7:0] db;              // Read it using this bus
31
assign db = db_w;           // Drive 3-state bidirectional bus
32
always_comb                 // Output to pin bus only when our
33
begin                       // test is not driving it
34
    if (db_w==='z)
35
        ctl_db_oe = 1;
36
    else
37
        ctl_db_oe = 0;
38
end
39
 
40
// ----------------------------------------------------
41
// Bidirectional external data pins
42
logic  [7:0] dpin_w;        // Drive it using this bus
43
wire [7:0] dpin;            // Read it using this bus
44
assign dpin = dpin_w;       // Drive 3-state bidirectional
45
always_comb                 // Output to pin bus only when our
46
begin                       // test is not driving it
47
    if (dpin_w==='z)
48
        ctl_db_pin_oe = 1;
49
    else
50
        ctl_db_pin_oe = 0;
51
end
52
 
53
// ----------------- TEST -------------------
54
`define CHECKA(arg) \
55
   assert(apin===arg);
56
 
57
`define CHECKD(arg) \
58
   assert(dpin===arg);
59
 
60
initial begin
61
    ab = 16'h0;
62
    ctl_ab_we = 0;
63
    pin_control_oe = 0;
64
    db_w = 'z;
65
    dpin_w = 'z;
66
    ctl_db_we = 0;
67
 
68
    //------------------------------------------------------------
69
    // Test the address pin logic
70
    `T  ab = 16'hAA55;      // Latch a value and output it
71
        ctl_ab_we = 1;
72
        pin_control_oe = 1;
73
    `T  ctl_ab_we = 0;
74
    `T `CHECKA(16'hAA55);
75
        pin_control_oe = 0;
76
        ab = 16'h1234;      // Should not affect
77
    `T  pin_control_oe = 1;  // Toggle output on and off
78
    `T `CHECKA(16'hAA55);
79
        pin_control_oe = 0;
80
    `T `CHECKA(16'hz);
81
 
82
    //------------------------------------------------------------
83
    // Test the data pin logic
84
    `T  dpin_w = 8'hAA;     // Load and latch a value
85
        ctl_db_pin_re = 1;  // Read into the latch
86
 
87
    `T  dpin_w = 'z;
88
        db_w = 8'h55;
89
        ctl_db_pin_re = 0;
90
        ctl_db_we = 1;
91
       `CHECKD(8'hAA);
92
    `T  db_w = 'z;
93
 
94
    `T $display("End of test");
95
end
96
 
97
//--------------------------------------------------------------
98
// Instantiate bus block and assign identical nets and variables
99
//--------------------------------------------------------------
100
 
101
address_pins address_pins_inst( .*, .bus_ab_pin_we(ctl_ab_we), .address(ab[15:0]), .abus(apin[15:0]) );
102
 
103
data_pins data_pins_inst( .*, .bus_db_oe(ctl_db_pin_oe), .ctl_bus_db_we(ctl_db_we), .bus_db_pin_oe(ctl_db_pin_oe), .bus_db_pin_re(ctl_db_pin_re), .D(dpin[7:0]) );
104
 
105
endmodule

powered by: WebSVN 2.1.0

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