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 13 and 15

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

Rev 13 Rev 15
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-09 13:34:14 +0100 (Wed, 09 Feb 2011) $
$LastChangedDate: 2011-02-13 16:20:10 +0100 (Sun, 13 Feb 2011) $
$LastChangedBy: acapola $
$LastChangedBy: acapola $
$LastChangedRevision: 13 $
$LastChangedRevision: 15 $
$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 69... Line 69...
        output wire cardTx,
        output wire cardTx,
        output wire termTx,
        output wire termTx,
        output wire guardTime,
        output wire guardTime,
        output wire overrunError,
        output wire overrunError,
        output wire frameError,
        output wire frameError,
 
        output reg comOnGoing,
        output reg [7:0] lastByte,
        output reg [7:0] lastByte,
        output reg [31:0] bytesCnt
        output reg [31:0] bytesCnt
        );
        );
localparam CLOCK_PER_BIT_WIDTH = 4'd13;
localparam CLOCK_PER_BIT_WIDTH = 4'd13;
 
 
Line 111... Line 112...
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 [CLOCK_PER_BIT_WIDTH-1:0] clocksPerBit = cyclesPerEtu-1;
wire [CLOCK_PER_BIT_WIDTH-1:0] clocksPerBit = cyclesPerEtu-1;
 
 
 
wire rxCore_nReset = nReset & isoVdd & isoReset;
reg [CLOCK_PER_BIT_WIDTH-1:0] safeClocksPerBit;
reg [CLOCK_PER_BIT_WIDTH-1:0] safeClocksPerBit;
always @(posedge clk, negedge nReset) begin
 
        if(~nReset) begin
always @(*) comOnGoing = rxRun|rxStartBit;
 
 
 
always @(posedge clk, negedge rxCore_nReset) begin
 
        if(~rxCore_nReset) begin
                safeClocksPerBit<=clocksPerBit;
                safeClocksPerBit<=clocksPerBit;
        end else if(endOfRx|~(rxRun|rxStartBit)) begin
        end else if(endOfRx|~comOnGoing) begin
                safeClocksPerBit<=clocksPerBit;
                safeClocksPerBit<=clocksPerBit;
        end
        end
end
end
 
 
 
wire [7:0] ts;
 
 
RxCoreSelfContained #(
RxCoreSelfContained #(
                .DIVIDER_WIDTH(DIVIDER_WIDTH),
                .DIVIDER_WIDTH(DIVIDER_WIDTH),
                .CLOCK_PER_BIT_WIDTH(CLOCK_PER_BIT_WIDTH),
                .CLOCK_PER_BIT_WIDTH(CLOCK_PER_BIT_WIDTH),
                .PRECISE_STOP_BIT(1'b1))
                .PRECISE_STOP_BIT(1'b1))
        rxCore (
        rxCore (
Line 142... Line 149...
    .msbFirst(msbFirst),
    .msbFirst(msbFirst),
         .ackFlags(ackFlags),
         .ackFlags(ackFlags),
    .serialIn(isoSio),
    .serialIn(isoSio),
    .comClk(isoClk),
    .comClk(isoClk),
    .clk(clk),
    .clk(clk),
    .nReset(nReset)
    .nReset(rxCore_nReset)
    );
    );
 
 
TsAnalyzer tsAnalyzer(
TsAnalyzer tsAnalyzer(
        .nReset(nReset),
        .nReset(nReset),
        .isoReset(isoReset),
        .isoReset(isoReset),
Line 158... Line 165...
        .isActivated(isActivated),
        .isActivated(isActivated),
        .tsReceived(tsReceived),
        .tsReceived(tsReceived),
        .tsError(tsError),
        .tsError(tsError),
        .atrIsEarly(atrIsEarly),
        .atrIsEarly(atrIsEarly),
        .atrIsLate(atrIsLate),
        .atrIsLate(atrIsLate),
        .useIndirectConvention(useIndirectConvention)
        .useIndirectConvention(useIndirectConvention),
 
        .ts(ts)
        );
        );
 
 
FiDiAnalyzer fiDiAnalyzer(
FiDiAnalyzer fiDiAnalyzer(
        .fiCode(fiCode),
        .fiCode(fiCode),
        .diCode(diCode),
        .diCode(diCode),
Line 203... Line 211...
                ackFlags<=1'b0;
                ackFlags<=1'b0;
                bytesCnt<=32'b0;
                bytesCnt<=32'b0;
        end else if(ackFlags) begin
        end else if(ackFlags) begin
                ackFlags<=1'b0;
                ackFlags<=1'b0;
        end else if(frameErrorFlag|bufferFull) begin
        end else if(frameErrorFlag|bufferFull) begin
                lastByte<=dataOut;
                if(tsReceived) lastByte<=dataOut;//ts is read by tsAnalyzer
                ackFlags<=1'b1;
                ackFlags<=1'b1;
                bytesCnt<=bytesCnt+1'b1;
                bytesCnt<=bytesCnt+1'b1;
 
        end else if((32'b1==bytesCnt) & tsReceived) begin
 
                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);
always @(posedge isoClk, negedge nReset) begin
always @(posedge isoClk, negedge rxCore_nReset) begin
        if(~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;
Line 434... Line 444...
        if(guardTime & ~isoSio)
        if(guardTime & ~isoSio)
                {proto_cardTx, proto_termTx}={txDir[0],txDir[1]};
                {proto_cardTx, proto_termTx}={txDir[0],txDir[1]};
        else
        else
                {proto_cardTx, proto_termTx}={txDir[1],txDir[0]};
                {proto_cardTx, proto_termTx}={txDir[1],txDir[0]};
end
end
always @(posedge isoClk, negedge nReset) begin: protoComDirectionSeqBlock
always @(posedge isoClk, negedge rxCore_nReset) begin: protoComDirectionSeqBlock
        if(~nReset | ~run) begin
        if(~rxCore_nReset | ~run) begin
                txDir<=2'b00;
                txDir<=2'b00;
        end else begin
        end else begin
                if(~guardTime) begin //{waitCardTx, waitTermTx} is updated during stop bits so we hold current value here
                if(~guardTime) begin //{waitCardTx, waitTermTx} is updated during stop bits so we hold current value here
                        case({waitCardTx, waitTermTx})
                        case({waitCardTx, waitTermTx})
                                2'b00: txDir<=2'b00;//no one should/is sending
                                2'b00: txDir<=2'b00;//no one should/is sending
Line 451... Line 461...
        end
        end
end
end
 
 
reg phy_cardTx;
reg phy_cardTx;
reg phy_termTx;
reg phy_termTx;
always @(negedge isoSio, negedge nReset) begin: phyComDirectionBlock
always @(negedge isoSio, negedge rxCore_nReset) begin: phyComDirectionBlock
        if(~nReset) begin
        if(~rxCore_nReset) begin
                phy_cardTx<=1'b0;
                phy_cardTx<=1'b0;
                phy_termTx<=1'b0;
                phy_termTx<=1'b0;
        end else begin
        end else begin
                if(~isoSioTerm) begin
                if(~isoSioTerm) begin
                        phy_cardTx<=1'b0;
                        phy_cardTx<=1'b0;

powered by: WebSVN 2.1.0

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