-- **********************************************************************
-- *                                                                    *
-- *     Hardware Register Mappings for the RVP8/Tx Receiver Board      *
-- *                                                                    *
-- **********************************************************************
-- File: rda/pcicards/rvp8tx.inc
--
--                        COPYRIGHT (c) 2001  BY
--          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
-- 
-- THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
-- ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
-- INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
-- COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
-- OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
-- TRANSFERED.
--

-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-- This file must be manually maintained in parallel with its C
--   companion file: rvp8tx.h.  The syntax between C and AHDL
--        is too different to try to patch automatically.
-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

-- **************************************
-- *                                    *
-- * RVP8/Tx Control/Status Definitions *
-- *                                    *
-- **************************************

CONSTANT TX8CSRSZ             = 64 ;	-- CSR decoded address space (DWORDs)
CONSTANT TX8CSRHIB = LOG2(TX8CSRSZ) - 1 ;

-- ------------------------------
-- CAUTION: Address 0x00 is RESETADDR
-- CAUTION: Address 0x01 is ISR_ADDR

-- ------------------------------
-- Board Edge LEDs.  Note that the "Always ON" code is assigned the
-- value zero so that all of the LEDs light up upon reset.
--
CONSTANT TX8REDLED        = H"03" ;	-- Red LED options
  CONSTANT TX8REDLED_ON      =  0 ; 	--   On always
  CONSTANT TX8REDLED_OFF     =  1 ;	--   Off always
  CONSTANT TX8REDLED_PCIACT  =  2 ;	--   Shows PCI access

CONSTANT TX8GRNLED        = H"04" ;	-- Green LED options
  CONSTANT TX8GRNLED_ON      =  0 ; 	--   On always
  CONSTANT TX8GRNLED_OFF     =  1 ;	--   Off always

CONSTANT TX8VISLED        = H"05" ;	-- Green (edge visible) LED options
  CONSTANT TX8VISLED_ON      =  0 ; 	--   On always
  CONSTANT TX8VISLED_OFF     =  1 ;	--   Off always

-- ------------------------------
-- PCI Read/Write 32-bit diagnostic mirror
--
CONSTANT TX8MIRROR        = H"06" ;	-- Reads back what's written

-- ------------------------------
-- General purpose Counter/Timers
--
CONSTANT TX8TIMER0        = H"08" ;	-- Timers 0-2 Control/Status
CONSTANT TX8TIMER1        = H"09" ;
CONSTANT TX8TIMER2        = H"0A" ;

  CONSTANT TX8TIMER0_NBITS   = 20 ;	--   Number of bits in timers 0-2
  CONSTANT TX8TIMER1_NBITS   = 16 ;
  CONSTANT TX8TIMER2_NBITS   = 16 ;

  CONSTANT TX8TIMER_CLK1MHZ  =  0 ;	--   Clock = 1MHz

-- ------------------------------
-- Digital POT reference voltages for each Tx section
--
CONSTANT TX8POT           = H"0B" ;	-- Control register (no readback)
  CONSTANT TX8POT_CLKA       =  0 ;	--   Clock "A" channel
  CONSTANT TX8POT_UPA        =  1 ;	--   Count Up "A" channel
  CONSTANT TX8POT_CLKB       =  2 ;	--   Likewise for "B"
  CONSTANT TX8POT_UPB        =  3 ;

-- ------------------------------
-- BNC (External Clock) line configuration
--
CONSTANT TX8BNC           = H"0C" ;	-- Control/Status register
  CONSTANT TX8BNC_OUTDIV0    =  0 ;	--   Output clock divisor
  CONSTANT TX8BNC_OUTDIV1    =  1 ;
  CONSTANT TX8BNC_OUTDIV2    =  2 ;
  CONSTANT TX8BNC_OUTDIV3    =  3 ;
  CONSTANT TX8BNC_OUTDIV4    =  4 ;
  CONSTANT TX8BNC_MODE0      =  8 ;	--   Mode of operation (See definitions
  CONSTANT TX8BNC_MODE1      =  9 ;	--     below)
  CONSTANT TX8BNC_MODE2      = 10 ;

    CONSTANT TX8BNCMODE_INHIZ = 0 ;	-- BNC serves as High-Z digital input
    CONSTANT TX8BNCMODE_IN50Z = 1 ;	-- BNC serves as 50-Ohm digital input
    CONSTANT TX8BNCMODE_TXOUT = 2 ;	-- BNC outputs divided Tx clock
    CONSTANT TX8BNCMODE_RXOUT = 3 ;	-- BNC outputs divided Rx clock
    CONSTANT TX8BNCMODE_40OUT = 4 ;	-- BNC outputs divided 40MHz clock

-- ------------------------------
-- Master Tx Sampling Clock/VCXO for Rev.A/B/C boards
--
CONSTANT TX8CLKA          = H"0D" ;	-- Control/Status register
  CONSTANT TX8CLKA_DENOMLO   =  0 ;	--   Denominator (minus one)
  CONSTANT TX8CLKA_DENOMHI   =  8 ;
  CONSTANT TX8CLKA_NUMERLO   = 12 ;	--   Numerator (minus one)
  CONSTANT TX8CLKA_NUMERHI   = 20 ;
  CONSTANT TX8CLKA_PLLSRC0   = 24 ;	--   Reference clock source for locking
  CONSTANT TX8CLKA_PLLSRC1   = 25 ;	--     the PLL.
  CONSTANT TX8CLKA_PLLENAB   = 26 ;	--   Enable PLL feedback
  CONSTANT TX8CLKA_PLLERROR  = 27 ;	--   Locking error (sticky) since last RD

    CONSTANT TX8PLLSRC_BNC     = 0 ;	-- PLL locked to BNC input clock
    CONSTANT TX8PLLSRC_IFD     = 1 ;	-- PLL locked to IFD acquisition clock

