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

Subversion Repositories light8080

[/] [light8080/] [trunk/] [verilog/] [bench/] [tb_l80soc.v] - Diff between revs 65 and 66

Only display areas with differences | Details | Blame | View Log

Rev 65 Rev 66
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//      Project:        light8080 SOC           WiCores Solutions 
//      Project:        light8080 SOC           WiCores Solutions 
// 
// 
//      Filename:       tb_l80soc.v                     (February 04, 2012)
//      Filename:       tb_l80soc.v                     (February 04, 2012)
// 
// 
//      Author(s):      Moti Litochevski 
//      Author(s):      Moti Litochevski 
// 
// 
//      Description:
//      Description:
//              This file implements the light8080 SOC test bench. 
//              This file implements the light8080 SOC test bench. 
//
//
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//
//
//      To Do: 
//      To Do: 
//      - 
//      - 
// 
// 
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// 
// 
//      Copyright (C) 2012 Moti Litochevski 
//      Copyright (C) 2012 Moti Litochevski 
// 
// 
//      This source file may be used and distributed without restriction provided that this 
//      This source file may be used and distributed without restriction provided that this 
//      copyright statement is not removed from the file and that any derivative work 
//      copyright statement is not removed from the file and that any derivative work 
//      contains the original copyright notice and the associated disclaimer.
//      contains the original copyright notice and the associated disclaimer.
//
//
//      THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 
//      THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 
//      INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND 
//      INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND 
//      FITNESS FOR A PARTICULAR PURPOSE. 
//      FITNESS FOR A PARTICULAR PURPOSE. 
// 
// 
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
 
 
`timescale 1ns / 1ns
`timescale 1ns / 1ns
 
 
module test;
module test;
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// test bench global defines 
// test bench global defines 
// the following define selects between CPU instruction trace and uart transmitted bytes 
// the following define selects between CPU instruction trace and uart transmitted bytes 
//`define CPU_TRACE             1
//`define CPU_TRACE             1
 
 
 
 
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// internal signals 
// internal signals 
reg clock;                              // global clock 
reg clock;                              // global clock 
reg reset;                              // global reset 
reg reset;                              // global reset 
 
 
// UUT interfaces 
// UUT interfaces 
wire rxd, txd;
wire rxd, txd;
wire [7:0] p1dio, p2dio;
wire [7:0] p1dio, p2dio;
 
wire [3:0] extint;
 
reg sp1dio0;
 
 
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// test bench implementation 
// test bench implementation 
// global signals generation  
// global signals generation  
initial
initial
begin
begin
        clock = 0;
        clock = 0;
        reset = 1;
        reset = 1;
        #100 reset = 0;
        #100 reset = 0;
end
end
 
 
// clock generator - 50MHz clock 
// clock generator - 50MHz clock 
always
always
begin
begin
        #10 clock = 0;
        #10 clock = 0;
        #10 clock = 1;
        #10 clock = 1;
end
end
 
 
// test bench dump variables 
// test bench dump variables 
initial
initial
begin
begin
        $display("");
        $display("");
        $display("  light8080 SOC simulation");
        $display("  light8080 SOC simulation");
        $display("--------------------------------------");
        $display("--------------------------------------");
        $dumpfile("test.vcd");
        $dumpfile("test.vcd");
        $dumpvars(0, test);
        $dumpvars(0, test);
        $display("");
        $display("");
end
end
 
 
// simulation end condition 
// simulation end condition 
always @ (posedge clock)
always @ (posedge clock)
begin
begin
        if (dut.cpu_io && (dut.cpu_addr[7:0] == 8'hff))
        if (dut.cpu_io && (dut.cpu_addr[7:0] == 8'hff))
        begin
        begin
                $display("");
                $display("");
                $display("Simulation ended by software");
                $display("Simulation ended by software");
                $finish;
                $finish;
        end
        end
end
end
 
 
//------------------------------------------------------------------
//------------------------------------------------------------------
// device under test 
// device under test 
l80soc dut
l80soc dut
(
(
        .clock(clock),
        .clock(clock),
        .reset(reset),
        .reset(reset),
        .txd(txd),
        .txd(txd),
        .rxd(rxd),
        .rxd(rxd),
        .p1dio(p1dio),
        .p1dio(p1dio),
        .p2dio(p2dio)
        .p2dio(p2dio),
 
        .extint(extint)
);
);
 
 
//------------------------------------------------------------------
//------------------------------------------------------------------
// uart receive is not used in this test becnch 
// uart receive is not used in this test becnch 
assign rxd = 1'b1;
assign rxd = 1'b1;
 
 
 
// external interrupt 0 is connected to the p1dio[0] rising edge 
 
assign extint[3:1] = 3'b0;
 
assign extint[0] = ((sp1dio0 == 1'b0) && (p1dio[0] == 1'b1)) ? 1'b1 : 1'b0;
 
 
 
// p1dio[0] rising edge detection 
 
always @ (posedge reset or posedge clock)
 
begin
 
        if (reset)
 
                sp1dio0 <= 1'b0;
 
        else if (p1dio[0] == 1'b1)
 
                sp1dio0 <= 1'b1;
 
        else
 
                sp1dio0 <= 1'b0;
 
end
 
 
 
//------------------------------------------------------------------
 
// test bench output log selection - either simple CPU trace or UART 
 
// transmit port log 
`ifdef CPU_TRACE
`ifdef CPU_TRACE
// display executed instructions 
// display executed instructions 
reg [15:0] saddr;
reg [15:0] saddr;
reg scpu_rd;
reg scpu_rd;
always @ (posedge clock)
always @ (posedge clock)
begin
begin
        if (dut.cpu.uc_decode)
        if (dut.cpu.uc_decode)
        begin
        begin
                $display("");
                $display("");
                $write("%x : %x", saddr, dut.cpu.data_in);
                $write("%x : %x", saddr, dut.cpu.data_in);
        end
        end
        else if (scpu_rd)
        else if (scpu_rd)
                $write("%x", dut.cpu.data_in);
                $write("%x", dut.cpu.data_in);
 
 
        // sampled address bus and read pulse 
        // sampled address bus and read pulse 
        saddr <= dut.cpu.addr_out;
        saddr <= dut.cpu.addr_out;
        scpu_rd <= dut.cpu.rd;
        scpu_rd <= dut.cpu.rd;
end
end
`else
`else
// display characters transmitted to the uart 
// display characters transmitted to the uart 
initial
initial
begin
begin
        $display("Characters sent to the UART:");
        $display("Characters sent to the UART:");
end
end
 
 
// check uart write pulse 
// check uart write pulse 
always @ (posedge clock)
always @ (posedge clock)
begin
begin
        if (dut.txValid)
        if (dut.txValid)
                $write("%c", dut.cpu_dout);
                $write("%c", dut.cpu_dout);
end
end
`endif
`endif
endmodule
endmodule
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//                                              Th.. Th.. Th.. Thats all folks !!!
//                                              Th.. Th.. Th.. Thats all folks !!!
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
 
 

powered by: WebSVN 2.1.0

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