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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [tbIso7816_3_Master.v] - Diff between revs 3 and 4

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 4
`timescale 1ns / 1ps
`timescale 1ns / 1ps
 
`default_nettype none
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Company: 
// Company: 
// Engineer:
// Engineer:
//
//
// Create Date:   22:16:42 01/10/2011
// Create Date:   22:16:42 01/10/2011
// Design Name:   Iso7816_3_Master
// Design Name:   Iso7816_3_Master
// Module Name:   tbIso7816_3_Master.v
// Module Name:   tbIso7816_3_Master.v
// Project Name:  Uart
// Project Name:  Uart
// Target Device:  
// Target Device:  
// Tool versions:  
// Tool versions:  
// Description: 
// Description: 
//
//
// Verilog Test Fixture created by ISE for module: Iso7816_3_Master
// Verilog Test Fixture created by ISE for module: Iso7816_3_Master
//
//
// Dependencies:
// Dependencies:
// 
// 
// Revision:
// Revision:
// Revision 0.01 - File Created
// Revision 0.01 - File Created
// Additional Comments:
// Additional Comments:
// 
// 
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
 
 
module tbIso7816_3_Master;
module tbIso7816_3_Master;
parameter CLK_PERIOD = 10;//should be %2
parameter CLK_PERIOD = 10;//should be %2
        // Inputs
        // Inputs
        reg nReset;
        reg nReset;
        reg clk;
        reg clk;
        reg [15:0] clkPerCycle;
        reg [15:0] clkPerCycle;
        reg startActivation;
        reg startActivation;
        reg startDeactivation;
        reg startDeactivation;
        reg [7:0] dataIn;
        reg [7:0] dataIn;
        reg nWeDataIn;
        reg nWeDataIn;
        reg [12:0] cyclePerEtu;
        reg [12:0] cyclePerEtu;
        reg nCsDataOut;
        reg nCsDataOut;
        reg nCsStatusOut;
        reg nCsStatusOut;
 
 
        // Outputs
        // Outputs
        wire [7:0] dataOut;
        wire [7:0] dataOut;
        wire [7:0] statusOut;
        wire [7:0] statusOut;
        wire isActivated;
        wire isActivated;
        wire useIndirectConvention;
        wire useIndirectConvention;
        wire tsError;
        wire tsError;
        wire tsReceived;
        wire tsReceived;
        wire atrIsEarly;
        wire atrIsEarly;
        wire atrIsLate;
        wire atrIsLate;
        wire isoClk;
        wire isoClk;
        wire isoReset;
        wire isoReset;
        wire isoVdd;
        wire isoVdd;
 
 
        // Bidirs
        // Bidirs
        wire isoSio;
        wire isoSio;
 
 
 
wire COM_statusOut=statusOut;
 
wire COM_clk=isoClk;
 
integer COM_errorCnt;
 
 
 
wire txRun,txPending, rxRun, rxStartBit, isTx, overrunErrorFlag, frameErrorFlag, bufferFull;
 
assign {txRun, txPending, rxRun, rxStartBit, isTx, overrunErrorFlag, frameErrorFlag, bufferFull} = statusOut;
 
 
 
`include "ComDriverTasks.v"
 
 
        // Instantiate the Unit Under Test (UUT)
        // Instantiate the Unit Under Test (UUT)
        Iso7816_3_Master uut (
        Iso7816_3_Master uut (
                .nReset(nReset),
                .nReset(nReset),
                .clk(clk),
                .clk(clk),
                .clkPerCycle(clkPerCycle),
                .clkPerCycle(clkPerCycle),
                .startActivation(startActivation),
                .startActivation(startActivation),
                .startDeactivation(startDeactivation),
                .startDeactivation(startDeactivation),
                .dataIn(dataIn),
                .dataIn(dataIn),
                .nWeDataIn(nWeDataIn),
                .nWeDataIn(nWeDataIn),
                .cyclePerEtu(cyclePerEtu),
                .cyclePerEtu(cyclePerEtu),
                .dataOut(dataOut),
                .dataOut(dataOut),
                .nCsDataOut(nCsDataOut),
                .nCsDataOut(nCsDataOut),
                .statusOut(statusOut),
                .statusOut(statusOut),
                .nCsStatusOut(nCsStatusOut),
                .nCsStatusOut(nCsStatusOut),
                .isActivated(isActivated),
                .isActivated(isActivated),
                .useIndirectConvention(useIndirectConvention),
                .useIndirectConvention(useIndirectConvention),
                .tsError(tsError),
                .tsError(tsError),
                .tsReceived(tsReceived),
                .tsReceived(tsReceived),
                .atrIsEarly(atrIsEarly),
                .atrIsEarly(atrIsEarly),
                .atrIsLate(atrIsLate),
                .atrIsLate(atrIsLate),
                .isoSio(isoSio),
                .isoSio(isoSio),
                .isoClk(isoClk),
                .isoClk(isoClk),
                .isoReset(isoReset),
                .isoReset(isoReset),
                .isoVdd(isoVdd)
                .isoVdd(isoVdd)
        );
        );
 
 
        DummyCard card(
        DummyCard card(
                .isoReset(isoReset),
                .isoReset(isoReset),
                .isoClk(isoClk),
                .isoClk(isoClk),
                .isoVdd(isoVdd),
                .isoVdd(isoVdd),
                .isoSio(isoSio)
                .isoSio(isoSio)
        );
        );
 
 
        integer tbErrorCnt;
        integer tbErrorCnt;
        initial begin
        initial begin
                // Initialize Inputs
                // Initialize Inputs
 
                COM_errorCnt=0;
                nReset = 0;
                nReset = 0;
                clk = 0;
                clk = 0;
                clkPerCycle = 0;
                clkPerCycle = 0;
                startActivation = 0;
                startActivation = 0;
                startDeactivation = 0;
                startDeactivation = 0;
                dataIn = 0;
                dataIn = 0;
                nWeDataIn = 0;
                nWeDataIn = 1'b1;
                cyclePerEtu = 0;
                cyclePerEtu = 0;
                nCsDataOut = 0;
                nCsDataOut = 1'b1;
                nCsStatusOut = 0;
                nCsStatusOut = 1'b1;
 
 
                // Wait 100 ns for global reset to finish
                // Wait 100 ns for global reset to finish
                #100;
                #100;
      nReset = 1;
      nReset = 1;
                // Add stimulus here
                // Add stimulus here
                #100
                #100
                startActivation = 1'b1;
                startActivation = 1'b1;
                wait(isActivated);
                wait(isActivated);
                wait(atrIsEarly|atrIsLate);
                wait(tsReceived);
 
                if(atrIsEarly) begin
 
                        $display("ERROR: ATR is early");
 
                        tbErrorCnt=tbErrorCnt+1;
 
                end
 
                if(atrIsLate) begin
 
                        $display("ERROR: ATR is late");
 
                        tbErrorCnt=tbErrorCnt+1;
 
                end
 
                @(posedge clk);
 
                while((txRun===1'b1)||(rxRun===1'b1)||(rxStartBit===1'b1)) begin
 
                        while((txRun===1'b1)||(rxRun===1'b1)||(rxStartBit===1'b1)) begin
 
                                @(posedge clk);
 
                        end
 
                        @(posedge clk);
 
                end
 
                $display("Two cycle pause in communication detected, stop simulation");
                #200
                #200
                $finish;
                $finish;
        end
        end
 
        //T=0 tpdu stimuli
 
        initial begin
 
                receiveAndCheckByte(8'h3B);
 
                receiveAndCheckByte(8'h00);
 
                //sendBytes("000C000001");//would be handy, TODO
 
                sendByte(8'h00);
 
                sendByte(8'h0C);
 
                sendByte(8'h00);
 
                sendByte(8'h00);
 
                sendByte(8'h01);
 
                receiveAndCheckByte(8'h0C);
 
                //sendBytes("55");
 
                sendByte(8'h55);
 
                receiveAndCheckByte(8'h90);
 
                receiveAndCheckByte(8'h00);
 
        end
        initial begin
        initial begin
                // timeout
                // timeout
                #10000;
                #100000;
      tbErrorCnt=tbErrorCnt+1;
      tbErrorCnt=tbErrorCnt+1;
      $display("ERROR: timeout expired");
      $display("ERROR: timeout expired");
      #10;
      #10;
                $finish;
                $finish;
        end
        end
        always
        always
                #(CLK_PERIOD/2) clk =  ! clk;
                #(CLK_PERIOD/2) clk =  ! clk;
endmodule
endmodule
 
 
 
 

powered by: WebSVN 2.1.0

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