Line 1... |
Line 1... |
// ------------------------- CONFIDENTIAL ------------------------------------
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright 2008-2011 by Michael A. Morris, dba M. A. Morris & Associates
|
// Copyright 2008-2013 by Michael A. Morris, dba M. A. Morris & Associates
|
//
|
//
|
// All rights reserved. No part of this source code may be reproduced or
|
// All rights reserved. The source code contained herein is publicly released
|
// transmitted in any form or by any means, electronic or mechanical,
|
// under the terms and conditions of the GNU Lesser Public License. No part of
|
// including photocopying, recording, or any information storage and
|
// this source code may be reproduced or transmitted in any form or by any
|
// retrieval system, without permission in writing from Michael A. Morris,
|
// means, electronic or mechanical, including photocopying, recording, or any
|
// dba M. A. Morris & Associates.
|
// information storage and retrieval system in violation of the license under
|
|
// which the source code is released.
|
|
//
|
|
// The source code contained herein is free; it may be redistributed and/or
|
|
// modified in accordance with the terms of the GNU Lesser General Public
|
|
// License as published by the Free Software Foundation; either version 2.1 of
|
|
// the GNU Lesser General Public License, or any later version.
|
|
//
|
|
// The source code contained herein is freely released WITHOUT ANY WARRANTY;
|
|
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
// PARTICULAR PURPOSE. (Refer to the GNU Lesser General Public License for
|
|
// more details.)
|
|
//
|
|
// A copy of the GNU Lesser General Public License should have been received
|
|
// along with the source code contained herein; if not, a copy can be obtained
|
|
// by writing to:
|
|
//
|
|
// Free Software Foundation, Inc.
|
|
// 51 Franklin Street, Fifth Floor
|
|
// Boston, MA 02110-1301 USA
|
//
|
//
|
// Further, no use of this source code is permitted in any form or means
|
// Further, no use of this source code is permitted in any form or means
|
// without a valid, written license agreement with Michael A. Morris, dba
|
// without inclusion of this banner prominently in any derived works.
|
// M. A. Morris & Associates.
|
|
//
|
//
|
// Michael A. Morris
|
// Michael A. Morris
|
// dba M. A. Morris & Associates
|
// Huntsville, AL
|
// 164 Raleigh Way
|
|
// Huntsville, AL 35811, USA
|
|
// Ph. +1 256 508 5869
|
|
//
|
|
// Licensed To: DopplerTech, Inc. (DTI)
|
|
// 9345 E. South Frontage Rd.
|
|
// Yuma, AZ 85365
|
|
//
|
//
|
// ----------------------------------------------------------------------------
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
// Company: M. A. Morris & Associates
|
// Company: M. A. Morris & Associates
|
// Engineer: Michael A. Morris
|
// Engineer: Michael A. Morris
|
//
|
//
|
// Create Date: 07:33 05/10/2008
|
// Create Date: 07:33 05/10/2008
|
// Design Name: LTAS
|
// Design Name: Synchronous Serial Peripheral (SSP) Interface UART
|
// Module Name: C:/XProjects/ISE10.1i/LTAS/LTAS_Top.v
|
// Module Name: ../VerilogCoponentsLib/SSP_UART/SSPx_Slv.v
|
// Project Name: LTAS
|
// Project Name: Verilog Components Library
|
// Target Devices: XC3S700AN-5FFG484I
|
// Target Devices: XC3S50A-4VQG100I, XC3S20A-4VQG100I, XC3S700AN-4FFG484I
|
// Tool versions: ISE 10.1i SP3
|
// Tool versions: ISE 10.1i SP3
|
//
|
//
|
// Description:
|
// Description:
|
//
|
//
|
// This module implements a full-duplex (Slave) SSP interface for 16-bit
|
// This module implements a full-duplex (Slave) SSP interface for 16-bit
|
Line 66... |
Line 77... |
// 2.00 11B06 MAM Modified the interface to separate RA[3:1] and
|
// 2.00 11B06 MAM Modified the interface to separate RA[3:1] and
|
// RA[0] into RA[2:0] address port and a WnR command
|
// RA[0] into RA[2:0] address port and a WnR command
|
// port. This makes the operation of the SSP/SPI I/F
|
// port. This makes the operation of the SSP/SPI I/F
|
// more clear.
|
// more clear.
|
//
|
//
|
|
// 2.10 13G06 MAM Changed the asynchronous reset generated by ~SSEL.
|
|
// Previously, a number of internal circuits were
|
|
// reset asynchronously on system reset, Rst, or ~SSEL.
|
|
// Added a FF, clocked on posedge SCK, that is asyn-
|
|
// chronously reset as before, but synchronously de-
|
|
// asserts on first rising edge of SCK. This signal,
|
|
// SSP_Rst, is used to asynchronously reset the same
|
|
// circuits as before: BC, EOC, and RDI. SPI Modes 0 or
|
|
// 3 are still supported.
|
|
//
|
|
// 2.20 14D25 MAM Encountered an issue whereby RA[2] held in reset
|
|
// after SSEL deasserted and then reasserted. The
|
|
// asynchronous reset on the signal SSP_Rst, a FF
|
|
// clocked on the falling edge of SCK, was changed to
|
|
// the combinatorial signal Rst_SSP. Rst_SSP is the
|
|
// source of the asynchronous reset of the SSP_Rst FF.
|
|
// The additional delay in the SSP_Rst signal caused
|
|
// RA[2] to be kept in reset at the start of a new
|
|
// SSP transfer cycle. Also added two additional CE
|
|
// signals while tracking down this issue: CE_RA and
|
|
// CE_WnR. They were previously driven directly by the
|
|
// bit counter.
|
//
|
//
|
// Additional Comments:
|
// Additional Comments:
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
module SSPx_Slv(
|
module SSPx_Slv(
|
input Rst, // System Reset
|
input Rst, // System Reset
|
//
|
//
|
input SSEL, // Slave Select
|
input SSEL, // Slave Select
|
Line 97... |
Line 130... |
//
|
//
|
|
|
reg [15:1] RDI; // Serial Input Shift Register
|
reg [15:1] RDI; // Serial Input Shift Register
|
reg [11:0] rDO; // output data register
|
reg [11:0] rDO; // output data register
|
|
|
|
reg SSP_Rst;
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Implementation
|
// Implementation
|
//
|
//
|
|
|
// Module Reset - asynchronous because SCK not continuous
|
// Module Reset - asynchronous because SCK not continuous
|
|
|
assign Rst_SSP = (Rst | ~SSEL);
|
assign Rst_SSP = (Rst | ~SSEL);
|
|
|
|
always @(posedge SCK or posedge Rst_SSP)
|
|
begin
|
|
if(Rst_SSP)
|
|
SSP_Rst <= #1 ~0;
|
|
else
|
|
SSP_Rst <= #1 0;
|
|
end
|
|
|
// Bit Counter, count from 0 to 15
|
// Bit Counter, count from 0 to 15
|
// Clock on negedge SCK to align MISO in bit cell
|
// Clock on negedge SCK to align MISO in bit cell
|
|
|
always @(negedge SCK or posedge Rst_SSP)
|
always @(negedge SCK or posedge SSP_Rst)
|
begin
|
begin
|
if(Rst_SSP)
|
if(SSP_Rst)
|
BC <= #1 4'd0;
|
BC <= #1 4'd0;
|
else
|
else
|
BC <= #1 (BC + 1);
|
BC <= #1 (BC + 1);
|
end
|
end
|
|
|
// End-Of-Cycle, asserted during last bit of transfer (bit 15)
|
// End-Of-Cycle, asserted during last bit of transfer (bit 15)
|
// Clock on negedge SCK to center rising edge in bit cell
|
// Clock on negedge SCK to center rising edge in bit cell
|
|
|
always @(negedge SCK or posedge Rst_SSP)
|
always @(negedge SCK or posedge SSP_Rst)
|
begin
|
begin
|
if(Rst_SSP)
|
if(SSP_Rst)
|
EOC <= #1 1'b0;
|
EOC <= #1 1'b0;
|
else
|
else
|
EOC <= #1 (BC == 14);
|
EOC <= #1 (BC == 14);
|
end
|
end
|
|
|
Line 156... |
Line 199... |
4'b1010 : RDI[ 5] <= #1 MOSI;
|
4'b1010 : RDI[ 5] <= #1 MOSI;
|
4'b1011 : RDI[ 4] <= #1 MOSI;
|
4'b1011 : RDI[ 4] <= #1 MOSI;
|
4'b1100 : RDI[ 3] <= #1 MOSI;
|
4'b1100 : RDI[ 3] <= #1 MOSI;
|
4'b1101 : RDI[ 2] <= #1 MOSI;
|
4'b1101 : RDI[ 2] <= #1 MOSI;
|
4'b1110 : RDI[ 1] <= #1 MOSI;
|
4'b1110 : RDI[ 1] <= #1 MOSI;
|
|
default : RDI <= #1 RDI;
|
endcase
|
endcase
|
end
|
end
|
|
|
// Assign RA, WnR, and DI bus from RDI and MOSI
|
// Assign RA, WnR, and DI bus from RDI and MOSI
|
|
|
//always @(posedge SCK or posedge Rst)
|
assign CE_RA = (BC == 2);
|
//begin
|
|
// if(Rst)
|
|
// RA <= #1 0;
|
|
// else if(BC == 2)
|
|
// RA <= #1 {RDI[15:14], MOSI};
|
|
//end
|
|
//
|
|
//always @(posedge SCK or posedge Rst)
|
|
//begin
|
|
// if(Rst)
|
|
// WnR <= #1 0;
|
|
// else if(BC == 3)
|
|
// WnR <= #1 MOSI;
|
|
//end
|
|
|
|
always @(negedge SCK or posedge Rst)
|
always @(negedge SCK or posedge Rst_SSP)
|
begin
|
begin
|
if(Rst)
|
if(Rst_SSP)
|
RA <= #1 0;
|
RA <= #1 0;
|
else if(BC == 2)
|
else if(CE_RA)
|
RA <= #1 RDI[15:13];
|
RA <= #1 RDI[15:13];
|
end
|
end
|
|
|
always @(negedge SCK or posedge Rst)
|
assign CE_WnR = (BC == 3);
|
|
|
|
always @(negedge SCK or posedge Rst_SSP)
|
begin
|
begin
|
if(Rst)
|
if(Rst_SSP)
|
WnR <= #1 0;
|
WnR <= #1 0;
|
else if(EOC)
|
else if(EOC)
|
WnR <= #1 0;
|
WnR <= #1 0;
|
else if(BC == 3)
|
else if(CE_WnR)
|
WnR <= #1 RDI[12];
|
WnR <= #1 RDI[12];
|
end
|
end
|
|
|
always @(posedge SCK or posedge Rst)
|
always @(*) DI <= {RDI[11:1], MOSI};
|
begin
|
|
if(Rst)
|
|
DI <= #1 0;
|
|
else if(EOC)
|
|
DI <= #1 {RDI[11:1], MOSI};
|
|
end
|
|
|
|
always @(negedge SCK or posedge Rst)
|
always @(negedge SCK or posedge Rst)
|
begin
|
begin
|
if(Rst)
|
if(Rst)
|
rDO <= #1 0;
|
rDO <= #1 0;
|
Line 213... |
Line 239... |
rDO <= #1 DO;
|
rDO <= #1 DO;
|
end
|
end
|
|
|
// Generate MISO: multiplex MOSI and DO using En and BC
|
// Generate MISO: multiplex MOSI and DO using En and BC
|
|
|
always @(BC or rDO or MOSI)
|
always @(*)
|
begin
|
begin
|
case(BC)
|
case(BC)
|
4'b0000 : MISO <= MOSI;
|
4'b0000 : MISO <= MOSI;
|
4'b0001 : MISO <= MOSI;
|
4'b0001 : MISO <= MOSI;
|
4'b0010 : MISO <= MOSI;
|
4'b0010 : MISO <= MOSI;
|