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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [iso7816_3_t0_analyzer.v] - Diff between revs 17 and 18

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 17 Rev 18
Line 1... Line 1...
/*
/*
Author: Sebastien Riou (acapola)
Author: Sebastien Riou (acapola)
Creation date: 22:22:43 01/10/2011
Creation date: 22:22:43 01/10/2011
 
 
$LastChangedDate: 2011-02-18 15:23:07 +0100 (Fri, 18 Feb 2011) $
$LastChangedDate: 2011-03-07 14:17:52 +0100 (Mon, 07 Mar 2011) $
$LastChangedBy: acapola $
$LastChangedBy: acapola $
$LastChangedRevision: 17 $
$LastChangedRevision: 18 $
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/iso7816_3_t0_analyzer.v $
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/iso7816_3_t0_analyzer.v $
 
 
This file is under the BSD licence:
This file is under the BSD licence:
Copyright (c) 2011, Sebastien Riou
Copyright (c) 2011, Sebastien Riou
 
 
Line 96... Line 96...
//integer COM_errorCnt;
//integer COM_errorCnt;
//wire txPending=1'b0;
//wire txPending=1'b0;
//wire txRun=1'b0;
//wire txRun=1'b0;
 
 
wire rxRun, rxStartBit, overrunErrorFlag, frameErrorFlag, bufferFull;
wire rxRun, rxStartBit, overrunErrorFlag, frameErrorFlag, bufferFull;
assign overrunErrorFlag = overrunError;
//assign overrunErrorFlag = overrunError;
assign frameErrorFlag = frameError;
assign frameErrorFlag = frameError;
 
 
wire [7:0] rxData;
wire [7:0] rxData;
reg ackFlags;
reg ackFlags;
 
 
Line 119... Line 119...
 
 
always @(*) comOnGoing = rxRun|rxStartBit;
always @(*) comOnGoing = rxRun|rxStartBit;
 
 
always @(posedge clk, negedge rxCore_nReset) begin
always @(posedge clk, negedge rxCore_nReset) begin
        if(~rxCore_nReset) begin
        if(~rxCore_nReset) begin
                safeClocksPerBit<=clocksPerBit;
                safeClocksPerBit<={CLOCK_PER_BIT_WIDTH{1'b0}};
        end else if(endOfRx|~comOnGoing) begin
        end else if(endOfRx|~comOnGoing) begin
                safeClocksPerBit<=clocksPerBit;
                safeClocksPerBit<=clocksPerBit;
        end
        end
end
end
 
 
Line 219... Line 219...
        end else if((32'b1==bytesCnt) & tsReceived) begin
        end else if((32'b1==bytesCnt) & tsReceived) begin
                lastByte<=ts;
                lastByte<=ts;
        end
        end
end
end
reg ppsValidSoFar;
reg ppsValidSoFar;
reg ppsAccepted;
//reg ppsAccepted;
wire ppsDataMatch = (tpduHeader[(CLA_I-(tempBytesCnt*8))+:8]==dataOut);
wire ppsDataMatch = (tpduHeader[(CLA_I-(tempBytesCnt*8))+:8]==dataOut);
wire [3:0] earlyAtrK = (4'h0==tdiCnt) ? dataOut[3:0] : atrK;
wire [3:0] earlyAtrK = (4'h0==tdiCnt) ? dataOut[3:0] : atrK;
always @(posedge isoClk, negedge rxCore_nReset) begin
always @(posedge isoClk, negedge rxCore_nReset) begin
        if(~rxCore_nReset) begin
        if(~rxCore_nReset) begin
                ppsValidSoFar<=1'b0;
                ppsValidSoFar<=1'b0;
                ppsAccepted<=1'b0;
                //ppsAccepted<=1'b0;
                fiCode<=4'b0001;
                fiCode<=4'b0001;
                diCode<=4'b0001;
                diCode<=4'b0001;
                useT0<=1'b1;
                useT0<=1'b1;
                useT1<=1'b0;
                useT1<=1'b0;
                useT15<=1'b0;
                useT15<=1'b0;
Line 251... Line 251...
                                                if(tempBytesCnt+1==nIfBytes) begin //TDi bytes
                                                if(tempBytesCnt+1==nIfBytes) begin //TDi bytes
                                                        if(4'h0==tdiCnt) begin//this is T0
                                                        if(4'h0==tdiCnt) begin//this is T0
                                                                atrK <= dataOut[3:0];
                                                                atrK <= dataOut[3:0];
                                                        end
                                                        end
                                                        tempBytesCnt <= 2'h0;
                                                        tempBytesCnt <= 2'h0;
                                                        tdiStruct <= {tdiCnt+1,dataOut};
                                                        tdiStruct <= {tdiCnt+1'b1,dataOut};
                                                        if(12'h0=={dataOut,atrK}) begin
                                                        if(12'h0=={dataOut,atrK}) begin
                                                                atrCompleted <= 1'b1;
                                                                atrCompleted <= 1'b1;
                                                                {waitCardTx,waitTermTx}<=2'b01;
                                                                {waitCardTx,waitTermTx}<=2'b01;
                                                        end
                                                        end
                                                        if((1'b0==tdiStruct[7]) |//we just received the last interface byte
                                                        if((1'b0==tdiStruct[7]) |//we just received the last interface byte
Line 266... Line 266...
                                                                fsmState <= ATR_TDI;
                                                                fsmState <= ATR_TDI;
                                                        end
                                                        end
 
 
                                                end else begin //TA, TB or TC bytes
                                                end else begin //TA, TB or TC bytes
                                                        //TODO: get relevant info
                                                        //TODO: get relevant info
                                                        tempBytesCnt <= tempBytesCnt+1;
                                                        tempBytesCnt <= tempBytesCnt+1'b1;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
                                ATR_HISTORICAL: begin
                                ATR_HISTORICAL: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
Line 282... Line 282...
                                                                atrCompleted <= 1'b1;
                                                                atrCompleted <= 1'b1;
                                                                {waitCardTx,waitTermTx}<=2'b10;
                                                                {waitCardTx,waitTermTx}<=2'b10;
                                                                fsmState <= T0_HEADER;
                                                                fsmState <= T0_HEADER;
                                                        end
                                                        end
                                                end else begin
                                                end else begin
                                                        tempBytesCnt <= tempBytesCnt+1;
                                                        tempBytesCnt <= tempBytesCnt+1'b1;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
                                ATR_TCK: begin
                                ATR_TCK: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
Line 316... Line 316...
                                                if(3==tempBytesCnt) begin//support only 4 byte PPS
                                                if(3==tempBytesCnt) begin//support only 4 byte PPS
                                                        tempBytesCnt <= 8'h0;
                                                        tempBytesCnt <= 8'h0;
                                                        fsmState <= T0_PPS_RESPONSE;
                                                        fsmState <= T0_PPS_RESPONSE;
                                                        {waitCardTx,waitTermTx}<=2'b10;
                                                        {waitCardTx,waitTermTx}<=2'b10;
                                                        ppsValidSoFar<=1'b1;
                                                        ppsValidSoFar<=1'b1;
                                                        ppsAccepted<=1'b0;
                                                        //ppsAccepted<=1'b0;
                                                end else begin
                                                end else begin
                                                        tempBytesCnt <= tempBytesCnt+1;
                                                        tempBytesCnt <= tempBytesCnt+1'b1;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
                                T0_PPS_RESPONSE: begin
                                T0_PPS_RESPONSE: begin
                                        if(3==tempBytesCnt) begin//support only 4 byte PPS
                                        if(3==tempBytesCnt) begin//support only 4 byte PPS
Line 354... Line 354...
                                                                        useT1<=1'b0;
                                                                        useT1<=1'b0;
                                                                        useT15<=1'b0;
                                                                        useT15<=1'b0;
                                                                end
                                                                end
                                                        endcase
                                                        endcase
                                                end else begin
                                                end else begin
                                                        tempBytesCnt <= tempBytesCnt+1;
                                                        tempBytesCnt <= tempBytesCnt+1'b1;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
                                T0_HEADER_TPDU: begin
                                T0_HEADER_TPDU: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
Line 366... Line 366...
                                                if(4==tempBytesCnt) begin
                                                if(4==tempBytesCnt) begin
                                                        tempBytesCnt <= 8'h0;
                                                        tempBytesCnt <= 8'h0;
                                                        fsmState <= T0_PB;
                                                        fsmState <= T0_PB;
                                                        {waitCardTx,waitTermTx}<=2'b10;
                                                        {waitCardTx,waitTermTx}<=2'b10;
                                                end else begin
                                                end else begin
                                                        tempBytesCnt <= tempBytesCnt+1;
                                                        tempBytesCnt <= tempBytesCnt+1'b1;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
                                T0_PB: begin
                                T0_PB: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
Line 401... Line 401...
                                end
                                end
                                T0_NACK_DATA: begin
                                T0_NACK_DATA: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
                                                fsmState <= T0_PB;
                                                fsmState <= T0_PB;
                                                {waitCardTx,waitTermTx}<=2'b10;
                                                {waitCardTx,waitTermTx}<=2'b10;
                                                tempBytesCnt <= tempBytesCnt+1;
                                                tempBytesCnt <= tempBytesCnt+1'b1;
                                        end
                                        end
                                end
                                end
                                T0_SW1: begin
                                T0_SW1: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
                                        //TODO:check != 60 but equal to 6x or 9x
                                        //TODO:check != 60 but equal to 6x or 9x
Line 424... Line 424...
                                                if(tempBytesCnt==(tpduHeader[P3_I+:8]-1)) begin
                                                if(tempBytesCnt==(tpduHeader[P3_I+:8]-1)) begin
                                                        tempBytesCnt <= 0;
                                                        tempBytesCnt <= 0;
                                                        fsmState <= T0_SW1;
                                                        fsmState <= T0_SW1;
                                                        {waitCardTx,waitTermTx}<=2'b10;
                                                        {waitCardTx,waitTermTx}<=2'b10;
                                                end else begin
                                                end else begin
                                                        tempBytesCnt <= tempBytesCnt+1;
                                                        tempBytesCnt <= tempBytesCnt+1'b1;
                                                end
                                                end
                                        end
                                        end
                                end
                                end
                        endcase
                        endcase
                end
                end

powered by: WebSVN 2.1.0

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