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

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [sources/] [Uart.v] - Diff between revs 11 and 12

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

Rev 11 Rev 12
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-01-29 17:13:49 +0100 (Sat, 29 Jan 2011) $
$LastChangedBy: acapola $
$LastChangedBy: acapola $
$LastChangedRevision: 11 $
$LastChangedRevision: 12 $
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/sources/Uart.v $
$HeadURL: file:///svn/iso7816_3_master/iso7816_3_master/trunk/sources/Uart.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 56... Line 56...
    output wire endOfRx,           //one cycle pulse: 1 during last cycle of last stop bit of rx
    output wire endOfRx,           //one cycle pulse: 1 during last cycle of last stop bit of rx
    output wire rxRun,                                  //rx is definitely started, one of the three flag will be set
    output wire rxRun,                                  //rx is definitely started, one of the three flag will be set
    output wire rxStartBit,                     //rx is started, but we don't know yet if real rx or just a glitch
    output wire rxStartBit,                     //rx is started, but we don't know yet if real rx or just a glitch
    output wire txFull,
    output wire txFull,
    output wire isTx,              //1 only when tx is ongoing. Indicates the direction of the com line.
    output wire isTx,              //1 only when tx is ongoing. Indicates the direction of the com line.
 
    output wire endOfTx,           //one cycle pulse: 1 during last cycle of last stop bit of tx
 
 
         input wire serialIn,                           //signals to merged into a inout signal according to "isTx"
         input wire serialIn,                           //signals to merged into a inout signal according to "isTx"
         output wire serialOut,
         output wire serialOut,
         output wire comClk,
         output wire comClk,
 
 
Line 73... Line 74...
         input wire ackFlags,
         input wire ackFlags,
         input wire clk,
         input wire clk,
    input wire nReset
    input wire nReset
    );
    );
 
 
//constant definition for states
 
localparam IDLE_STATE =         3'b000;
 
localparam RX_STATE =   3'b001;
 
localparam TX_STATE =   3'b011;
 
 
 
wire rxSerialIn = isTx ? STOP_BIT1 : serialIn;
wire rxSerialIn = isTx ? STOP_BIT1 : serialIn;
//wire serialOut;
 
wire loadDataIn;
wire loadDataIn;
 
 
wire txStopBits;
wire txStopBits;
 
 
assign isTx = txRun & ~txStopBits;
assign isTx = txRun & ~txStopBits;
//let this to top level to avoid inout signal
 
//assign serialLine = isTx ? serialOut : 1'bz;
 
 
 
assign loadDataIn = startTx & ~rxStartBit & (~rxRun | endOfRx);
assign loadDataIn = startTx & ~rxStartBit & (~rxRun | endOfRx);
 
 
/*//complicated approach... instead we can simply divide the clock at lower levels
reg [CLOCK_PER_BIT_WIDTH-1:0] safeClocksPerBit;
wire useEarlyComClk = |clkPerCycle ? 1'b1:1'b0;
always @(posedge clk, negedge nReset) begin
reg dividedClk;
        if(~nReset) begin
wire earlyComClk;//earlier than comClk by 1 cycle of clk (use to make 1 cycle pulse signals)
                safeClocksPerBit<=clocksPerBit;
always @(posedge clk)begin
        end else if(endOfRx|endOfTx|~(rxRun|rxStartBit|txRun)) begin
        if(useEarlyComClk)
                safeClocksPerBit<=clocksPerBit;
                dividedClk <= earlyComClk;
        end
end
end
assign comClk=useEarlyComClk ? dividedClk : clk;//clock for communication
 
wire endOfRxComClk;//pulse of 1 cycle of comClk
 
assign endOfRx = useEarlyComClk ? endOfRxComClk & earlyComClk & ~comClk : endOfRxComClk;//pulse of 1 cycle of clk
 
ClkDivider #(.DIVIDER_WIDTH(DIVIDER_WIDTH))
 
        clkDivider(
 
                .nReset(nReset),
 
                .clk(clk),
 
                .divider(clkPerCycle),
 
                .dividedClk(earlyComClk)
 
                );
 
*/
 
wire stopBit;
wire stopBit;
// Instantiate the module
// Instantiate the module
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)
Line 125... Line 105...
    .endOfRx(endOfRx),
    .endOfRx(endOfRx),
    .run(rxRun),
    .run(rxRun),
    .startBit(rxStartBit),
    .startBit(rxStartBit),
         .stopBit(stopBit),
         .stopBit(stopBit),
    .clkPerCycle(clkPerCycle),
    .clkPerCycle(clkPerCycle),
    .clocksPerBit(clocksPerBit),
    .clocksPerBit(safeClocksPerBit),
    .stopBit2(stopBit2),
    .stopBit2(stopBit2),
    .oddParity(oddParity),
    .oddParity(oddParity),
    .msbFirst(msbFirst),
    .msbFirst(msbFirst),
         .ackFlags(ackFlags),
         .ackFlags(ackFlags),
    .serialIn(rxSerialIn),
    .serialIn(rxSerialIn),
Line 141... Line 121...
                        .CLOCK_PER_BIT_WIDTH(CLOCK_PER_BIT_WIDTH)
                        .CLOCK_PER_BIT_WIDTH(CLOCK_PER_BIT_WIDTH)
                )
                )
        txCore (
        txCore (
        .serialOut(serialOut),
        .serialOut(serialOut),
        .run(txRun),
        .run(txRun),
 
        .endOfTx(endOfTx),
        .full(txFull),
        .full(txFull),
   .stopBits(txStopBits),
   .stopBits(txStopBits),
        .dataIn(txData),
        .dataIn(txData),
        .clkPerCycle(clkPerCycle),
        .clkPerCycle(clkPerCycle),
        .clocksPerBit(clocksPerBit),
        .clocksPerBit(safeClocksPerBit),
        .stopBit2(stopBit2),
        .stopBit2(stopBit2),
   .oddParity(oddParity),
   .oddParity(oddParity),
   .msbFirst(msbFirst),
   .msbFirst(msbFirst),
        .loadDataIn(loadDataIn),
        .loadDataIn(loadDataIn),
        .comClk(comClk),
        .comClk(comClk),

powered by: WebSVN 2.1.0

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