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

Subversion Repositories mcs-4

[/] [mcs-4/] [trunk/] [rtl/] [verilog/] [i4003/] [i4003_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 i40031 Shift Register testbench
6
//
7
// This testbench instantiates two i4003 modules, resets them, and
8
// shifts a single '1' bit through them.
9
//
10
// This file is part of the MCS-4 project hosted at OpenCores:
11
//      http://www.opencores.org/cores/mcs-4/
12
//
13
// Copyright © 2021 by Reece Pollack <rrpollack@opencores.org>
14
//
15
// These materials are provided under the Creative Commons
16
// "Attribution-NonCommercial-ShareAlike" (CC BY-NC-SA) Public License.
17
// They are NOT "public domain", and are protected by copyright.
18
//
19
// This work based on materials provided by Intel Corporation and
20
// others under the same license. See the file doc/License for
21
// details of this license.
22
//
23
////////////////////////////////////////////////////////////////////////
24
 
25
module i4003_tb;
26
 
27
    // Inputs
28
    reg sysclk = 1'b0;
29
    reg cp;
30
    reg serial_in;
31
    reg enable;
32
 
33
    // Interconnection
34
    wire serial_chain;
35
 
36
    // Outputs
37
    wire [19:0] parallel_out;
38
    wire serial_out;
39
 
40
    // Instantiate the Unit Under Test (UUT)
41
    i4003 #(
42
        .SYSCLK_TCY     (50)
43
        ) uut1 (
44
        .sysclk         (sysclk),
45
        .cp             (cp),
46
        .serial_in      (serial_in),
47
        .enable         (enable),
48
        .parallel_out   (parallel_out[9:0]),
49
        .serial_out     (serial_chain)
50
    );
51
 
52
    // Instantiate the Unit Under Test (UUT)
53
    i4003 #(
54
        .SYSCLK_TCY     (50)
55
        ) uut2 (
56
        .sysclk         (sysclk),
57
        .cp             (cp),
58
        .serial_in      (serial_chain),
59
        .enable         (enable),
60
        .parallel_out   (parallel_out[19:10]),
61
        .serial_out     (serial_out)
62
    );
63
 
64
    always begin
65
        #25 sysclk = ~sysclk;
66
    end
67
 
68
    integer i;
69
 
70
    initial begin
71
        // Initialize Inputs
72
        cp = 1'b0;
73
        serial_in = 1'b0;
74
        enable = 1'b0;
75
 
76
        // Wait 100 ns for global reset to finish
77
        #100;
78
        enable = 1'b1;
79
 
80
        // Shift a 1 down the registers
81
        shift(1'b1);
82
        for (i = 0; i < 21; i = i + 1)
83
            shift(1'b0);
84
 
85
        $finish;
86
    end
87
 
88
    task shift(
89
        input si
90
    );
91
        begin
92
            cp = 1'b1;
93
            #250;
94
            serial_in = si;
95
            #2750;
96
            serial_in = 1'b0;
97
            #3000;
98
            cp = 1'b0;
99
            #6000;
100
        end
101
    endtask
102
 
103
endmodule
104
 

powered by: WebSVN 2.1.0

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