Line 1... |
Line 1... |
/*
|
/*
|
Author: Sebastien Riou (acapola)
|
Author: Sebastien Riou (acapola)
|
Creation date: 23:57:02 08/31/2010
|
Creation date: 23:57:02 08/31/2010
|
|
|
$LastChangedDate: 2011-01-29 13:16:17 +0100 (Sat, 29 Jan 2011) $
|
$LastChangedDate: 2011-02-14 15:11:43 +0100 (Mon, 14 Feb 2011) $
|
$LastChangedBy: acapola $
|
$LastChangedBy: acapola $
|
$LastChangedRevision: 11 $
|
$LastChangedRevision: 16 $
|
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/sources/RxCore.v $
|
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/sources/RxCore.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 30... |
Line 30... |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
*/
|
*/
|
`default_nettype none
|
`default_nettype none
|
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
|
|
module RxCore(
|
module RxCore
|
|
#(//parameters to override
|
|
parameter CLOCK_PER_BIT_WIDTH = 13, //allow to support default speed of ISO7816
|
|
parameter PRECISE_STOP_BIT = 0, //if 1, stopBit signal goes high exactly at start of stop bit instead of middle of parity bit
|
|
//default conventions (nothing to do with iso7816's convention, this is configured dynamically by the inputs)
|
|
parameter START_BIT = 1'b0,
|
|
parameter STOP_BIT1 = 1'b1,
|
|
parameter STOP_BIT2 = 1'b1
|
|
)
|
|
(
|
output reg [7:0] dataOut,
|
output reg [7:0] dataOut,
|
output reg overrunErrorFlag, //new data has been received before dataOut was read
|
output reg overrunErrorFlag, //new data has been received before dataOut was read
|
output reg dataOutReadyFlag, //new data available
|
output reg dataOutReadyFlag, //new data available
|
output reg frameErrorFlag, //bad parity or bad stop bits
|
output reg frameErrorFlag, //bad parity or bad stop bits
|
output reg endOfRx, //one cycle pulse: 1 during last cycle of last stop bit
|
output reg endOfRx, //one cycle pulse: 1 during last cycle of last stop bit
|
Line 57... |
Line 66... |
input wire bitClocksCounterEarlyMatch,
|
input wire bitClocksCounterEarlyMatch,
|
input wire bitClocksCounterMatch,
|
input wire bitClocksCounterMatch,
|
input wire [CLOCK_PER_BIT_WIDTH-1:0] bitClocksCounter
|
input wire [CLOCK_PER_BIT_WIDTH-1:0] bitClocksCounter
|
);
|
);
|
|
|
//parameters to override
|
|
parameter CLOCK_PER_BIT_WIDTH = 13; //allow to support default speed of ISO7816
|
|
parameter PRECISE_STOP_BIT = 0; //if 1, stopBit signal goes high exactly at start of stop bit instead of middle of parity bit
|
|
|
|
//default conventions
|
|
parameter START_BIT = 1'b0;
|
|
parameter STOP_BIT1 = 1'b1;
|
|
parameter STOP_BIT2 = 1'b1;
|
|
|
|
//constant definition for states
|
//constant definition for states
|
localparam IDLE_STATE = 3'b000;
|
localparam IDLE_STATE = 3'b000;
|
localparam START_STATE = 3'b001;
|
localparam START_STATE = 3'b001;
|
localparam DATA_STATE = 3'b011;
|
localparam DATA_STATE = 3'b011;
|
localparam PARITY_STATE = 3'b010;
|
localparam PARITY_STATE = 3'b010;
|