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 | Show entire file | Details | Blame | View Log

Rev 3 Rev 4
Line 1... Line 1...
`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
Line 50... Line 50...
        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),
Line 82... Line 91...
                .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

powered by: WebSVN 2.1.0

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