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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [tsAnalyzer.v] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 acapola
/*
2
Author: Sebastien Riou (acapola)
3
Creation date: 22:22:43 01/10/2011
4
 
5
$LastChangedDate: 2011-02-18 15:23:07 +0100 (Fri, 18 Feb 2011) $
6
$LastChangedBy: acapola $
7
$LastChangedRevision: 17 $
8
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/test/tsAnalyzer.v $
9
 
10
This file is under the BSD licence:
11
Copyright (c) 2011, Sebastien Riou
12
 
13
All rights reserved.
14
 
15
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
16
 
17
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
19
The names of contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
32
`default_nettype none
33 5 acapola
`timescale 1ns / 1ps
34
 
35
module TsAnalyzer(
36
        input wire nReset,
37
        input wire isoReset,
38
        input wire isoClk,
39
        input wire isoVdd,
40
        input wire isoSio,
41
        input wire endOfRx,
42
        input wire [7:0] rxData,//assumed to be sent lsb first, high level coding logical 1.
43 6 acapola
        output wire isActivated,
44
        output wire tsReceived,
45
        output wire tsError,
46
        output wire atrIsEarly,//high if TS received before 400 cycles after reset release
47
        output wire atrIsLate,//high if TS is still not received after 40000 cycles after reset release
48 15 acapola
        output wire useIndirectConvention,
49
        output reg [7:0] ts
50 5 acapola
        );
51
 
52
 
53
reg [8:0] tsCnt;//counter to start ATR 400 cycles after reset release
54
 
55
reg [16:0] resetCnt;
56
reg waitTs;
57
assign tsReceived = ~waitTs;
58
assign atrIsEarly = ~waitTs & (resetCnt<(16'h100+16'd400));
59
assign atrIsLate = resetCnt>(16'h100+16'd40000);
60 17 acapola
assign useIndirectConvention = ~waitTs & (ts==8'h3F);
61
assign tsError = ~waitTs & (ts!=8'h3B) & (ts!=8'h3F);
62 6 acapola
 
63
assign isActivated = isoReset & isoVdd;
64 15 acapola
wire fsm_nReset=nReset & isoReset & isoVdd;
65
always @(posedge isoClk, negedge fsm_nReset) begin
66
        if(~fsm_nReset) begin
67 5 acapola
                resetCnt<=16'b0;
68
                waitTs<=1'b1;
69
        end else if(isActivated) begin
70
                if(waitTs) begin
71
                        if(endOfRx) begin
72
                                waitTs<=1'b0;
73 15 acapola
                                case(rxData)
74
                                        8'h3B: ts<=rxData;
75 17 acapola
                                        8'h03: ts<=8'h3F;//03 is 3F written LSB first and complemented
76 15 acapola
                                        default: ts<=rxData;
77
                                endcase
78 5 acapola
                        end
79
                        resetCnt<=resetCnt+1;
80
                end
81
        end else begin
82 15 acapola
                //if(isoVdd & isoReset) begin
83 5 acapola
                        resetCnt<=resetCnt + 1;
84 15 acapola
                //end else begin
85
                //      resetCnt<=16'b0;
86
                //end
87 5 acapola
        end
88
end
89
 
90
endmodule
91 11 acapola
`default_nettype wire
92 5 acapola
 

powered by: WebSVN 2.1.0

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