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 11 and 12

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

Rev 11 Rev 12
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-01-29 13:16:17 +0100 (Sat, 29 Jan 2011) $
$LastChangedDate: 2011-01-29 17:13:49 +0100 (Sat, 29 Jan 2011) $
$LastChangedBy: acapola $
$LastChangedBy: acapola $
$LastChangedRevision: 11 $
$LastChangedRevision: 12 $
$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 82... Line 82...
localparam INS_I= 8*3;
localparam INS_I= 8*3;
localparam P1_I = 8*2;
localparam P1_I = 8*2;
localparam P2_I = 8*1;
localparam P2_I = 8*1;
localparam P3_I = 0;
localparam P3_I = 0;
reg [CLA_I+7:0] tpduHeader;
reg [CLA_I+7:0] tpduHeader;
 
localparam PPS0_I= CLA_I;
 
localparam PPS1_I= INS_I;
 
localparam PPS2_I= P1_I;
 
localparam PPS3_I= P2_I;
//wire COM_clk=isoClk;
//wire COM_clk=isoClk;
//integer COM_errorCnt;
//integer COM_errorCnt;
//wire txPending=1'b0;
//wire txPending=1'b0;
//wire txRun=1'b0;
//wire txRun=1'b0;
 
 
Line 100... Line 103...
wire msbFirst = useIndirectConvention;
wire msbFirst = useIndirectConvention;
wire sioHighValue = ~useIndirectConvention;
wire sioHighValue = ~useIndirectConvention;
wire oddParity = 1'b0;
wire oddParity = 1'b0;
 
 
wire [7:0] dataOut = sioHighValue ? rxData : ~rxData;
wire [7:0] dataOut = sioHighValue ? rxData : ~rxData;
 
 
 
 
//`include "ComRxDriverTasks.v"
 
 
 
wire endOfRx;
wire endOfRx;
 
 
wire stopBit2 = useT0;//1 if com use 2 stop bits --> 12 ETU / byte
wire stopBit2 = useT0;//1 if com use 2 stop bits --> 12 ETU / byte
wire [12:0] clocksPerBit = cyclesPerEtu-1;
wire [12:0] clocksPerBit = cyclesPerEtu-1;
RxCoreSelfContained #(
RxCoreSelfContained #(
Line 171... Line 170...
localparam T0_DATA = 3;
localparam T0_DATA = 3;
localparam T0_NACK_DATA = 4;
localparam T0_NACK_DATA = 4;
localparam T0_SW1 = 5;
localparam T0_SW1 = 5;
localparam T0_SW2 = 6;
localparam T0_SW2 = 6;
localparam T0_HEADER_PPS = 100;
localparam T0_HEADER_PPS = 100;
 
localparam T0_PPS_RESPONSE = 101;
 
 
integer fsmState;
integer fsmState;
 
 
reg [11:0] tdiStruct;
reg [11:0] tdiStruct;
wire [3:0] tdiCnt;//i+1
wire [3:0] tdiCnt;//i+1
Line 195... Line 195...
                lastByte<=dataOut;
                lastByte<=dataOut;
                ackFlags<=1'b1;
                ackFlags<=1'b1;
                bytesCnt<=bytesCnt+1'b1;
                bytesCnt<=bytesCnt+1'b1;
        end
        end
end
end
 
reg ppsValidSoFar;
 
reg ppsAccepted;
 
wire ppsDataMatch = (tpduHeader[(CLA_I-(tempBytesCnt*8))+:8]==dataOut);
always @(posedge isoClk, negedge nReset) begin
always @(posedge isoClk, negedge nReset) begin
        if(~nReset) begin
        if(~nReset) begin
 
                ppsValidSoFar<=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 271... Line 276...
                                T0_HEADER: begin
                                T0_HEADER: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
                                                tpduHeader[CLA_I+:8]<=dataOut;
                                                tpduHeader[CLA_I+:8]<=dataOut;
                                                tempBytesCnt <= 1;
                                                tempBytesCnt <= 1;
                                                if(8'hFF==dataOut)
                                                if(8'hFF==dataOut)
                                                        fsmState <= T0_HEADER_PPS;//TODO
                                                        fsmState <= T0_HEADER_PPS;
                                                else
                                                else
                                                        fsmState <= T0_HEADER_TPDU;
                                                        fsmState <= T0_HEADER_TPDU;
                                        end
                                        end
                                end
                                end
 
                                T0_HEADER_PPS: begin
 
                                        if(endOfRx) begin
 
                                                tpduHeader[(CLA_I-(tempBytesCnt*8))+:8]<=dataOut;
 
                                                if(3==tempBytesCnt) begin//support only 4 byte PPS
 
                                                        tempBytesCnt <= 8'h0;
 
                                                        fsmState <= T0_PPS_RESPONSE;
 
                                                        {waitCardTx,waitTermTx}<=2'b10;
 
                                                        ppsValidSoFar<=1'b1;
 
                                                        ppsAccepted<=1'b0;
 
                                                end else begin
 
                                                        tempBytesCnt <= tempBytesCnt+1;
 
                                                end
 
                                        end
 
                                end
 
                                T0_PPS_RESPONSE: begin
 
                                        if(3==tempBytesCnt) begin//support only 4 byte PPS
 
                                                if(guardTime) begin
 
                                                        if(ppsValidSoFar & ppsDataMatch) begin
 
                                                                {fiCode,diCode}<=tpduHeader[PPS2_I+:8];
 
                                                        end
 
                                                end
 
                                        end
 
                                        if(endOfRx) begin
 
                                                ppsValidSoFar<=ppsValidSoFar & ppsDataMatch;
 
                                                if(3==tempBytesCnt) begin//support only 4 byte PPS
 
                                                        tempBytesCnt <= 8'h0;
 
                                                        fsmState <= T0_HEADER;
 
                                                        {waitCardTx,waitTermTx}<=2'b01;
 
                                                        case(tpduHeader[(PPS1_I-(tempBytesCnt*8))+:8])
 
                                                                8'h11: begin
 
                                                                        useT0<=1'b0;
 
                                                                        useT1<=1'b1;
 
                                                                        useT15<=1'b0;
 
                                                                end
 
                                                                8'h1F: begin
 
                                                                        useT0<=1'b0;
 
                                                                        useT1<=1'b0;
 
                                                                        useT15<=1'b1;
 
                                                                end
 
                                                                default: begin
 
                                                                        useT0<=1'b1;
 
                                                                        useT1<=1'b0;
 
                                                                        useT15<=1'b0;
 
                                                                end
 
                                                        endcase
 
                                                end else begin
 
                                                        tempBytesCnt <= tempBytesCnt+1;
 
                                                end
 
                                        end
 
                                end
                                T0_HEADER_TPDU: begin
                                T0_HEADER_TPDU: begin
                                        if(endOfRx) begin
                                        if(endOfRx) begin
                                                tpduHeader[(CLA_I-(tempBytesCnt*8))+:8]<=dataOut;
                                                tpduHeader[(CLA_I-(tempBytesCnt*8))+:8]<=dataOut;
                                                if(4==tempBytesCnt) begin
                                                if(4==tempBytesCnt) begin
                                                        tempBytesCnt <= 8'h0;
                                                        tempBytesCnt <= 8'h0;

powered by: WebSVN 2.1.0

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