OpenCores
URL https://opencores.org/ocsvn/mcs-4/mcs-4/trunk

Subversion Repositories mcs-4

[/] [mcs-4/] [trunk/] [rtl/] [verilog/] [i4004/] [timing_io_tb.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 rrpollack
`timescale 1ns / 1ps
2
`default_nettype none
3
////////////////////////////////////////////////////////////////////////
4
//
5
// MCS-4 i4004 CPU Timing and I/O Interface testbench
6
//
7
// This testbench instantiates a timing_io module, and drives it
8
// with the basic 8-subcycle (A1, A2, A3, M1, M2, X1, X2, X3)
9
// instruction cycle to allow confirmation of the correct direction
10
// of transfer through the system bus interface.
11
//
12
// This file is part of the MCS-4 project hosted at OpenCores:
13
//      http://www.opencores.org/cores/mcs-4/
14
//
15
// Copyright © 2021 by Reece Pollack <rrpollack@opencores.org>
16
//
17
// These materials are provided under the Creative Commons
18
// "Attribution-NonCommercial-ShareAlike" (CC BY-NC-SA) Public License.
19
// They are NOT "public domain", and are protected by copyright.
20
//
21
// This work based on materials provided by Intel Corporation and
22
// others under the same license. See the file doc/License for
23
// details of this license.
24
//
25
////////////////////////////////////////////////////////////////////////
26
 
27
module timing_io_tb;
28
 
29
    localparam SYSCLK_TCY    = 20;   // sysclk period in nanoseconds
30
 
31
    // Inputs
32
    reg sysclk;
33
    wire clk1_pad;
34
    wire clk2_pad;
35
    reg poc_pad = 1'b0;
36
    reg test_pad = 1'b0;
37
    reg ior = 1'b0;
38
    reg cmrom = 1'b0;
39
    reg cmram0 = 1'b0;
40
    reg cmram1 = 1'b0;
41
    reg cmram2 = 1'b0;
42
    reg cmram3 = 1'b0;
43
 
44
    // Outputs
45
    wire clk1;
46
    wire clk2;
47
    wire a12;
48
    wire a22;
49
    wire a32;
50
    wire m12;
51
    wire m22;
52
    wire x12;
53
    wire x22;
54
    wire x32;
55
    wire sync;
56
    wire gate;
57
    wire poc;
58
    wire n0432;
59
    wire cmrom_pad;
60
    wire cmram0_pad;
61
    wire cmram1_pad;
62
    wire cmram2_pad;
63
    wire cmram3_pad;
64
 
65
    // Bidirs
66
    wire [3:0] data;
67
    wire [3:0] data_pad;
68
 
69
    // Instantiate the Unit Under Test (UUT)
70
    timing_io uut (
71
        .sysclk(sysclk),
72
        .clk1_pad(clk1_pad),
73
        .clk2_pad(clk2_pad),
74
        .poc_pad(poc_pad),
75
        .ior(ior),
76
        .clk1(clk1),
77
        .clk2(clk2),
78
        .a12(a12),
79
        .a22(a22),
80
        .a32(a32),
81
        .m12(m12),
82
        .m22(m22),
83
        .x12(x12),
84
        .x22(x22),
85
        .x32(x32),
86
        .sync(sync),
87
        .gate(gate),
88
        .poc(poc),
89
        .data(data),
90
        .data_pad(data_pad),
91
        .test_pad(test_pad),
92
        .n0432(n0432),
93
        .cmrom(cmrom),
94
        .cmrom_pad(cmrom_pad),
95
        .cmram0(cmram0),
96
        .cmram0_pad(cmram0_pad),
97
        .cmram1(cmram1),
98
        .cmram1_pad(cmram1_pad),
99
        .cmram2(cmram2),
100
        .cmram2_pad(cmram2_pad),
101
        .cmram3(cmram3),
102
        .cmram3_pad(cmram3_pad)
103
    );
104
 
105
    // Instantiate the 2-phase clock generator
106
    clockgen #(
107
        .SYSCLK_TCY(SYSCLK_TCY)
108
    ) clockgen (
109
        .sysclk(sysclk),
110
        .clk1(clk1_pad),
111
        .clk2(clk2_pad)
112
    );
113
 
114
    always begin
115
        sysclk = 1'b0;
116
        #(SYSCLK_TCY / 2);
117
        sysclk = 1'b1;
118
        #(SYSCLK_TCY / 2);
119
    end
120
 
121
    reg [3:0] data_out;
122
    always @* begin
123
        if (poc)
124
            data_out = 4'bzzzz;
125
        else begin
126
            (* PARALLEL_CASE *)
127
            case (1'b1)
128
            a12:        data_out = 4'b0001;
129
            a22:        data_out = 4'b0010;
130
            a32:        data_out = 4'b0011;
131
            m12:        data_out = 4'bzzzz;
132
            m22:        data_out = 4'bzzzz;
133
            x12:        data_out = 4'b0110;
134
            x22:        data_out = 4'b0111;
135
            x32:        data_out = 4'b1000;
136
            default:    data_out = 4'bxxxx;
137
            endcase
138
        end
139
    end
140
    assign data = data_out;
141
    assign data_pad = 4'bzzzz;
142
 
143
    initial begin
144
        // Initialize Inputs
145
        poc_pad = 1'b1;
146
 
147
        // Wait 10000 ns for global reset to finish
148
        #10000;
149
 
150
        // Add stimulus here
151
        @(posedge m12);
152
        poc_pad = 1'b0;
153
    end
154
 
155
endmodule
156
 

powered by: WebSVN 2.1.0

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