-- ------------------------------
-- Master Tx Sampling Clock/VCXO for Rev.D boards
--
CONSTANT TX8CLKD          = H"0E" ;	-- Control/Status register
  CONSTANT TX8CLKD_PLL_LE    =  0 ;	--   Direct control of the LE, DATA,
  CONSTANT TX8CLKD_PLL_DATA  =  1 ;	--     and CLK serial inputs of the
  CONSTANT TX8CLKD_PLL_CLK   =  2 ;	--     LMX2306 PLL chip.
  CONSTANT TX8CLKD_PLLSRC0   =  4 ;	--   Reference clock source (use same
  CONSTANT TX8CLKD_PLLSRC1   =  5 ;	--     source definitions as above).
  CONSTANT TX8CLKD_PLLERROR  =  8 ;	--   Lock error (from chip LD pin)

-- ------------------------------
-- Softplane common control/status register.  Bit definitions can be
-- found in rda_modules.inc.
--
CONSTANT TX8SPLCOM        = H"0F" ;

-- ------------------------------
-- TxDAC Control/Status register for each AD9772A chip
--
CONSTANT TX8DACA          = H"10" ;	-- TxDAC "A" channel CSR
CONSTANT TX8DACB          = H"18" ;	-- TxDAC "B" channel CSR
  CONSTANT TX8DAC_MOD0       =  0 ;	--   Chip MOD0 line
  CONSTANT TX8DAC_MOD1       =  1 ;	--   Chip MOD1 line
  CONSTANT TX8DAC_DIV0       =  2 ;	--   Chip DIV0 line
  CONSTANT TX8DAC_DIV1       =  3 ;	--   Chip DIV1 line
  CONSTANT TX8DAC_PLLOCK     =  4 ;	--   Chip PLLOCK line (RD-Only)
  CONSTANT TX8DAC_PLLVDD     =  5 ;	--   Chip PLLVDD line (RD-Only)
  CONSTANT TX8DAC_NCOENAB    =  8 ;	--   Enable NCO functions
  CONSTANT TX8DAC_PULSED     =  9 ;	--   Pulsed output (vs CW)
  CONSTANT TX8DAC_PHASEMOD   = 10 ;	--   Apply phase modulation per pulse
  CONSTANT TX8DAC_ABRUPTPH   = 11 ;	--   Make abrupt phase changes

-- ------------------------------
-- TxDAC Numerically Controlled Oscillator (NCO) FREQ phase increment
-- register sets the output frequency as a binary angle increment.  The
-- FMOD register contains fractional p/q frequency control values that
-- let us generate most frequencies precisely, not just approximately.
-- The CW register holds fixed phase and amplitude offsets that are used
-- when waveform generation is OFF.  Don't bother making any of these
-- registers readable via PCI (to save gates).
--
CONSTANT TX8FREQA         = H"11" ;	-- TxDAC "A" channel frequency
CONSTANT TX8FMODA         = H"12" ;	-- TxDAC "A" fractional frequency
CONSTANT TX8CWA           = H"13" ;	-- TxDAC "A" CW phase/amplitude

CONSTANT TX8FREQB         = H"19" ;	-- TxDAC "B" channel frequency
CONSTANT TX8FMODB         = H"1A" ;	-- TxDAC "B" fractional frequency
CONSTANT TX8CWB           = H"1B" ;	-- TxDAC "B" CW phase/amplitude

-- ------------------------------
-- TxDAC common control elements
--
CONSTANT TX8DACOM         = H"20" ;	-- Control/Status register
  CONSTANT TX8DACOM_SYNCNCO  =  0 ;	--   Sync both chan's NCOs (WR-Only)

-- ************************************
-- *                                  *
-- * RVP8/Tx Master FPGA Memory Block *
-- *                                  *
-- ************************************

CONSTANT TX8MEMSZ        = H"80000" ;	-- Total memory size (512K DWORDs)
CONSTANT TX8MEMHIB = LOG2(TX8MEMSZ) - 1 ;

-- ************************************
-- *                                  *
-- * Global Circuit Board Definitions *
-- *                                  *
-- ************************************

-- ------------------------------
-- Interrupt UNIT assignments to ISR register
--
CONSTANT TX8INTUNIT_TIMER0   =  0 ;	-- Counter/Timer #0
CONSTANT TX8INTUNIT_TIMER1   =  1 ;	-- Counter/Timer #1
CONSTANT TX8INTUNIT_TIMER2   =  2 ;	-- Counter/Timer #2

-- Other hardware constants
--
CONSTANT TX8CLKFREQ    = 40000000 ;	-- Reference clock frequency
CONSTANT TX8BOOTMIDCLK = 0 ;		-- Boot data transitions on edges
