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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [DummyCard.v] - Diff between revs 14 and 15

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

Rev 14 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-10 16:40:57 +0100 (Thu, 10 Feb 2011) $
$LastChangedDate: 2011-02-13 16:20:10 +0100 (Sun, 13 Feb 2011) $
$LastChangedBy: acapola $
$LastChangedBy: acapola $
$LastChangedRevision: 14 $
$LastChangedRevision: 15 $
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/DummyCard.v $
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/DummyCard.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 44... Line 44...
        reg nWeDataIn;
        reg nWeDataIn;
        reg nCsDataOut;
        reg nCsDataOut;
        reg nCsStatusOut;
        reg nCsStatusOut;
 
 
        // Outputs
        // Outputs
        wire [7:0] dataOut;
        wire [7:0] uart_dataOut;
        wire [7:0] statusOut;
        wire [7:0] statusOut;
        wire serialOut;
        wire serialOut;
        reg [12:0] cyclesPerEtu;
        reg [12:0] cyclesPerEtu;
 
 
        wire cardIsoClk;//card use its own generated clock (like true UARTs)
        wire cardIsoClk;//card use its own generated clock (like true UARTs)
 
 
 
reg useIndirectConventionConfig;//can be changed by commands
 
reg useIndirectConvention;
 
 
 
wire stopBit2=1'b1;//0: 1 stop bit, 1: 2 stop bits 
 
wire msbFirst = useIndirectConvention;//if 1, bits order is: startBit, b7, b6, b5...b0, parity
 
wire oddParity = 1'b0;//if 1, parity bit is such that data+parity have an odd number of 1
 
wire sioHighValue = ~useIndirectConvention;//apply only to data bits
 
 
 
wire [7:0] uart_dataIn = sioHighValue ? dataIn : ~dataIn;
 
wire [7:0] dataOut = sioHighValue ? uart_dataOut : ~uart_dataOut;
 
 
        HalfDuplexUartIf uartIf (
        HalfDuplexUartIf uartIf (
                .nReset(isoReset),
                .nReset(isoReset),
                .clk(isoClk),
                .clk(isoClk),
                .clkPerCycle(clkPerCycle),
                .clkPerCycle(clkPerCycle),
                .dataIn(dataIn),
                .dataIn(uart_dataIn),
                .nWeDataIn(nWeDataIn),
                .nWeDataIn(nWeDataIn),
                .clocksPerBit(cyclesPerEtu),
                .clocksPerBit(cyclesPerEtu),
                .dataOut(dataOut),
                .stopBit2(stopBit2),
 
                .oddParity(oddParity),
 
      .msbFirst(msbFirst),
 
           .dataOut(uart_dataOut),
                .nCsDataOut(nCsDataOut),
                .nCsDataOut(nCsDataOut),
                .statusOut(statusOut),
                .statusOut(statusOut),
                .nCsStatusOut(nCsStatusOut),
                .nCsStatusOut(nCsStatusOut),
                .serialIn(isoSio),
                .serialIn(isoSio),
                .serialOut(serialOut),
                .serialOut(serialOut),
Line 104... Line 119...
                sw:   90 00
                sw:   90 00
        read buffer:
        read buffer:
                tpdu: 00 0A 00 00 LE
                tpdu: 00 0A 00 00 LE
                response: data
                response: data
                sw:   90 00
                sw:   90 00
 
        toggle communication convention (take effect at next reset):
 
                tpdu 00 FC 00 00 00
 
                sw:     90 00
        any other:
        any other:
                sw:   69 86
                sw:   69 86
*/
*/
task sendAckByte;
task sendAckByte;
        sendByte(tpduHeader[INS_I+7:INS_I]);
        sendByte(tpduHeader[INS_I+7:INS_I]);
Line 136... Line 154...
        end
        end
        sendHexBytes("9000");//sendWord(16'h9000);
        sendHexBytes("9000");//sendWord(16'h9000);
end
end
endtask
endtask
 
 
 
task toggleConventionCmd;
 
integer i;
 
begin
 
        useIndirectConventionConfig=~useIndirectConventionConfig;
 
        sendHexBytes("9000");//sendWord(16'h9000);
 
end
 
endtask
 
 
 
//stuff which can be changed by command and affect ATR
 
always @(posedge isoVdd) begin
 
        useIndirectConventionConfig<=1'b1;
 
end
 
 
integer i;
integer i;
always @(posedge isoClk, negedge isoReset) begin
always @(posedge isoClk, negedge isoReset) begin
        if(~isoReset) begin
        if(~isoReset) begin
                nWeDataIn<=1'b1;
                nWeDataIn<=1'b1;
                nCsDataOut<=1'b1;
                nCsDataOut<=1'b1;
                nCsStatusOut<=1'b1;
                nCsStatusOut<=1'b1;
                tsCnt<=9'b0;
                tsCnt<=9'b0;
                sendAtr<=1'b1;
                sendAtr<=1'b1;
                cyclesPerEtu <= 13'd372-1'b1;
                cyclesPerEtu <= 13'd372-1'b1;
 
                useIndirectConvention<=useIndirectConventionConfig;
        end else if(tsCnt!=9'd400) begin
        end else if(tsCnt!=9'd400) begin
                tsCnt <= tsCnt + 1'b1;
                tsCnt <= tsCnt + 1'b1;
        end else if(sendAtr) begin
        end else if(sendAtr) begin
                sendAtr<=1'b0;
                sendAtr<=1'b0;
                //sendHexBytes("3B00");
                //sendHexBytes("3B00");
 
                if(useIndirectConvention)
 
                        sendHexBytes("3F");
 
                else
                sendHexBytes("3B");
                sendHexBytes("3B");
                //sendHexBytes("3F");
 
                //sendHexBytes("9497801F42BABEBABE");
                //sendHexBytes("9497801F42BABEBABE");
                //sendHexBytes("9E 97 80 1F C7 80 31 E0 73 FE 21 1B 66 D0 00 28 24 01 00 0D");
                //sendHexBytes("9E 97 80 1F C7 80 31 E0 73 FE 21 1B 66 D0 00 28 24 01 00 0D");
                sendHexBytes("9E 97 80 1F C7 80 31 E0 73 FE 21 1B 66 D0 00 28 24 01 00 ");
                sendHexBytes("9E 97 80 1F C7 80 31 E0 73 FE 21 1B 66 D0 00 28 24 01 00 ");
                waitEndOfTx;
                waitEndOfTx;
        end else begin
        end else begin
Line 178... Line 212...
                        receiveByte(tpduHeader[P3_I+:8]);
                        receiveByte(tpduHeader[P3_I+:8]);
                        //dispatch
                        //dispatch
                        case(tpduHeader[7+CLA_I:P2_I])
                        case(tpduHeader[7+CLA_I:P2_I])
                                        32'h000C0000: writeBufferCmd;
                                        32'h000C0000: writeBufferCmd;
                                        32'h000A0000: readBufferCmd;
                                        32'h000A0000: readBufferCmd;
                                        default: sendHexBytes("6986");//sendWord(16'h6986);
                                        32'h00FC0000: toggleConventionCmd;
 
                                        default: sendHexBytes("6986");
                        endcase
                        endcase
                end
                end
        end
        end
end
end
 
 

powered by: WebSVN 2.1.0

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