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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [sources/] [RxCoreSelfContained.v] - Blame information for rev 7

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

Line No. Rev Author Line
1 4 acapola
`timescale 1ns / 1ps
2
`default_nettype none
3 2 acapola
//////////////////////////////////////////////////////////////////////////////////
4
// Company: 
5
// Engineer: Sebastien Riou
6
// 
7
// Create Date:    23:57:02 08/31/2010 
8
// Design Name: 
9
// Module Name:    RxCore 
10
// Project Name: 
11
// Target Devices: 
12
// Tool versions: 
13
// Description: 
14
//
15
// Dependencies: 
16
//
17
// Revision: 
18
// Revision 0.01 - File Created
19
// Additional Comments: 
20
//
21
//////////////////////////////////////////////////////////////////////////////////
22
module RxCoreSelfContained(
23 4 acapola
    output wire [7:0] dataOut,
24
    output wire overrunErrorFlag,       //new data has been received before dataOut was read
25
    output wire dataOutReadyFlag,       //new data available
26
    output wire frameErrorFlag,         //bad parity or bad stop bits
27
    output wire endOfRx,                                //one cycle pulse: 1 during last cycle of last stop bit
28
    output wire run,                                    //rx is definitely started, one of the three flag will be set
29
    output wire startBit,                               //rx is started, but we don't know yet if real rx or just a glitch
30 5 acapola
         output wire stopBit,                           //rx is over but still in stop bits
31 4 acapola
         input wire [DIVIDER_WIDTH-1:0] clkPerCycle,
32
         input wire [CLOCK_PER_BIT_WIDTH-1:0] clocksPerBit,
33
         input wire stopBit2,//0: 1 stop bit, 1: 2 stop bits
34
         input wire oddParity, //if 1, parity bit is such that data+parity have an odd number of 1
35
    input wire msbFirst,  //if 1, bits order is: startBit, b7, b6, b5...b0, parity
36
         input wire ackFlags,
37
         input wire serialIn,
38
    input wire comClk,//not used yet
39
    input wire clk,
40
    input wire nReset
41 2 acapola
    );
42
 
43
//parameters to override
44
parameter DIVIDER_WIDTH = 1;
45 7 acapola
parameter CLOCK_PER_BIT_WIDTH = 13;     //allow to support default speed of ISO7816
46
parameter PRECISE_STOP_BIT = 0; //if 1, stopBit signal goes high exactly at start of stop bit instead of middle of parity bit
47 2 acapola
//invert the polarity of the output or not
48
//parameter IN_POLARITY = 1'b0;
49
//parameter PARITY_POLARITY = 1'b1;
50
//default conventions
51
parameter START_BIT = 1'b0;
52
parameter STOP_BIT1 = 1'b1;
53
parameter STOP_BIT2 = 1'b1;
54
 
55
wire [CLOCK_PER_BIT_WIDTH-1:0] bitClocksCounter;
56
wire bitClocksCounterEarlyMatch;
57
wire bitClocksCounterMatch;
58
wire [CLOCK_PER_BIT_WIDTH-1:0] bitClocksCounterCompare;
59
wire bitClocksCounterInc;
60
wire bitClocksCounterClear;
61 4 acapola
wire bitClocksCounterInitVal;
62
wire dividedClk;
63 2 acapola
Counter #(      .DIVIDER_WIDTH(DIVIDER_WIDTH),
64 7 acapola
                                .WIDTH(CLOCK_PER_BIT_WIDTH),
65 2 acapola
                                .WIDTH_INIT(1))
66
                bitClocksCounterModule(
67
                                .counter(bitClocksCounter),
68
                                .earlyMatch(bitClocksCounterEarlyMatch),
69 4 acapola
                                .match(bitClocksCounterMatch),
70
                                .dividedClk(dividedClk),
71 2 acapola
                                .divider(clkPerCycle),
72
                                .compare(bitClocksCounterCompare),
73
                                .inc(bitClocksCounterInc),
74
                                .clear(bitClocksCounterClear),
75
                                .initVal(bitClocksCounterInitVal),
76
                                .clk(clk),
77
                                .nReset(nReset));
78
 
79 7 acapola
RxCore #(       .CLOCK_PER_BIT_WIDTH(CLOCK_PER_BIT_WIDTH),
80
                                .PRECISE_STOP_BIT(PRECISE_STOP_BIT)
81
                                )
82
        rxCore (
83 2 acapola
    .dataOut(dataOut),
84
    .overrunErrorFlag(overrunErrorFlag),
85
    .dataOutReadyFlag(dataOutReadyFlag),
86
    .frameErrorFlag(frameErrorFlag),
87
    .endOfRx(endOfRx),
88
    .run(run),
89 5 acapola
    .startBit(startBit),
90
    .stopBit(stopBit),
91 2 acapola
    .clocksPerBit(clocksPerBit),
92
    .stopBit2(stopBit2),
93
    .oddParity(oddParity),
94
    .msbFirst(msbFirst),
95
         .ackFlags(ackFlags),
96
    .serialIn(serialIn),
97
    .clk(clk),
98
    .nReset(nReset),
99
        .bitClocksCounterEarlyMatch(bitClocksCounterEarlyMatch),
100
   .bitClocksCounterMatch(bitClocksCounterMatch),
101
        .bitClocksCounterCompare(bitClocksCounterCompare),
102
        .bitClocksCounterInc(bitClocksCounterInc),
103
        .bitClocksCounterClear(bitClocksCounterClear),
104 7 acapola
        .bitClocksCounterInitVal(bitClocksCounterInitVal),
105
        .bitClocksCounter(bitClocksCounter)
106 2 acapola
    );
107
 
108
endmodule

powered by: WebSVN 2.1.0

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