//--------------------------------------------------------------------------------------------------
//
// Title       : PWMtranslator
// Design      : U4
// Author      : mbari###
// Company     : MBARI
//
//-------------------------------------------------------------------------------------------------
//
// File        : c:\projects\genosensor\2g\cplds\core\u4\src\PWMtranslator.v
// Generated   : Fri Dec 19 18:07:00 2003
// From        : interface description file
// By          : Itf2Vhdl ver. 1.20
//
//-------------------------------------------------------------------------------------------------
//
// Description : 
//
//-------------------------------------------------------------------------------------------------
`timescale 1ps / 1ps

//{{ Section below this comment is automatically maintained
//   and may be overwritten
//{module {PWMtranslator}}
module PWMtranslator ( PWM ,DIR ,Brake ,PAH ,PAL ,PBH ,PBL ,fBRK ,HBRK ,MTRpwr ,FLS ,RLS, external_pwm_o );

output PAH ;
wire PAH ;
output PAL ;
wire PAL ;
output PBH ;
wire PBH ;
output PBL ;
wire PBL ;

input PWM ;
wire PWM ;
input DIR ;
wire DIR ;
input Brake ;
wire Brake ;
input fBRK ;
wire fBRK ;
input HBRK ;
wire HBRK ;
input MTRpwr ;
wire MTRpwr ;
input FLS ;
wire FLS ;
input RLS ;
wire RLS ;	   

output external_pwm_o;   // WJR

//}} End of automatically maintained section

// -- Enter your statements here -- //



wire BRK;

assign BRK = (fBRK | Brake | HBRK);

//PH(fBRK,Brake,DIR,PWM,PAH);	 
//PL(fBRK,Brake,DIR,PWM,PAL);	 
//PH(fBRK,Brake,!DIR,PWM,PBH);	 
//PH(fBRK,Brake,!DIR,PWM,PBL);	 

//on the low driver PAL and PBL these lines are transistor on when low.  The anding of the signal with
//MTRpwr will casue the low lines to be turned on.  This is OK because power is failing and will
//casue the motor to be locked while power fails.  This also means that we are not applying
//a voltage to a device which has power removed.  This will save on leakage current.
//FLS and RLS have been added initial to stop the motor from the ability to begin driven initial when 
//corresponding direciton is being asserted.  This will turn the topside driver off.

assign PAH = (PWM & !DIR & !BRK & RLS) & MTRpwr;
assign PAL = ((!PWM & DIR & !BRK) | (PWM & !DIR & !BRK)) & MTRpwr;
assign PBH = (PWM & DIR & !BRK & FLS) & MTRpwr;
assign PBL = ((!PWM & !DIR & !BRK) | (PWM & DIR & !BRK)) & MTRpwr;		 

// WJR
// Disable the external PWM if
//   the brake signal(BRK = 1) is asserted
//   or the Forward Limit Switch(FLS = 0) is asserted
//   or the Reverse Limit Switch(RLS = 0)

assign external_pwm_o = !BRK & FLS & RLS & PWM;

endmodule

