OpenCores
URL https://opencores.org/ocsvn/cpu8080/cpu8080/trunk

Subversion Repositories cpu8080

[/] [cpu8080/] [trunk/] [project/] [cpu8080_tbw.tfw] - Rev 31

Go to most recent revision | Compare with Previous | Blame | View Log

////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 1995-2003 Xilinx, Inc.
// All Right Reserved.
////////////////////////////////////////////////////////////////////////////////
//   ____  ____ 
//  /   /\/   / 
// /___/  \  /    Vendor: Xilinx 
// \   \   \/     Version : 8.2.02i
//  \   \         Application : ISE
//  /   /         Filename : cpu8080_tbw.tfw
// /___/   /\     Timestamp : Sat Nov 18 22:47:07 2006
// \   \  /  \ 
//  \___\/\___\ 
//
//Command: 
//Design Name: cpu8080_tbw
//Device: Xilinx
//
`timescale 1ns/1ps

module cpu8080_tbw;
    wire [15:0] addr;
    reg [7:0] data$inout$reg = 8'b00000000;
    wire [7:0] data = data$inout$reg;
    wire readmem;
    wire writemem;
    wire readio;
    wire writeio;
    wire intr;
    wire inta;
    wire waitr;
    wire [2:0] r;
    wire [2:0] g;
    wire [2:0] b;
    wire hsync_n;
    wire vsync_n;
    reg ps2_clk = 1'b0;
    reg ps2_data = 1'b0;
    reg reset_n = 1'b0;
    reg clock = 1'b0;
    wire [7:0] diag;

    parameter PERIOD = 40;
    parameter real DUTY_CYCLE = 0.5;
    parameter OFFSET = 100;

    initial    // Clock process for clock
    begin
        #OFFSET;
        forever
        begin
            clock = 1'b0;
            #(PERIOD-(PERIOD*DUTY_CYCLE)) clock = 1'b1;
            #(PERIOD*DUTY_CYCLE);
        end
    end

    testbench UUT (
        .addr(addr),
        .data(data),
        .readmem(readmem),
        .writemem(writemem),
        .readio(readio),
        .writeio(writeio),
        .intr(intr),
        .inta(inta),
        .waitr(waitr),
        .r(r),
        .g(g),
        .b(b),
        .hsync_n(hsync_n),
        .vsync_n(vsync_n),
        .ps2_clk(ps2_clk),
        .ps2_data(ps2_data),
        .reset_n(reset_n),
        .clock(clock),
        .diag(diag));

        integer TX_ERROR = 0;
        
        initial begin  // Open the results file...
            #200040 // Final time:  200040 ns
            if (TX_ERROR == 0) begin
                $display("No errors or warnings.");
                end else begin
                    $display("%d errors found in simulation.", TX_ERROR);
                    end
                    $stop;
                end

                initial begin
                    // -------------  Current Time:  110ns
                    #110;
                    ps2_clk = 1'b1;
                    ps2_data = 1'b1;
                    reset_n = 1'b0;
                    data$inout$reg = 8'bZZZZZZZZ;
                    // -------------------------------------
                    // -------------  Current Time:  130ns
                    #20;
                    CHECK_intr(1'b0);
                    CHECK_diag(8'bXXX11X00);
                    // -------------------------------------
                    // -------------  Current Time:  270ns
                    #140;
                    reset_n = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  370ns
                    #100;
                    CHECK_b(3'bXXX);
                    CHECK_g(3'bXXX);
                    CHECK_r(3'bXXX);
                    // -------------------------------------
                    // -------------  Current Time:  390ns
                    #20;
                    ps2_data = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  410ns
                    #20;
                    CHECK_diag(8'bXXX01X00);
                    // -------------------------------------
                    // -------------  Current Time:  510ns
                    #100;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  530ns
                    #20;
                    CHECK_diag(8'bXXX00X00);
                    // -------------------------------------
                    // -------------  Current Time:  590ns
                    #60;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  650ns
                    #60;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  670ns
                    #20;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  690ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  830ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  850ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  990ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  1010ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  1150ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  1170ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  1310ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  1330ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  1470ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  1490ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  1630ns
                    #140;
                    ps2_clk = 1'b1;
                    ps2_data = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  1650ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  1790ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  1810ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  1950ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  1970ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  1990ns
                    #20;
                    ps2_data = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  2010ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  2110ns
                    #100;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  2130ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  2270ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  2290ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  2430ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  2450ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  2590ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  2610ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  2750ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  2770ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  2910ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  2930ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  3070ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  3090ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  3230ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  3250ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  3310ns
                    #60;
                    ps2_data = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  3330ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  3390ns
                    #60;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  3410ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  3550ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  3570ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  3590ns
                    #20;
                    ps2_data = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  3610ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  3710ns
                    #100;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  3730ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  3870ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  3890ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  5910ns
                    #2020;
                    ps2_data = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  5930ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  6070ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  6090ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  6230ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  6250ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  6390ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  6410ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  6550ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  6570ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  6630ns
                    #60;
                    ps2_data = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  6650ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  6710ns
                    #60;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  6730ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  6870ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  6890ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  6910ns
                    #20;
                    ps2_data = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  6930ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  7030ns
                    #100;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  7050ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  7190ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  7210ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  7350ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  7370ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  7510ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  7530ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  7550ns
                    #20;
                    ps2_data = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  7570ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  7670ns
                    #100;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  7690ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  7830ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  7850ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  7910ns
                    #60;
                    ps2_data = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  7930ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  7990ns
                    #60;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  8010ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  8150ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  8170ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  8310ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  8330ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  8470ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  8490ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  8630ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  8650ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  8790ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  8810ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  8950ns
                    #140;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  8970ns
                    #20;
                    CHECK_diag(8'bXXX00X01);
                    // -------------------------------------
                    // -------------  Current Time:  9110ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  9130ns
                    #20;
                    CHECK_diag(8'bXXX01X01);
                    // -------------------------------------
                    // -------------  Current Time:  9190ns
                    #60;
                    ps2_data = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  9210ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  9270ns
                    #60;
                    ps2_clk = 1'b0;
                    // -------------------------------------
                    // -------------  Current Time:  9290ns
                    #20;
                    CHECK_diag(8'bXXX10X01);
                    // -------------------------------------
                    // -------------  Current Time:  9430ns
                    #140;
                    ps2_clk = 1'b1;
                    // -------------------------------------
                    // -------------  Current Time:  9450ns
                    #20;
                    CHECK_diag(8'bXXX11X01);
                    // -------------------------------------
                    // -------------  Current Time:  31090ns
                    #21640;
                    CHECK_b(3'b000);
                    CHECK_g(3'b000);
                    CHECK_r(3'b000);
                    // -------------------------------------
                    // -------------  Current Time:  31890ns
                    #800;
                    CHECK_hsync_n(1'b0);
                    // -------------------------------------
                    // -------------  Current Time:  39890ns
                    #8000;
                    CHECK_hsync_n(1'b1);
                    // -------------------------------------
                    // -------------  Current Time:  43890ns
                    #4000;
                    CHECK_b(3'bXXX);
                    CHECK_g(3'bXXX);
                    CHECK_r(3'bXXX);
                    // -------------------------------------
                    // -------------  Current Time:  95090ns
                    #51200;
                    CHECK_b(3'b000);
                    CHECK_g(3'b000);
                    CHECK_r(3'b000);
                    // -------------------------------------
                    // -------------  Current Time:  95890ns
                    #800;
                    CHECK_hsync_n(1'b0);
                    // -------------------------------------
                    // -------------  Current Time:  103890ns
                    #8000;
                    CHECK_hsync_n(1'b1);
                    // -------------------------------------
                    // -------------  Current Time:  107890ns
                    #4000;
                    CHECK_b(3'bXXX);
                    CHECK_g(3'bXXX);
                    CHECK_r(3'bXXX);
                    // -------------------------------------
                    // -------------  Current Time:  159090ns
                    #51200;
                    CHECK_b(3'b000);
                    CHECK_g(3'b000);
                    CHECK_r(3'b000);
                    // -------------------------------------
                    // -------------  Current Time:  159890ns
                    #800;
                    CHECK_hsync_n(1'b0);
                    // -------------------------------------
                    // -------------  Current Time:  167890ns
                    #8000;
                    CHECK_hsync_n(1'b1);
                    // -------------------------------------
                    // -------------  Current Time:  171890ns
                    #4000;
                    CHECK_b(3'bXXX);
                    CHECK_g(3'bXXX);
                    CHECK_r(3'bXXX);
                    // -------------------------------------
                end

                task CHECK_addr;
                    input [15:0] NEXT_addr;

                    #0 begin
                        if (NEXT_addr !== addr) begin
                            $display("Error at time=%dns addr=%b, expected=%b", $time, addr, NEXT_addr);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_readmem;
                    input NEXT_readmem;

                    #0 begin
                        if (NEXT_readmem !== readmem) begin
                            $display("Error at time=%dns readmem=%b, expected=%b", $time, readmem, NEXT_readmem);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_writemem;
                    input NEXT_writemem;

                    #0 begin
                        if (NEXT_writemem !== writemem) begin
                            $display("Error at time=%dns writemem=%b, expected=%b", $time, writemem, NEXT_writemem);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_readio;
                    input NEXT_readio;

                    #0 begin
                        if (NEXT_readio !== readio) begin
                            $display("Error at time=%dns readio=%b, expected=%b", $time, readio, NEXT_readio);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_writeio;
                    input NEXT_writeio;

                    #0 begin
                        if (NEXT_writeio !== writeio) begin
                            $display("Error at time=%dns writeio=%b, expected=%b", $time, writeio, NEXT_writeio);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_intr;
                    input NEXT_intr;

                    #0 begin
                        if (NEXT_intr !== intr) begin
                            $display("Error at time=%dns intr=%b, expected=%b", $time, intr, NEXT_intr);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_inta;
                    input NEXT_inta;

                    #0 begin
                        if (NEXT_inta !== inta) begin
                            $display("Error at time=%dns inta=%b, expected=%b", $time, inta, NEXT_inta);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_waitr;
                    input NEXT_waitr;

                    #0 begin
                        if (NEXT_waitr !== waitr) begin
                            $display("Error at time=%dns waitr=%b, expected=%b", $time, waitr, NEXT_waitr);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_r;
                    input [2:0] NEXT_r;

                    #0 begin
                        if (NEXT_r !== r) begin
                            $display("Error at time=%dns r=%b, expected=%b", $time, r, NEXT_r);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_g;
                    input [2:0] NEXT_g;

                    #0 begin
                        if (NEXT_g !== g) begin
                            $display("Error at time=%dns g=%b, expected=%b", $time, g, NEXT_g);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_b;
                    input [2:0] NEXT_b;

                    #0 begin
                        if (NEXT_b !== b) begin
                            $display("Error at time=%dns b=%b, expected=%b", $time, b, NEXT_b);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_hsync_n;
                    input NEXT_hsync_n;

                    #0 begin
                        if (NEXT_hsync_n !== hsync_n) begin
                            $display("Error at time=%dns hsync_n=%b, expected=%b", $time, hsync_n, NEXT_hsync_n);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_vsync_n;
                    input NEXT_vsync_n;

                    #0 begin
                        if (NEXT_vsync_n !== vsync_n) begin
                            $display("Error at time=%dns vsync_n=%b, expected=%b", $time, vsync_n, NEXT_vsync_n);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask
                task CHECK_diag;
                    input [7:0] NEXT_diag;

                    #0 begin
                        if (NEXT_diag !== diag) begin
                            $display("Error at time=%dns diag=%b, expected=%b", $time, diag, NEXT_diag);
                            TX_ERROR = TX_ERROR + 1;
                        end
                    end
                endtask

            endmodule

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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