]> jspc29.x-matter.uni-frankfurt.de Git - mdcfee.git/commitdiff
Initial commit
authorJan Michel <j.michel@gsi.de>
Tue, 12 Apr 2016 09:37:08 +0000 (11:37 +0200)
committerJan Michel <j.michel@gsi.de>
Tue, 12 Apr 2016 09:37:08 +0000 (11:37 +0200)
24 files changed:
.kateproject [new file with mode: 0644]
code/ffarray.vhd [new file with mode: 0644]
cores/._Real_._Math_.vhd [new file with mode: 0644]
cores/generate_core.tcl [new file with mode: 0644]
cores/generate_ngd.tcl [new file with mode: 0644]
cores/msg_file.log [new file with mode: 0644]
cores/pll_4x266.edn [new file with mode: 0644]
cores/pll_4x266.ipx [new file with mode: 0644]
cores/pll_4x266.jhd [new file with mode: 0644]
cores/pll_4x266.lpc [new file with mode: 0644]
cores/pll_4x266.naf [new file with mode: 0644]
cores/pll_4x266.sort [new file with mode: 0644]
cores/pll_4x266.srp [new file with mode: 0644]
cores/pll_4x266.sym [new file with mode: 0644]
cores/pll_4x266.vhd [new file with mode: 0644]
cores/pll_4x266_generate.log [new file with mode: 0644]
cores/pll_4x266_tmpl.vhd [new file with mode: 0644]
dbowk/compile.pl [new file with mode: 0755]
dbowk/config_compile.pl [new file with mode: 0644]
dbowk/config_compile_frankfurt.pl [new file with mode: 0644]
dbowk/dbo.lpf [new file with mode: 0644]
dbowk/dbo.prj [new file with mode: 0644]
dbowk/dbo.vhd [new file with mode: 0644]
dbowk/par.p2t [new file with mode: 0644]

diff --git a/.kateproject b/.kateproject
new file mode 100644 (file)
index 0000000..d0829c9
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "name": "MdcFee"
+, "files": [ { "git": 1 } ]
+}
diff --git a/code/ffarray.vhd b/code/ffarray.vhd
new file mode 100644 (file)
index 0000000..52bd3ee
--- /dev/null
@@ -0,0 +1,109 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+use work.trb_net_std.all;
+
+
+entity ffarray is
+  port(
+    CLK        : in std_logic;
+    RESET_IN   : in std_logic;    
+    SIGNAL_IN  : in std_logic;
+    
+    DATA_OUT   : out std_logic_vector(8 downto 0);
+    READ_IN    : in  std_logic := '0';
+    EMPTY_OUT  : out std_logic := '0'
+    );
+end entity;
+
+architecture ffarray_arch of ffarray is
+
+attribute syn_hier : string;
+attribute syn_hier of ffarray_arch : architecture is "hard";
+  
+signal CLKt  : std_logic_vector(3 downto 0);
+signal CLKa  : std_logic_vector(7 downto 0);
+
+signal final1, final2     : std_logic_vector(7 downto 0);
+signal final_t   : std_logic_vector(7 downto 0);
+signal final     : std_logic_vector(8 downto 0);
+type ffarr_t is array(0 to 3) of std_logic_vector(7 downto 0);
+signal ffarr : ffarr_t;
+
+type ram_t  is array(0 to 1023) of std_logic_vector(7 downto 0);
+signal ram : ram_t;
+
+signal fifo_write, last : std_logic;
+
+
+  attribute syn_preserve : boolean;
+  attribute syn_keep : boolean;
+
+  attribute syn_preserve of CLKa : signal is true;
+  attribute syn_keep     of CLKa : signal is true;
+  attribute syn_preserve of CLKt : signal is true;
+  attribute syn_keep     of CLKt : signal is true;
+
+
+begin
+
+THE_PLL : entity work.pll_4x266
+  port map(
+    CLKI    => CLK,
+    CLKOP   => CLKt(0),
+    CLKOS   => CLKt(1),
+    CLKOS2  => CLKt(2),
+    CLKOS3  => CLKt(3)
+    );
+
+CLKa(3 downto 0) <= CLKt(3 downto 0);
+CLKa(7 downto 4) <= not CLKt(3 downto 0);
+
+gen_ffarr_first : for i in 0 to 7 generate
+  ffarr(0)(i) <= SIGNAL_IN when rising_edge(CLKa(i));
+  ffarr(1)(i) <= ffarr(0)(i) when rising_edge(CLKa((i/4)*4));
+  ffarr(2)(i) <= ffarr(1)(i) when rising_edge(CLKa(0));
+end generate;
+
+process begin
+  wait until falling_edge(CLK);
+  final_t <= ffarr(2);
+end process;
+
+
+process begin
+  wait until rising_edge(CLK);
+  final1 <= final_t;
+  final2 <= ffarr(2);
+  last   <= final2(7);
+  if (final1(7) xor last) = '1' then
+    fifo_write <= '1';
+    final <= final1 & last;
+  elsif (final2(7) xor final1(7)) = '1' then
+    fifo_write <= '1';
+    final <= final2 & final1(7);
+  else
+    fifo_write <= '0';
+  end if;
+end process;
+
+    
+THE_FIFO : entity work.fifo_9x2k_oreg
+  port map(
+    Data        => final,
+    WrClock     => CLK,
+    RdClock     => CLK, 
+    WrEn        => fifo_write, 
+    RdEn        => READ_IN,
+    Reset       => RESET_IN,
+    RPReset     => RESET_IN, 
+    Q           => DATA_OUT,
+    Empty       => EMPTY_OUT,
+    Full        => open,
+    AlmostEmpty => open,
+    AlmostFull  => open
+    );
+    
+end architecture;
\ No newline at end of file
diff --git a/cores/._Real_._Math_.vhd b/cores/._Real_._Math_.vhd
new file mode 100644 (file)
index 0000000..ad185b2
--- /dev/null
@@ -0,0 +1,2574 @@
+
+
+------------------------------------------------------------------------
+--
+-- Copyright 1996 by IEEE. All rights reserved.
+--
+-- This source file is an essential part of IEEE Std 1076.2-1996, IEEE Standard 
+-- VHDL Mathematical Packages. This source file may not be copied, sold, or 
+-- included with software that is sold without written permission from the IEEE
+-- Standards Department. This source file may be used to implement this standard 
+-- and may be distributed in compiled form in any manner so long as the 
+-- compiled form does not allow direct decompilation of the original source file.
+-- This source file may be copied for individual use between licensed users. 
+-- This source file is provided on an AS IS basis. The IEEE disclaims ANY 
+-- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY 
+-- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source 
+-- file shall indemnify and hold IEEE harmless from any damages or liability 
+-- arising out of the use thereof.
+--
+-- Title:       Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996, 
+--              MATH_REAL)
+--
+-- Library:     This package shall be compiled into a library
+--              symbolically named IEEE.
+--
+-- Developers:  IEEE DASC VHDL Mathematical Packages Working Group
+--
+-- Purpose:     This package defines a standard for designers to use in
+--              describing VHDL models that make use of common REAL constants
+--              and common REAL elementary mathematical functions.
+--
+-- Limitation:  The values generated by the functions in this package may
+--              vary from platform to platform, and the precision of results
+--              is only guaranteed to be the minimum required by IEEE Std 1076-
+--              1993.
+--
+-- Notes:
+--              No declarations or definitions shall be included in, or
+--              excluded from, this package.
+--              The "package declaration" defines the types, subtypes, and
+--              declarations of MATH_REAL.
+--              The standard mathematical definition and conventional meaning
+--              of the mathematical functions that are part of this standard
+--              represent the formal semantics of the implementation of the
+--              MATH_REAL package declaration.  The purpose of the MATH_REAL
+--              package body is to provide a guideline for implementations to
+--              verify their implementation of MATH_REAL.  Tool developers may
+--              choose to implement the package body in the most efficient
+--              manner available to them.
+--
+-- -----------------------------------------------------------------------------
+-- Version    : 1.5
+-- Date       : 24 July 1996
+-- -----------------------------------------------------------------------------
+
+package MATH_REAL is
+    constant CopyRightNotice: STRING
+      := "Copyright 1996 IEEE. All rights reserved.";
+
+    --
+    -- Constant Definitions
+    --
+    constant  MATH_E : REAL := 2.71828_18284_59045_23536;
+                                                      -- Value of e
+    constant  MATH_1_OVER_E : REAL := 0.36787_94411_71442_32160;
+                                                      -- Value of 1/e
+    constant  MATH_PI : REAL := 3.14159_26535_89793_23846;
+                                                      -- Value of pi
+    constant  MATH_2_PI : REAL := 6.28318_53071_79586_47693;
+                                                      -- Value of 2*pi
+    constant  MATH_1_OVER_PI : REAL := 0.31830_98861_83790_67154;
+                                                      -- Value of 1/pi
+    constant  MATH_PI_OVER_2 : REAL := 1.57079_63267_94896_61923;
+                                                      -- Value of pi/2
+    constant  MATH_PI_OVER_3 : REAL := 1.04719_75511_96597_74615;
+                                                      -- Value of pi/3
+    constant  MATH_PI_OVER_4 : REAL := 0.78539_81633_97448_30962;
+                                                      -- Value of pi/4
+    constant  MATH_3_PI_OVER_2 : REAL := 4.71238_89803_84689_85769;
+                                                      -- Value 3*pi/2
+    constant  MATH_LOG_OF_2 : REAL := 0.69314_71805_59945_30942;
+                                                      -- Natural log of 2
+    constant  MATH_LOG_OF_10 : REAL := 2.30258_50929_94045_68402;
+                                                      -- Natural log of 10
+    constant  MATH_LOG2_OF_E : REAL := 1.44269_50408_88963_4074;
+                                                      -- Log base 2 of e
+    constant  MATH_LOG10_OF_E: REAL := 0.43429_44819_03251_82765;
+                                                      -- Log base 10 of e
+    constant  MATH_SQRT_2: REAL := 1.41421_35623_73095_04880;
+                                                      -- square root of 2
+    constant  MATH_1_OVER_SQRT_2: REAL := 0.70710_67811_86547_52440;
+                                                      -- square root of 1/2
+    constant  MATH_SQRT_PI: REAL := 1.77245_38509_05516_02730;
+                                                      -- square root of pi
+    constant  MATH_DEG_TO_RAD: REAL := 0.01745_32925_19943_29577;
+                                     -- Conversion factor from degree to radian
+    constant  MATH_RAD_TO_DEG: REAL := 57.29577_95130_82320_87680;
+                                     -- Conversion factor from radian to degree
+
+    --
+    -- Function Declarations
+    --
+    function SIGN (X: in REAL ) return REAL;
+        -- Purpose:
+        --         Returns 1.0 if X > 0.0; 0.0 if X = 0.0; -1.0 if X < 0.0
+        -- Special values:
+        --         None
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ABS(SIGN(X)) <= 1.0
+        -- Notes:
+        --         None
+
+    function CEIL (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns smallest INTEGER value (as REAL) not less than X
+        -- Special values:
+        --         None
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         CEIL(X) is mathematically unbounded
+        -- Notes:
+        --         a) Implementations have to support at least the domain
+        --                ABS(X) < REAL(INTEGER'HIGH)
+
+    function FLOOR (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns largest INTEGER value (as REAL) not greater than X
+        -- Special values:
+        --         FLOOR(0.0) = 0.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         FLOOR(X) is mathematically unbounded
+        -- Notes:
+        --         a) Implementations have to support at least the domain
+        --                ABS(X) < REAL(INTEGER'HIGH)
+
+    function ROUND (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Rounds X to the nearest integer value (as real). If X is
+        --         halfway between two integers, rounding is away from 0.0
+        -- Special values:
+        --         ROUND(0.0) = 0.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ROUND(X) is mathematically unbounded
+        -- Notes:
+        --         a) Implementations have to support at least the domain
+        --                ABS(X) < REAL(INTEGER'HIGH)
+
+    function TRUNC (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Truncates X towards 0.0 and returns truncated value
+        -- Special values:
+        --         TRUNC(0.0) = 0.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         TRUNC(X) is mathematically unbounded
+        -- Notes:
+        --         a) Implementations have to support at least the domain
+        --                ABS(X) < REAL(INTEGER'HIGH)
+
+    function "MOD" (X, Y: in REAL ) return REAL;
+        -- Purpose:
+        --         Returns floating point modulus of X/Y, with the same sign as
+        --         Y, and absolute value less than the absolute value of Y, and
+        --         for some INTEGER value N the result satisfies the relation
+        --         X = Y*N + MOD(X,Y)
+        -- Special values:
+        --         None
+        -- Domain:
+        --         X in REAL; Y in REAL and Y /= 0.0
+        -- Error conditions:
+        --         Error if Y = 0.0
+        -- Range:
+        --         ABS(MOD(X,Y)) < ABS(Y)
+        -- Notes:
+        --         None
+
+    function REALMAX (X, Y : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns the algebraically larger of X and Y
+        -- Special values:
+        --         REALMAX(X,Y) = X when X = Y
+        -- Domain:
+        --         X in REAL; Y in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         REALMAX(X,Y) is mathematically unbounded
+        -- Notes:
+        --         None
+
+    function REALMIN (X, Y : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns the algebraically smaller of X and Y
+        -- Special values:
+        --         REALMIN(X,Y) = X when X = Y
+        -- Domain:
+        --         X in REAL; Y in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         REALMIN(X,Y) is mathematically unbounded
+        -- Notes:
+        --         None
+
+    procedure UNIFORM(variable SEED1,SEED2:inout POSITIVE; variable X:out REAL);
+        -- Purpose:
+        --         Returns, in X, a pseudo-random number with uniform
+        --         distribution in the open interval (0.0, 1.0).
+        -- Special values:
+        --         None
+        -- Domain:
+        --         1 <= SEED1 <= 2147483562; 1 <= SEED2 <= 2147483398
+        -- Error conditions:
+        --         Error if SEED1 or SEED2 outside of valid domain
+        -- Range:
+        --         0.0 < X < 1.0
+        -- Notes:
+        --         a) The semantics for this function are described by the
+        --            algorithm published by Pierre L'Ecuyer in "Communications
+        --            of the ACM," vol. 31, no. 6, June 1988, pp. 742-774.
+        --            The algorithm is based on the combination of two
+        --            multiplicative linear congruential generators for 32-bit
+        --            platforms.
+        --
+        --         b) Before the first call to UNIFORM, the seed values
+        --            (SEED1, SEED2) have to be initialized to values in the range
+        --            [1, 2147483562] and [1, 2147483398] respectively.  The
+        --            seed values are modified after each call to UNIFORM.
+        --
+        --         c) This random number generator is portable for 32-bit
+        --            computers, and it has a period of ~2.30584*(10**18) for each
+        --            set of seed values.
+        --
+        --         d) For information on spectral tests for the algorithm, refer
+        --            to the L'Ecuyer article.
+
+    function SQRT (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns square root of X
+        -- Special values:
+        --         SQRT(0.0) = 0.0
+        --         SQRT(1.0) = 1.0
+        -- Domain:
+        --         X >= 0.0
+        -- Error conditions:
+        --         Error if X < 0.0
+        -- Range:
+        --         SQRT(X) >= 0.0
+        -- Notes:
+        --         a) The upper bound of the reachable range of SQRT is
+        --            approximately given by:
+        --                SQRT(X) <= SQRT(REAL'HIGH)
+
+    function CBRT (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns cube root of X
+        -- Special values:
+        --         CBRT(0.0) = 0.0
+        --         CBRT(1.0) = 1.0
+        --         CBRT(-1.0) = -1.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         CBRT(X) is mathematically unbounded
+        -- Notes:
+        --         a) The reachable range of CBRT is approximately given by:
+        --                ABS(CBRT(X)) <= CBRT(REAL'HIGH)
+
+    function "**" (X : in INTEGER; Y : in REAL) return REAL;
+        -- Purpose:
+        --         Returns Y power of X ==>  X**Y
+        -- Special values:
+        --         X**0.0 = 1.0; X /= 0
+        --         0**Y = 0.0; Y > 0.0
+        --         X**1.0 = REAL(X); X >= 0
+        --         1**Y = 1.0
+        -- Domain:
+        --         X > 0
+        --         X = 0 for Y > 0.0
+        --         X < 0 for Y = 0.0
+        -- Error conditions:
+        --         Error if X < 0 and Y /= 0.0
+        --         Error if X = 0 and Y <= 0.0
+        -- Range:
+        --         X**Y >= 0.0
+        -- Notes:
+        --         a) The upper bound of the reachable range for "**" is
+        --            approximately given by:
+        --                X**Y <= REAL'HIGH
+
+    function "**" (X : in REAL; Y : in REAL) return REAL;
+        -- Purpose:
+        --         Returns Y power of X ==>  X**Y
+        -- Special values:
+        --         X**0.0 = 1.0; X /= 0.0
+        --         0.0**Y = 0.0; Y > 0.0
+        --         X**1.0 = X; X >= 0.0
+        --         1.0**Y = 1.0
+        -- Domain:
+        --         X > 0.0
+        --         X = 0.0 for Y > 0.0
+        --         X < 0.0 for Y = 0.0
+        -- Error conditions:
+        --         Error if X < 0.0 and Y /= 0.0
+        --         Error if X = 0.0 and Y <= 0.0
+        -- Range:
+        --         X**Y >= 0.0
+        -- Notes:
+        --         a) The upper bound of the reachable range for "**" is
+        --            approximately given by:
+        --                X**Y <= REAL'HIGH
+
+    function EXP (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns e**X; where e = MATH_E
+        -- Special values:
+        --         EXP(0.0) = 1.0
+        --         EXP(1.0) = MATH_E
+        --         EXP(-1.0) = MATH_1_OVER_E
+        --         EXP(X) = 0.0 for X <= -LOG(REAL'HIGH)
+        -- Domain:
+        --         X in REAL such that EXP(X) <= REAL'HIGH
+        -- Error conditions:
+        --         Error if X > LOG(REAL'HIGH)
+        -- Range:
+        --         EXP(X) >= 0.0
+        -- Notes:
+        --         a) The usable domain of EXP is approximately given by:
+        --                X <= LOG(REAL'HIGH)
+
+    function LOG (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns natural logarithm of X
+        -- Special values:
+        --         LOG(1.0) = 0.0
+        --         LOG(MATH_E) = 1.0
+        -- Domain:
+        --         X > 0.0
+        -- Error conditions:
+        --         Error if X <= 0.0
+        -- Range:
+        --         LOG(X) is mathematically unbounded
+        -- Notes:
+        --         a) The reachable range of LOG is approximately given by:
+        --                LOG(0+) <= LOG(X) <= LOG(REAL'HIGH)
+
+    function LOG2 (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns logarithm base 2 of X
+        -- Special values:
+        --         LOG2(1.0) = 0.0
+        --         LOG2(2.0) = 1.0
+        -- Domain:
+        --         X > 0.0
+        -- Error conditions:
+        --         Error if X <= 0.0
+        -- Range:
+        --         LOG2(X) is mathematically unbounded
+        -- Notes:
+        --         a) The reachable range of LOG2 is approximately given by:
+        --                LOG2(0+) <= LOG2(X) <= LOG2(REAL'HIGH)
+
+    function LOG10 (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns logarithm base 10 of X
+        -- Special values:
+        --         LOG10(1.0) = 0.0
+        --         LOG10(10.0) = 1.0
+        -- Domain:
+        --         X > 0.0
+        -- Error conditions:
+        --         Error if X <= 0.0
+        -- Range:
+        --         LOG10(X) is mathematically unbounded
+        -- Notes:
+        --         a) The reachable range of LOG10 is approximately given by:
+        --                LOG10(0+) <= LOG10(X) <= LOG10(REAL'HIGH)
+
+    function LOG (X: in REAL; BASE: in REAL) return REAL;
+        -- Purpose:
+        --         Returns logarithm base BASE of X
+        -- Special values:
+        --         LOG(1.0, BASE) = 0.0
+        --         LOG(BASE, BASE) = 1.0
+        -- Domain:
+        --         X > 0.0
+        --         BASE > 0.0
+        --         BASE /= 1.0
+        -- Error conditions:
+        --         Error if X <= 0.0
+        --         Error if BASE <= 0.0
+        --         Error if BASE = 1.0
+        -- Range:
+        --         LOG(X, BASE) is mathematically unbounded
+        -- Notes:
+        --         a) When BASE > 1.0, the reachable range of LOG is
+        --            approximately given by:
+        --                LOG(0+, BASE) <= LOG(X, BASE) <= LOG(REAL'HIGH, BASE)
+        --         b) When 0.0 < BASE < 1.0, the reachable range of LOG is
+        --            approximately given by:
+        --                LOG(REAL'HIGH, BASE) <= LOG(X, BASE) <= LOG(0+, BASE)
+
+    function  SIN (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns sine of X; X in radians
+        -- Special values:
+        --         SIN(X) = 0.0 for X = k*MATH_PI, where k is an INTEGER
+        --         SIN(X) = 1.0 for X = (4*k+1)*MATH_PI_OVER_2, where k is an
+        --                                                           INTEGER
+        --         SIN(X) = -1.0 for X = (4*k+3)*MATH_PI_OVER_2, where k is an
+        --                                                           INTEGER
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ABS(SIN(X)) <= 1.0
+        -- Notes:
+        --         a) For larger values of ABS(X), degraded accuracy is allowed.
+
+    function  COS ( X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns cosine of X; X in radians
+        -- Special values:
+        --         COS(X) = 0.0 for X = (2*k+1)*MATH_PI_OVER_2, where k is an
+        --                                                            INTEGER
+        --         COS(X) = 1.0 for X = (2*k)*MATH_PI, where k is an INTEGER
+        --         COS(X) = -1.0 for X = (2*k+1)*MATH_PI, where k is an INTEGER
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ABS(COS(X)) <= 1.0
+        -- Notes:
+        --         a) For larger values of ABS(X), degraded accuracy is allowed.
+
+    function  TAN (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns tangent of X; X in radians
+        -- Special values:
+        --         TAN(X) = 0.0 for X = k*MATH_PI, where k is an INTEGER
+        -- Domain:
+        --         X in REAL and
+        --         X /= (2*k+1)*MATH_PI_OVER_2, where k is an INTEGER
+        -- Error conditions:
+        --         Error if X = ((2*k+1) * MATH_PI_OVER_2), where k is an
+        --                                                           INTEGER
+        -- Range:
+        --         TAN(X) is mathematically unbounded
+        -- Notes:
+        --         a) For larger values of ABS(X), degraded accuracy is allowed.
+
+    function  ARCSIN (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns inverse sine of X
+        -- Special values:
+        --         ARCSIN(0.0) = 0.0
+        --         ARCSIN(1.0) = MATH_PI_OVER_2
+        --         ARCSIN(-1.0) = -MATH_PI_OVER_2
+        -- Domain:
+        --         ABS(X) <= 1.0
+        -- Error conditions:
+        --         Error if ABS(X) > 1.0
+        -- Range:
+        --         ABS(ARCSIN(X) <= MATH_PI_OVER_2
+        -- Notes:
+        --         None
+
+    function  ARCCOS (X : in REAL ) return REAL;
+        -- Purpose:
+        --         Returns inverse cosine of X
+        -- Special values:
+        --         ARCCOS(1.0) = 0.0
+        --         ARCCOS(0.0) = MATH_PI_OVER_2
+        --         ARCCOS(-1.0) = MATH_PI
+        -- Domain:
+        --         ABS(X) <= 1.0
+        -- Error conditions:
+        --         Error if ABS(X) > 1.0
+        -- Range:
+        --         0.0 <= ARCCOS(X) <= MATH_PI
+        -- Notes:
+        --         None
+
+    function  ARCTAN (Y : in REAL) return REAL;
+        -- Purpose:
+        --         Returns the value of the angle in radians of the point
+        --        (1.0, Y), which is in rectangular coordinates
+        -- Special values:
+        --         ARCTAN(0.0) = 0.0
+        -- Domain:
+        --         Y in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ABS(ARCTAN(Y)) <= MATH_PI_OVER_2
+        -- Notes:
+        --         None
+
+    function  ARCTAN (Y : in REAL; X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns the principal value of the angle in radians of
+        --         the point (X, Y), which is in rectangular coordinates
+        -- Special values:
+        --         ARCTAN(0.0, X) = 0.0 if X > 0.0
+        --         ARCTAN(0.0, X) = MATH_PI if X < 0.0
+        --         ARCTAN(Y, 0.0) = MATH_PI_OVER_2 if Y > 0.0
+        --         ARCTAN(Y, 0.0) = -MATH_PI_OVER_2 if Y < 0.0
+        -- Domain:
+        --         Y in REAL
+        --         X in REAL, X /= 0.0 when Y = 0.0
+        -- Error conditions:
+        --         Error if X = 0.0 and Y = 0.0
+        -- Range:
+        --         -MATH_PI < ARCTAN(Y,X) <= MATH_PI
+        -- Notes:
+        --         None
+
+    function SINH (X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns hyperbolic sine of X
+        -- Special values:
+        --         SINH(0.0) = 0.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         SINH(X) is mathematically unbounded
+        -- Notes:
+        --         a) The usable domain of SINH is approximately given by:
+        --                ABS(X) <= LOG(REAL'HIGH)
+
+
+    function COSH (X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns hyperbolic cosine of X
+        -- Special values:
+        --         COSH(0.0) = 1.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         COSH(X) >= 1.0
+        -- Notes:
+        --         a) The usable domain of COSH is approximately given by:
+        --                ABS(X) <= LOG(REAL'HIGH)
+
+    function TANH (X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns hyperbolic tangent of X
+        -- Special values:
+        --         TANH(0.0) = 0.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ABS(TANH(X)) <= 1.0
+        -- Notes:
+        --         None
+
+    function ARCSINH (X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns inverse hyperbolic sine of X
+        -- Special values:
+        --         ARCSINH(0.0) = 0.0
+        -- Domain:
+        --         X in REAL
+        -- Error conditions:
+        --         None
+        -- Range:
+        --         ARCSINH(X) is mathematically unbounded
+        -- Notes:
+        --         a) The reachable range of ARCSINH is approximately given by:
+        --                ABS(ARCSINH(X)) <= LOG(REAL'HIGH)
+
+    function ARCCOSH (X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns inverse hyperbolic cosine of X
+        -- Special values:
+        --         ARCCOSH(1.0) = 0.0
+        -- Domain:
+        --         X >= 1.0
+        -- Error conditions:
+        --         Error if X < 1.0
+        -- Range:
+        --         ARCCOSH(X) >= 0.0
+        -- Notes:
+        --         a) The upper bound of the reachable range of ARCCOSH is
+        --            approximately given by:   ARCCOSH(X) <= LOG(REAL'HIGH)
+
+    function ARCTANH (X : in REAL) return REAL;
+        -- Purpose:
+        --         Returns inverse hyperbolic tangent of X
+        -- Special values:
+        --         ARCTANH(0.0) = 0.0
+        -- Domain:
+        --         ABS(X) < 1.0
+        -- Error conditions:
+        --         Error if ABS(X) >= 1.0
+        -- Range:
+        --         ARCTANH(X) is mathematically unbounded
+        -- Notes:
+        --         a) The reachable range of ARCTANH is approximately given by:
+        --                ABS(ARCTANH(X)) < LOG(REAL'HIGH)
+
+end  MATH_REAL;
+
+
+
+------------------------------------------------------------------------
+--
+-- Copyright 1996 by IEEE. All rights reserved.
+
+-- This source file is an informative part of IEEE Std 1076.2-1996, IEEE Standard 
+-- VHDL Mathematical Packages. This source file may not be copied, sold, or 
+-- included with software that is sold without written permission from the IEEE
+-- Standards Department. This source file may be used to implement this standard 
+-- and may be distributed in compiled form in any manner so long as the 
+-- compiled form does not allow direct decompilation of the original source file.
+-- This source file may be copied for individual use between licensed users. 
+-- This source file is provided on an AS IS basis. The IEEE disclaims ANY 
+-- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY 
+-- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source 
+-- file shall indemnify and hold IEEE harmless from any damages or liability 
+-- arising out of the use thereof.
+
+--
+-- Title:       Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996,
+--              MATH_REAL)
+--
+-- Library:     This package shall be compiled into a library
+--              symbolically named IEEE.
+--
+-- Developers:  IEEE DASC VHDL Mathematical Packages Working Group
+--
+-- Purpose:     This package body is a nonnormative implementation of the 
+--              functionality defined in the MATH_REAL package declaration.
+--
+-- Limitation:  The values generated by the functions in this package may
+--              vary from platform to platform, and the precision of results
+--              is only guaranteed to be the minimum required by IEEE Std 1076
+--              -1993.
+--
+-- Notes:
+--              The "package declaration" defines the types, subtypes, and
+--              declarations of MATH_REAL.
+--              The standard mathematical definition and conventional meaning
+--              of the mathematical functions that are part of this standard
+--              represent the formal semantics of the implementation of the
+--              MATH_REAL package declaration.  The purpose of the MATH_REAL
+--              package body is to clarify such semantics and provide a
+--              guideline for implementations to verify their implementation
+--              of MATH_REAL.  Tool developers may choose to implement
+--              the package body in the most efficient manner available to them.
+--
+-- -----------------------------------------------------------------------------
+-- Version    : 1.5
+-- Date       : 24 July 1996
+-- -----------------------------------------------------------------------------
+
+package body MATH_REAL is
+
+    --
+    -- Local Constants for Use in the Package Body Only
+    --
+    constant  MATH_E_P2 :  REAL := 7.38905_60989_30650;   -- e**2
+    constant  MATH_E_P10 :  REAL := 22026.46579_48067_17; -- e**10
+    constant  MATH_EIGHT_PI : REAL := 25.13274_12287_18345_90770_115; --8*pi
+    constant  MAX_ITER:  INTEGER := 27;  -- Maximum precision factor for cordic
+    constant  MAX_COUNT: INTEGER := 150; -- Maximum count for number of tries
+    constant  BASE_EPS: REAL := 0.00001;  -- Factor for convergence criteria
+    constant  KC : REAL := 6.0725293500888142e-01; -- Constant for cordic
+
+    --
+    -- Local Type Declarations for Cordic Operations
+    --
+    type REAL_VECTOR is array (NATURAL range <>) of REAL;
+    type NATURAL_VECTOR is array (NATURAL range <>) of NATURAL;
+    subtype REAL_VECTOR_N is REAL_VECTOR (0 to MAX_ITER);
+    subtype REAL_ARR_2 is REAL_VECTOR (0 to 1);
+    subtype REAL_ARR_3 is REAL_VECTOR (0 to 2);
+    subtype QUADRANT is INTEGER range 0 to 3;
+    type CORDIC_MODE_TYPE is (ROTATION, VECTORING);
+
+    --
+    -- Auxiliary Functions for Cordic Algorithms
+    --
+    function POWER_OF_2_SERIES (D : in NATURAL_VECTOR; INITIAL_VALUE : in REAL;
+                NUMBER_OF_VALUES : in NATURAL) return REAL_VECTOR is
+        -- Description:
+        --        Returns power of two for a vector of values
+        -- Notes:
+        --        None
+        --
+        variable V : REAL_VECTOR (0 to NUMBER_OF_VALUES);
+        variable TEMP : REAL := INITIAL_VALUE;
+        variable FLAG : BOOLEAN := TRUE;
+    begin
+              for I in 0 to NUMBER_OF_VALUES loop
+                 V(I) := TEMP;
+                 for P in D'RANGE loop
+                            if I = D(P) then
+                                FLAG := FALSE;
+                                exit;
+                            end if;
+                 end loop;
+                 if FLAG then
+                            TEMP := TEMP/2.0;
+                 end if;
+                 FLAG := TRUE;
+              end loop;
+              return V;
+    end POWER_OF_2_SERIES;
+
+
+    constant TWO_AT_MINUS : REAL_VECTOR := POWER_OF_2_SERIES(
+                                               NATURAL_VECTOR'(100, 90),1.0,
+                                                                  MAX_ITER);
+
+    constant EPSILON : REAL_VECTOR_N := (
+                                        7.8539816339744827e-01,
+                                        4.6364760900080606e-01,
+                                        2.4497866312686413e-01,
+                                        1.2435499454676144e-01,
+                                        6.2418809995957351e-02,
+                                        3.1239833430268277e-02,
+                                        1.5623728620476830e-02,
+                                        7.8123410601011116e-03,
+                                        3.9062301319669717e-03,
+                                        1.9531225164788189e-03,
+                                        9.7656218955931937e-04,
+                                        4.8828121119489829e-04,
+                                        2.4414062014936175e-04,
+                                        1.2207031189367021e-04,
+                                        6.1035156174208768e-05,
+                                        3.0517578115526093e-05,
+                                        1.5258789061315760e-05,
+                                        7.6293945311019699e-06,
+                                        3.8146972656064960e-06,
+                                        1.9073486328101870e-06,
+                                        9.5367431640596080e-07,
+                                        4.7683715820308876e-07,
+                                        2.3841857910155801e-07,
+                                        1.1920928955078067e-07,
+                                        5.9604644775390553e-08,
+                                        2.9802322387695303e-08,
+                                        1.4901161193847654e-08,
+                                        7.4505805969238281e-09
+                                       );
+
+    function CORDIC ( X0 : in REAL;
+                      Y0 : in REAL;
+                      Z0 : in REAL;
+                      N : in NATURAL;                 --  Precision factor
+            CORDIC_MODE : in CORDIC_MODE_TYPE         --  Rotation (Z -> 0)
+                                                      --  or vectoring (Y -> 0)
+                    ) return REAL_ARR_3 is
+        -- Description:
+        --        Compute cordic values
+        -- Notes:
+        --         None
+             variable X : REAL := X0;
+             variable Y : REAL := Y0;
+             variable Z : REAL := Z0;
+             variable X_TEMP : REAL;
+    begin
+       if CORDIC_MODE = ROTATION then
+           for K in 0 to N loop
+                      X_TEMP := X;
+                      if ( Z >= 0.0) then
+                               X := X - Y * TWO_AT_MINUS(K);
+                               Y := Y + X_TEMP * TWO_AT_MINUS(K);
+                               Z := Z - EPSILON(K);
+                      else
+                               X := X + Y * TWO_AT_MINUS(K);
+                               Y := Y - X_TEMP * TWO_AT_MINUS(K);
+                               Z := Z + EPSILON(K);
+                      end if;
+            end loop;
+        else
+            for K in 0 to N loop
+                    X_TEMP := X;
+                    if ( Y < 0.0) then
+                               X := X - Y * TWO_AT_MINUS(K);
+                               Y := Y + X_TEMP * TWO_AT_MINUS(K);
+                               Z := Z - EPSILON(K);
+                    else
+                               X := X + Y * TWO_AT_MINUS(K);
+                               Y := Y - X_TEMP * TWO_AT_MINUS(K);
+                               Z := Z + EPSILON(K);
+                    end if;
+            end loop;
+        end if;
+        return REAL_ARR_3'(X, Y, Z);
+    end CORDIC;
+
+    --
+    -- Bodies for Global Mathematical Functions Start Here
+    --
+    function SIGN (X: in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        None
+    begin
+           if  ( X > 0.0 )  then
+                return 1.0;
+           elsif ( X < 0.0 )  then
+                return -1.0;
+           else
+                return 0.0;
+           end if;
+    end SIGN;
+
+    function CEIL (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) No conversion to an INTEGER type is expected, so truncate
+        --           cannot overflow for large arguments
+        --        b) The domain supported by this function is X <= LARGE
+        --        c) Returns X if ABS(X) >= LARGE
+
+        constant LARGE: REAL  := REAL(INTEGER'HIGH);
+        variable RD: REAL;
+
+    begin
+         if ABS(X) >= LARGE then
+               return X;
+         end if;
+
+         RD := REAL ( INTEGER(X));
+         if RD = X then
+            return X;
+         end if;
+
+            if X > 0.0 then
+                       if RD >= X then
+                                  return RD;
+                       else
+                                  return RD + 1.0;
+                       end if;
+            elsif  X = 0.0  then
+                return 0.0;
+            else
+                       if RD <= X then
+                                  return RD + 1.0;
+                       else
+                                  return RD;
+                       end if;
+            end if;
+    end CEIL;
+
+    function FLOOR (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) No conversion to an INTEGER type is expected, so truncate
+        --           cannot overflow for large arguments
+        --        b) The domain supported by this function is ABS(X) <= LARGE
+        --        c) Returns X if ABS(X) >= LARGE
+
+        constant LARGE: REAL  := REAL(INTEGER'HIGH);
+        variable RD: REAL;
+
+    begin
+        if ABS( X ) >= LARGE then
+                    return X;
+        end if;
+
+        RD := REAL ( INTEGER(X));
+        if RD = X then
+                return X;
+        end if;
+
+        if X > 0.0 then
+                      if RD <= X then
+                                  return RD;
+                       else
+                                  return RD - 1.0;
+                       end if;
+        elsif  X = 0.0  then
+                return 0.0;
+        else
+                   if RD >= X then
+                                  return RD - 1.0;
+                   else
+                                  return RD;
+                   end if;
+        end if;
+    end FLOOR;
+
+    function ROUND (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --         a) Returns 0.0 if X = 0.0
+        --         b) Returns FLOOR(X + 0.5) if X > 0
+        --         c) Returns CEIL(X - 0.5) if X < 0
+
+    begin
+           if  X > 0.0  then
+                return FLOOR(X + 0.5);
+           elsif  X < 0.0  then
+                return CEIL( X - 0.5);
+           else
+                return 0.0;
+           end if;
+    end ROUND;
+
+    function TRUNC (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --         a) Returns 0.0 if X = 0.0
+        --         b) Returns FLOOR(X) if X > 0
+        --         c) Returns CEIL(X) if X < 0
+
+    begin
+           if  X > 0.0  then
+                return FLOOR(X);
+           elsif  X < 0.0  then
+                return CEIL( X);
+           else
+                return 0.0;
+           end if;
+    end TRUNC;
+
+
+
+
+    function "MOD" (X, Y: in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns 0.0 on error
+
+        variable XNEGATIVE : BOOLEAN := X < 0.0;
+        variable YNEGATIVE : BOOLEAN := Y < 0.0;
+        variable VALUE : REAL;
+    begin
+        -- Check validity of input arguments
+            if (Y = 0.0) then
+                 assert FALSE
+                        report "MOD(X, 0.0) is undefined"
+                        severity ERROR;
+                 return 0.0;
+              end if;
+
+        -- Compute value
+        if ( XNEGATIVE ) then
+                if ( YNEGATIVE ) then
+                        VALUE := X + (FLOOR(ABS(X)/ABS(Y)))*ABS(Y);
+                else
+                        VALUE := X + (CEIL(ABS(X)/ABS(Y)))*ABS(Y);
+                end if;
+        else
+                if ( YNEGATIVE ) then
+                        VALUE := X - (CEIL(ABS(X)/ABS(Y)))*ABS(Y);
+                else
+                        VALUE := X - (FLOOR(ABS(X)/ABS(Y)))*ABS(Y);
+                end if;
+        end if;
+
+        return VALUE;
+    end "MOD";
+
+
+    function REALMAX (X, Y : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) REALMAX(X,Y) = X when X = Y
+        --
+    begin
+        if X >= Y then
+           return X;
+        else
+           return Y;
+        end if;
+    end REALMAX;
+
+    function REALMIN (X, Y : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) REALMIN(X,Y) = X when X = Y
+        --
+    begin
+        if X <= Y then
+           return X;
+        else
+           return Y;
+        end if;
+    end REALMIN;
+
+
+    procedure UNIFORM(variable SEED1,SEED2:inout POSITIVE;variable X:out REAL)
+                                                                         is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns 0.0 on error
+        --
+        variable Z, K: INTEGER;
+        variable TSEED1 : INTEGER := INTEGER'(SEED1);
+        variable TSEED2 : INTEGER := INTEGER'(SEED2);
+    begin
+        -- Check validity of arguments
+        if SEED1 > 2147483562 then
+                assert FALSE
+                        report "SEED1 > 2147483562 in UNIFORM"
+                        severity ERROR;
+                X := 0.0;
+                return;
+        end if;
+
+        if SEED2 > 2147483398 then
+                assert FALSE
+                        report "SEED2 > 2147483398 in UNIFORM"
+                        severity ERROR;
+                X := 0.0;
+                return;
+        end if;
+
+        -- Compute new seed values and pseudo-random number
+        K := TSEED1/53668;
+        TSEED1 := 40014 * (TSEED1 - K * 53668) - K * 12211;
+
+        if TSEED1 < 0  then
+                TSEED1 := TSEED1 + 2147483563;
+        end if;
+
+        K := TSEED2/52774;
+        TSEED2 := 40692 * (TSEED2 - K * 52774) - K * 3791;
+
+        if TSEED2 < 0  then
+                TSEED2 := TSEED2 + 2147483399;
+        end if;
+
+        Z := TSEED1 - TSEED2;
+        if Z < 1 then
+                Z := Z + 2147483562;
+        end if;
+
+        -- Get output values
+        SEED1 := POSITIVE'(TSEED1);
+        SEED2 := POSITIVE'(TSEED2);
+        X :=  REAL(Z)*4.656613e-10;
+    end UNIFORM;
+
+
+
+    function SQRT (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Uses the Newton-Raphson approximation:
+        --            F(n+1) = 0.5*[F(n) + x/F(n)]
+        --        b) Returns 0.0 on error
+        --
+
+        constant EPS : REAL := BASE_EPS*BASE_EPS; -- Convergence factor
+
+        variable INIVAL: REAL;
+        variable OLDVAL : REAL ;
+        variable NEWVAL : REAL ;
+        variable COUNT : INTEGER := 1;
+
+    begin
+        -- Check validity of argument
+        if ( X < 0.0 ) then
+                assert FALSE
+                        report "X < 0.0 in SQRT(X)"
+                        severity ERROR;
+                return 0.0;
+        end if;
+
+        -- Get the square root for special cases
+        if X = 0.0 then
+                  return 0.0;
+        else
+                if ( X = 1.0 ) then
+                        return 1.0;
+                end if;
+        end if;
+
+        -- Get the square root for general cases
+        INIVAL := EXP(LOG(X)*(0.5)); -- Mathematically correct but imprecise
+        OLDVAL := INIVAL;
+        NEWVAL := (X/OLDVAL + OLDVAL)*0.5;
+
+        -- Check for  relative and absolute error and max count
+        while  ( ( (ABS((NEWVAL -OLDVAL)/NEWVAL) > EPS) OR
+                   (ABS(NEWVAL - OLDVAL) > EPS) ) AND
+                   (COUNT < MAX_COUNT) )  loop
+                OLDVAL := NEWVAL;
+                NEWVAL := (X/OLDVAL + OLDVAL)*0.5;
+                COUNT := COUNT + 1;
+        end loop;
+        return NEWVAL;
+    end SQRT;
+
+    function CBRT (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Uses the Newton-Raphson approximation:
+        --            F(n+1) = (1/3)*[2*F(n) + x/F(n)**2];
+        --
+        constant EPS : REAL := BASE_EPS*BASE_EPS;
+
+        variable INIVAL: REAL;
+        variable XLOCAL : REAL := X;
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable OLDVAL : REAL ;
+        variable NEWVAL : REAL ;
+        variable COUNT : INTEGER := 1;
+
+    begin
+
+        -- Compute root for special cases
+        if X = 0.0 then
+                return 0.0;
+        elsif ( X = 1.0 ) then
+                return 1.0;
+        else
+                if X = -1.0 then
+                        return -1.0;
+                end if;
+        end if;
+
+        -- Compute root for general cases
+        if NEGATIVE then
+                XLOCAL := -X;
+        end if;
+
+        INIVAL := EXP(LOG(XLOCAL)/(3.0)); -- Mathematically correct but
+                                          -- imprecise
+        OLDVAL := INIVAL;
+        NEWVAL := (XLOCAL/(OLDVAL*OLDVAL) + 2.0*OLDVAL)/3.0;
+
+        -- Check for relative and absolute errors and max count
+        while ( (  (ABS((NEWVAL -OLDVAL)/NEWVAL) > EPS ) OR
+                   (ABS(NEWVAL - OLDVAL) > EPS ) )  AND
+                   ( COUNT < MAX_COUNT ) ) loop
+                OLDVAL := NEWVAL;
+                NEWVAL :=(XLOCAL/(OLDVAL*OLDVAL) + 2.0*OLDVAL)/3.0;
+                COUNT := COUNT + 1;
+        end loop;
+
+        if NEGATIVE then
+                NEWVAL := -NEWVAL;
+        end if;
+
+        return NEWVAL;
+    end CBRT;
+
+    function "**" (X : in INTEGER; Y : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns 0.0 on error condition
+
+    begin
+        -- Check validity of argument
+        if ( ( X < 0  ) and ( Y /= 0.0 ) ) then
+                assert FALSE
+                        report "X < 0 and Y /= 0.0 in X**Y"
+                        severity ERROR;
+                return 0.0;
+        end if;
+
+        if ( ( X = 0  ) and ( Y <= 0.0 ) ) then
+                assert FALSE
+                        report "X = 0 and Y <= 0.0 in X**Y"
+                        severity ERROR;
+                return 0.0;
+        end if;
+
+        -- Get value for special cases
+        if ( X = 0  and  Y > 0.0 ) then
+                return 0.0;
+        end if;
+
+        if ( X = 1 ) then
+                return 1.0;
+        end if;
+
+        if ( Y = 0.0 and X /= 0 ) then
+                return 1.0;
+        end if;
+
+        if ( Y = 1.0) then
+                return (REAL(X));
+        end if;
+
+        -- Get value for general case
+        return EXP (Y * LOG (REAL(X)));
+    end "**";
+
+    function "**" (X : in REAL; Y : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns 0.0 on error condition
+
+    begin
+        -- Check validity of argument
+        if ( ( X < 0.0  ) and ( Y /= 0.0 ) ) then
+                assert FALSE
+                        report "X < 0.0 and Y /= 0.0 in X**Y"
+                        severity ERROR;
+                return 0.0;
+        end if;
+
+        if ( ( X = 0.0  ) and ( Y <= 0.0 ) ) then
+                assert FALSE
+                        report "X = 0.0 and Y <= 0.0 in X**Y"
+                        severity ERROR;
+                return 0.0;
+        end if;
+
+        -- Get value for special cases
+        if ( X = 0.0  and  Y > 0.0 ) then
+                return 0.0;
+        end if;
+
+        if ( X = 1.0 ) then
+                return 1.0;
+        end if;
+
+        if ( Y = 0.0 and X /= 0.0 ) then
+                return 1.0;
+        end if;
+
+        if ( Y = 1.0) then
+                return (X);
+        end if;
+
+        -- Get value for general case
+        return EXP (Y * LOG (X));
+    end "**";
+
+    function EXP  (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) This function computes the exponential using the following
+        --           series:
+        --                exp(x) = 1 + x + x**2/2! + x**3/3! + ... ; |x| < 1.0
+        --           and reduces argument X to take advantage of exp(x+y) =
+        --           exp(x)*exp(y)
+        --
+        --        b) This implementation limits X to be less than LOG(REAL'HIGH)
+        --           to avoid overflow.  Returns REAL'HIGH when X reaches that
+        --           limit
+        --
+        constant EPS : REAL := BASE_EPS*BASE_EPS*BASE_EPS;-- Precision criteria
+
+            variable RECIPROCAL: BOOLEAN := X < 0.0;-- Check sign of argument
+            variable XLOCAL : REAL := ABS(X);       -- Use positive value
+            variable OLDVAL: REAL ;
+            variable COUNT: INTEGER ;
+            variable NEWVAL: REAL ;
+            variable LAST_TERM: REAL ;
+        variable FACTOR : REAL := 1.0;
+
+     begin
+            -- Compute value for special cases
+        if X = 0.0 then
+                return 1.0;
+        end if;
+
+        if  XLOCAL = 1.0  then
+                if RECIPROCAL then
+                        return MATH_1_OVER_E;
+                else
+                        return MATH_E;
+                end if;
+        end if;
+
+        if  XLOCAL = 2.0  then
+                if RECIPROCAL then
+                        return 1.0/MATH_E_P2;
+                else
+                        return MATH_E_P2;
+                end if;
+        end if;
+
+        if  XLOCAL = 10.0  then
+                if RECIPROCAL then
+                        return 1.0/MATH_E_P10;
+                else
+                        return MATH_E_P10;
+                end if;
+        end if;
+
+        if XLOCAL > LOG(REAL'HIGH) then
+                if RECIPROCAL then
+                        return 0.0;
+                else
+                        assert FALSE
+                                report "X > LOG(REAL'HIGH) in EXP(X)"
+                                severity NOTE;
+                        return REAL'HIGH;
+                end if;
+        end if;
+
+        -- Reduce argument to ABS(X) < 1.0
+        while XLOCAL > 10.0 loop
+                XLOCAL := XLOCAL - 10.0;
+                FACTOR := FACTOR*MATH_E_P10;
+        end loop;
+
+        while XLOCAL > 1.0 loop
+                XLOCAL := XLOCAL - 1.0;
+                FACTOR := FACTOR*MATH_E;
+        end loop;
+
+        -- Compute value for case 0 < XLOCAL < 1
+        OLDVAL := 1.0;
+        LAST_TERM := XLOCAL;
+        NEWVAL:= OLDVAL + LAST_TERM;
+        COUNT := 2;
+
+        -- Check for relative and absolute errors and max count
+        while ( ( (ABS((NEWVAL - OLDVAL)/NEWVAL) > EPS) OR
+                  (ABS(NEWVAL - OLDVAL) > EPS) ) AND
+                  (COUNT < MAX_COUNT ) ) loop
+                OLDVAL := NEWVAL;
+                LAST_TERM := LAST_TERM*(XLOCAL / (REAL(COUNT)));
+                NEWVAL := OLDVAL + LAST_TERM;
+                COUNT := COUNT + 1;
+        end loop;
+
+        -- Compute final value using exp(x+y) = exp(x)*exp(y)
+        NEWVAL := NEWVAL*FACTOR;
+
+        if RECIPROCAL then
+                NEWVAL := 1.0/NEWVAL;
+        end if;
+
+        return NEWVAL;
+     end EXP;
+
+
+    --
+    -- Auxiliary Functions to Compute LOG
+    --
+    function ILOGB(X: in REAL) return INTEGER IS
+        -- Description:
+        --        Returns n such that -1 <= ABS(X)/2^n < 2
+        -- Notes:
+        --        None
+
+        variable N: INTEGER := 0;
+        variable Y: REAL := ABS(X);
+
+    begin
+        if(Y = 1.0 or Y = 0.0) then
+                return 0;
+        end if;
+
+        if( Y > 1.0) then
+                while Y >= 2.0 loop
+                        Y := Y/2.0;
+                        N := N+1;
+                end loop;
+                return N;
+        end if;
+
+        -- O < Y < 1
+        while Y < 1.0 loop
+                Y := Y*2.0;
+                N := N -1;
+        end loop;
+        return N;
+    end ILOGB;
+
+    function LDEXP(X: in REAL; N: in INTEGER) RETURN REAL IS
+        -- Description:
+        --        Returns X*2^n
+        -- Notes:
+        --         None
+    begin
+        return X*(2.0 ** N);
+    end LDEXP;
+
+    function LOG (X : in REAL ) return REAL IS
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        --
+        -- Notes:
+        --        a) Returns REAL'LOW on error
+        --
+        -- Copyright (c) 1992 Regents of the University of California.
+        -- All rights reserved.
+        --
+        -- Redistribution and use in source and binary forms, with or without
+        -- modification, are permitted provided that the following conditions
+        -- are met:
+        -- 1. Redistributions of source code must retain the above copyright
+        -- notice, this list of conditions and the following disclaimer.
+        -- 2. Redistributions in binary form must reproduce the above copyright
+        -- notice, this list of conditions and the following disclaimer in the
+        -- documentation and/or other materials provided with the distribution.
+        -- 3. All advertising materials mentioning features or use of this
+        -- software must display the following acknowledgement:
+        -- This product includes software developed by the University of
+        -- California, Berkeley and its contributors.
+        -- 4. Neither the name of the University nor the names of its
+        -- contributors may be used to endorse or promote products derived
+        -- from this software without specific prior written permission.
+        --
+        -- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
+        -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+        -- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+        -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
+        -- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+        -- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+        -- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+        -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+        -- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+        -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+        -- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+        -- DAMAGE.
+        --
+        -- NOTE: This VHDL version was generated using the C version of the
+        --         original function by the IEEE VHDL Mathematical Package
+        --         Working Group (CS/JT)
+
+        constant N: INTEGER := 128;
+
+        -- Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
+        -- Used for generation of extend precision logarithms.
+        -- The constant 35184372088832 is 2^45, so the divide is exact.
+        -- It ensures correct reading of logF_head, even for inaccurate
+        -- decimal-to-binary conversion routines. (Everybody gets the
+        -- right answer for INTEGERs less than 2^53.)
+        -- Values for LOG(F) were generated using error < 10^-57 absolute
+        -- with the bc -l package.
+
+        type REAL_VECTOR is array (NATURAL range <>) of REAL;
+
+        constant A1:REAL := 0.08333333333333178827;
+        constant A2:REAL := 0.01250000000377174923;
+        constant A3:REAL := 0.002232139987919447809;
+        constant A4:REAL := 0.0004348877777076145742;
+
+        constant LOGF_HEAD: REAL_VECTOR(0 TO N) := (
+                0.0,
+                0.007782140442060381246,
+                0.015504186535963526694,
+                0.023167059281547608406,
+                0.030771658666765233647,
+                0.038318864302141264488,
+                0.045809536031242714670,
+                0.053244514518837604555,
+                0.060624621816486978786,
+                0.067950661908525944454,
+                0.075223421237524235039,
+                0.082443669210988446138,
+                0.089612158689760690322,
+                0.096729626458454731618,
+                0.103796793681567578460,
+                0.110814366340264314203,
+                0.117783035656430001836,
+                0.124703478501032805070,
+                0.131576357788617315236,
+                0.138402322859292326029,
+                0.145182009844575077295,
+                0.151916042025732167530,
+                0.158605030176659056451,
+                0.165249572895390883786,
+                0.171850256926518341060,
+                0.178407657472689606947,
+                0.184922338493834104156,
+                0.191394852999565046047,
+                0.197825743329758552135,
+                0.204215541428766300668,
+                0.210564769107350002741,
+                0.216873938300523150246,
+                0.223143551314024080056,
+                0.229374101064877322642,
+                0.235566071312860003672,
+                0.241719936886966024758,
+                0.247836163904594286577,
+                0.253915209980732470285,
+                0.259957524436686071567,
+                0.265963548496984003577,
+                0.271933715484010463114,
+                0.277868451003087102435,
+                0.283768173130738432519,
+                0.289633292582948342896,
+                0.295464212893421063199,
+                0.301261330578199704177,
+                0.307025035294827830512,
+                0.312755710004239517729,
+                0.318453731118097493890,
+                0.324119468654316733591,
+                0.329753286372579168528,
+                0.335355541920762334484,
+                0.340926586970454081892,
+                0.346466767346100823488,
+                0.351976423156884266063,
+                0.357455888922231679316,
+                0.362905493689140712376,
+                0.368325561158599157352,
+                0.373716409793814818840,
+                0.379078352934811846353,
+                0.384411698910298582632,
+                0.389716751140440464951,
+                0.394993808240542421117,
+                0.400243164127459749579,
+                0.405465108107819105498,
+                0.410659924985338875558,
+                0.415827895143593195825,
+                0.420969294644237379543,
+                0.426084395310681429691,
+                0.431173464818130014464,
+                0.436236766774527495726,
+                0.441274560805140936281,
+                0.446287102628048160113,
+                0.451274644139630254358,
+                0.456237433481874177232,
+                0.461175715122408291790,
+                0.466089729924533457960,
+                0.470979715219073113985,
+                0.475845904869856894947,
+                0.480688529345570714212,
+                0.485507815781602403149,
+                0.490303988045525329653,
+                0.495077266798034543171,
+                0.499827869556611403822,
+                0.504556010751912253908,
+                0.509261901790523552335,
+                0.513945751101346104405,
+                0.518607764208354637958,
+                0.523248143765158602036,
+                0.527867089620485785417,
+                0.532464798869114019908,
+                0.537041465897345915436,
+                0.541597282432121573947,
+                0.546132437597407260909,
+                0.550647117952394182793,
+                0.555141507540611200965,
+                0.559615787935399566777,
+                0.564070138285387656651,
+                0.568504735352689749561,
+                0.572919753562018740922,
+                0.577315365035246941260,
+                0.581691739635061821900,
+                0.586049045003164792433,
+                0.590387446602107957005,
+                0.594707107746216934174,
+                0.599008189645246602594,
+                0.603290851438941899687,
+                0.607555250224322662688,
+                0.611801541106615331955,
+                0.616029877215623855590,
+                0.620240409751204424537,
+                0.624433288012369303032,
+                0.628608659422752680256,
+                0.632766669570628437213,
+                0.636907462236194987781,
+                0.641031179420679109171,
+                0.645137961373620782978,
+                0.649227946625615004450,
+                0.653301272011958644725,
+                0.657358072709030238911,
+                0.661398482245203922502,
+                0.665422632544505177065,
+                0.669430653942981734871,
+                0.673422675212350441142,
+                0.677398823590920073911,
+                0.681359224807238206267,
+                0.685304003098281100392,
+                0.689233281238557538017,
+                0.693147180560117703862);
+
+        constant LOGF_TAIL: REAL_VECTOR(0 TO N) := (
+                0.0,
+                -0.00000000000000543229938420049,
+                0.00000000000000172745674997061,
+                -0.00000000000001323017818229233,
+                -0.00000000000001154527628289872,
+                -0.00000000000000466529469958300,
+                0.00000000000005148849572685810,
+                -0.00000000000002532168943117445,
+                -0.00000000000005213620639136504,
+                -0.00000000000001819506003016881,
+                0.00000000000006329065958724544,
+                0.00000000000008614512936087814,
+                -0.00000000000007355770219435028,
+                0.00000000000009638067658552277,
+                0.00000000000007598636597194141,
+                0.00000000000002579999128306990,
+                -0.00000000000004654729747598444,
+                -0.00000000000007556920687451336,
+                0.00000000000010195735223708472,
+                -0.00000000000017319034406422306,
+                -0.00000000000007718001336828098,
+                0.00000000000010980754099855238,
+                -0.00000000000002047235780046195,
+                -0.00000000000008372091099235912,
+                0.00000000000014088127937111135,
+                0.00000000000012869017157588257,
+                0.00000000000017788850778198106,
+                0.00000000000006440856150696891,
+                0.00000000000016132822667240822,
+                -0.00000000000007540916511956188,
+                -0.00000000000000036507188831790,
+                0.00000000000009120937249914984,
+                0.00000000000018567570959796010,
+                -0.00000000000003149265065191483,
+                -0.00000000000009309459495196889,
+                0.00000000000017914338601329117,
+                -0.00000000000001302979717330866,
+                0.00000000000023097385217586939,
+                0.00000000000023999540484211737,
+                0.00000000000015393776174455408,
+                -0.00000000000036870428315837678,
+                0.00000000000036920375082080089,
+                -0.00000000000009383417223663699,
+                0.00000000000009433398189512690,
+                0.00000000000041481318704258568,
+                -0.00000000000003792316480209314,
+                0.00000000000008403156304792424,
+                -0.00000000000034262934348285429,
+                0.00000000000043712191957429145,
+                -0.00000000000010475750058776541,
+                -0.00000000000011118671389559323,
+                0.00000000000037549577257259853,
+                0.00000000000013912841212197565,
+                0.00000000000010775743037572640,
+                0.00000000000029391859187648000,
+                -0.00000000000042790509060060774,
+                0.00000000000022774076114039555,
+                0.00000000000010849569622967912,
+                -0.00000000000023073801945705758,
+                0.00000000000015761203773969435,
+                0.00000000000003345710269544082,
+                -0.00000000000041525158063436123,
+                0.00000000000032655698896907146,
+                -0.00000000000044704265010452446,
+                0.00000000000034527647952039772,
+                -0.00000000000007048962392109746,
+                0.00000000000011776978751369214,
+                -0.00000000000010774341461609578,
+                0.00000000000021863343293215910,
+                0.00000000000024132639491333131,
+                0.00000000000039057462209830700,
+                -0.00000000000026570679203560751,
+                0.00000000000037135141919592021,
+                -0.00000000000017166921336082431,
+                -0.00000000000028658285157914353,
+                -0.00000000000023812542263446809,
+                0.00000000000006576659768580062,
+                -0.00000000000028210143846181267,
+                0.00000000000010701931762114254,
+                0.00000000000018119346366441110,
+                0.00000000000009840465278232627,
+                -0.00000000000033149150282752542,
+                -0.00000000000018302857356041668,
+                -0.00000000000016207400156744949,
+                0.00000000000048303314949553201,
+                -0.00000000000071560553172382115,
+                0.00000000000088821239518571855,
+                -0.00000000000030900580513238244,
+                -0.00000000000061076551972851496,
+                0.00000000000035659969663347830,
+                0.00000000000035782396591276383,
+                -0.00000000000046226087001544578,
+                0.00000000000062279762917225156,
+                0.00000000000072838947272065741,
+                0.00000000000026809646615211673,
+                -0.00000000000010960825046059278,
+                0.00000000000002311949383800537,
+                -0.00000000000058469058005299247,
+                -0.00000000000002103748251144494,
+                -0.00000000000023323182945587408,
+                -0.00000000000042333694288141916,
+                -0.00000000000043933937969737844,
+                0.00000000000041341647073835565,
+                0.00000000000006841763641591466,
+                0.00000000000047585534004430641,
+                0.00000000000083679678674757695,
+                -0.00000000000085763734646658640,
+                0.00000000000021913281229340092,
+                -0.00000000000062242842536431148,
+                -0.00000000000010983594325438430,
+                0.00000000000065310431377633651,
+                -0.00000000000047580199021710769,
+                -0.00000000000037854251265457040,
+                0.00000000000040939233218678664,
+                0.00000000000087424383914858291,
+                0.00000000000025218188456842882,
+                -0.00000000000003608131360422557,
+                -0.00000000000050518555924280902,
+                0.00000000000078699403323355317,
+                -0.00000000000067020876961949060,
+                0.00000000000016108575753932458,
+                0.00000000000058527188436251509,
+                -0.00000000000035246757297904791,
+                -0.00000000000018372084495629058,
+                0.00000000000088606689813494916,
+                0.00000000000066486268071468700,
+                0.00000000000063831615170646519,
+                0.00000000000025144230728376072,
+                -0.00000000000017239444525614834);
+
+        variable M, J:INTEGER;
+        variable F1, F2, G, Q, U, U2, V: REAL;
+        variable ZERO: REAL := 0.0;--Made variable so no constant folding occurs
+        variable ONE: REAL := 1.0; --Made variable so no constant folding occurs
+
+        -- double logb(), ldexp();
+
+        variable U1:REAL;
+
+     begin
+
+        -- Check validity of argument
+        if ( X <= 0.0 ) then
+                assert FALSE
+                        report "X <= 0.0 in LOG(X)"
+                        severity ERROR;
+                return(REAL'LOW);
+        end if;
+
+        -- Compute value for special cases
+        if ( X = 1.0 ) then
+                return 0.0;
+        end if;
+
+        if ( X = MATH_E ) then
+                return 1.0;
+        end if;
+
+        -- Argument reduction: 1 <= g < 2; x/2^m = g;
+        -- y = F*(1 + f/F) for |f| <= 2^-8
+
+        M := ILOGB(X);
+        G := LDEXP(X, -M);
+        J := INTEGER(REAL(N)*(G-1.0)); -- C code adds 0.5 for rounding
+        F1 := (1.0/REAL(N)) * REAL(J) + 1.0; --F1*128 is an INTEGER in [128,512]
+        F2 := G - F1;
+
+        -- Approximate expansion for log(1+f2/F1) ~= u + q
+        G := 1.0/(2.0*F1+F2);
+        U := 2.0*F2*G;
+        V := U*U;
+        Q := U*V*(A1 + V*(A2 + V*(A3 + V*A4)));
+
+        -- Case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8,
+        --       u1 has at most 35 bits, and F1*u1 is exact, as F1 has < 8 bits.
+        --       It also adds exactly to |m*log2_hi + log_F_head[j] | < 750.
+        --
+        if ( J /= 0 or M /= 0) then
+                U1 := U + 513.0;
+                U1 := U1 - 513.0;
+
+                -- Case 2: |1-x| < 1/256. The m- and j- dependent terms are zero
+                --        u1 = u to 24 bits.
+                --
+        else
+                U1 := U;
+                --TRUNC(U1); --In c this is u1 = (double) (float) (u1)
+        end if;
+
+        U2 := (2.0*(F2 - F1*U1) - U1*F2) * G;
+        -- u1 + u2 = 2f/(2F+f) to extra precision.
+
+        -- log(x) = log(2^m*F1*(1+f2/F1)) =
+        -- (m*log2_hi+LOGF_HEAD(j)+u1) + (m*log2_lo+LOGF_TAIL(j)+q);
+        -- (exact) + (tiny)
+
+        U1 := U1 + REAL(M)*LOGF_HEAD(N) + LOGF_HEAD(J);        -- Exact
+        U2 := (U2 + LOGF_TAIL(J)) + Q;        -- Tiny
+        U2 := U2 + LOGF_TAIL(N)*REAL(M);
+        return (U1 + U2);
+    end LOG;
+
+
+    function LOG2 (X: in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns REAL'LOW on error
+    begin
+        -- Check validity of arguments
+        if ( X <= 0.0 )  then
+                assert FALSE
+                        report "X <= 0.0 in LOG2(X)"
+                        severity ERROR;
+                return(REAL'LOW);
+        end if;
+
+        -- Compute value for special cases
+        if ( X = 1.0 ) then
+                return 0.0;
+        end if;
+
+        if ( X = 2.0 ) then
+                return 1.0;
+        end if;
+
+        -- Compute value for general case
+        return ( MATH_LOG2_OF_E*LOG(X) );
+    end LOG2;
+
+
+    function LOG10 (X: in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns REAL'LOW on error
+    begin
+        -- Check validity of arguments
+        if ( X <= 0.0 )  then
+                   assert FALSE
+                        report "X <= 0.0 in LOG10(X)"
+                        severity ERROR;
+                   return(REAL'LOW);
+        end if;
+
+        -- Compute value for special cases
+        if ( X = 1.0 ) then
+                return 0.0;
+        end if;
+
+        if ( X = 10.0 ) then
+                return 1.0;
+        end if;
+
+        -- Compute value for general case
+        return ( MATH_LOG10_OF_E*LOG(X) );
+    end LOG10;
+
+
+    function LOG (X: in REAL; BASE: in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns REAL'LOW on error
+    begin
+        -- Check validity of arguments
+        if ( X <= 0.0 )  then
+                 assert FALSE
+                        report "X <= 0.0 in LOG(X, BASE)"
+                        severity ERROR;
+                 return(REAL'LOW);
+        end if;
+
+        if ( BASE <= 0.0 or BASE = 1.0 )  then
+                 assert FALSE
+                        report "BASE <= 0.0 or BASE = 1.0 in LOG(X, BASE)"
+                        severity ERROR;
+                 return(REAL'LOW);
+        end if;
+
+        -- Compute value for special cases
+        if ( X = 1.0 ) then
+                return 0.0;
+        end if;
+
+        if ( X = BASE ) then
+                return 1.0;
+        end if;
+
+        -- Compute value for general case
+        return ( LOG(X)/LOG(BASE));
+    end LOG;
+
+
+    function  SIN (X : in REAL ) return REAL is
+        -- Description:
+        --         See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --         a) SIN(-X) = -SIN(X)
+        --         b) SIN(X) = X if ABS(X) < EPS
+        --         c) SIN(X) = X - X**3/3! if EPS < ABS(X) < BASE_EPS
+        --         d) SIN(MATH_PI_OVER_2 - X) = COS(X)
+        --         e) COS(X) = 1.0 - 0.5*X**2 if ABS(X) < EPS
+        --         f) COS(X) = 1.0 - 0.5*X**2 + (X**4)/4! if
+        --                                         EPS< ABS(X) <BASE_EPS
+
+        constant EPS : REAL := BASE_EPS*BASE_EPS; -- Convergence criteria
+
+        variable N : INTEGER;
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable XLOCAL : REAL := ABS(X) ;
+        variable VALUE: REAL;
+        variable TEMP : REAL;
+
+    begin
+        -- Make XLOCAL < MATH_2_PI
+        if XLOCAL > MATH_2_PI then
+                TEMP := FLOOR(XLOCAL/MATH_2_PI);
+                XLOCAL := XLOCAL - TEMP*MATH_2_PI;
+        end if;
+
+        if XLOCAL < 0.0 then
+                assert FALSE
+                        report "XLOCAL <= 0.0 after reduction in SIN(X)"
+                        severity ERROR;
+                XLOCAL := -XLOCAL;
+        end if;
+
+        -- Compute value for special cases
+        if XLOCAL = 0.0  or XLOCAL = MATH_2_PI or XLOCAL = MATH_PI  then
+                return 0.0;
+        end if;
+
+        if  XLOCAL = MATH_PI_OVER_2 then
+                if NEGATIVE then
+                        return -1.0;
+                else
+                        return 1.0;
+                end if;
+        end if;
+
+        if  XLOCAL = MATH_3_PI_OVER_2 then
+                if NEGATIVE then
+                        return 1.0;
+                else
+                        return -1.0;
+                end if;
+        end if;
+
+        if XLOCAL < EPS then
+                if NEGATIVE then
+                        return -XLOCAL;
+                else
+                        return XLOCAL;
+                end if;
+        else
+                if XLOCAL < BASE_EPS then
+                        TEMP := XLOCAL - (XLOCAL*XLOCAL*XLOCAL)/6.0;
+                        if NEGATIVE then
+                                return -TEMP;
+                        else
+                                return TEMP;
+                        end if;
+                end if;
+        end if;
+
+        TEMP := MATH_PI - XLOCAL;
+        if ABS(TEMP) < EPS then
+                if NEGATIVE then
+                        return -TEMP;
+                else
+                        return TEMP;
+                end if;
+        else
+                if ABS(TEMP) < BASE_EPS then
+                        TEMP := TEMP - (TEMP*TEMP*TEMP)/6.0;
+                        if NEGATIVE then
+                                return -TEMP;
+                        else
+                                return TEMP;
+                        end if;
+                end if;
+        end if;
+
+        TEMP := MATH_2_PI - XLOCAL;
+        if ABS(TEMP) < EPS then
+                if NEGATIVE then
+                        return TEMP;
+                else
+                        return -TEMP;
+                end if;
+        else
+                if ABS(TEMP) < BASE_EPS then
+                        TEMP := TEMP - (TEMP*TEMP*TEMP)/6.0;
+                        if NEGATIVE then
+                                return TEMP;
+                        else
+                                return -TEMP;
+                        end if;
+                end if;
+        end if;
+
+        TEMP := ABS(MATH_PI_OVER_2 - XLOCAL);
+        if TEMP < EPS then
+                TEMP := 1.0 - TEMP*TEMP*0.5;
+                if NEGATIVE then
+                        return -TEMP;
+                else
+                        return TEMP;
+                end if;
+        else
+                if TEMP < BASE_EPS then
+                        TEMP := 1.0 -TEMP*TEMP*0.5 + TEMP*TEMP*TEMP*TEMP/24.0;
+                        if NEGATIVE then
+                                return -TEMP;
+                        else
+                                return TEMP;
+                        end if;
+                end if;
+        end if;
+
+        TEMP := ABS(MATH_3_PI_OVER_2 - XLOCAL);
+        if TEMP < EPS then
+                TEMP := 1.0 - TEMP*TEMP*0.5;
+                if NEGATIVE then
+                        return TEMP;
+                else
+                        return -TEMP;
+                end if;
+        else
+                if TEMP < BASE_EPS then
+                        TEMP := 1.0 -TEMP*TEMP*0.5 + TEMP*TEMP*TEMP*TEMP/24.0;
+                        if NEGATIVE then
+                                return TEMP;
+                        else
+                                return -TEMP;
+                        end if;
+                end if;
+        end if;
+
+        -- Compute value for general cases
+        if ((XLOCAL < MATH_PI_OVER_2 ) and (XLOCAL > 0.0)) then
+                 VALUE:=  CORDIC( KC, 0.0, x, 27, ROTATION)(1);
+        end if;
+
+        N := INTEGER ( FLOOR(XLOCAL/MATH_PI_OVER_2));
+        case QUADRANT( N mod 4) is
+           when 0 =>
+                VALUE := CORDIC( KC, 0.0, XLOCAL, 27, ROTATION)(1);
+           when 1 =>
+                VALUE := CORDIC( KC, 0.0, XLOCAL - MATH_PI_OVER_2, 27,
+                                                                ROTATION)(0);
+           when 2 =>
+                VALUE := -CORDIC( KC, 0.0, XLOCAL - MATH_PI, 27, ROTATION)(1);
+           when 3 =>
+                VALUE := -CORDIC( KC, 0.0, XLOCAL - MATH_3_PI_OVER_2, 27,
+                                                                ROTATION)(0);
+        end case;
+
+        if NEGATIVE then
+                return -VALUE;
+        else
+                return VALUE;
+        end if;
+    end SIN;
+
+
+   function COS (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) COS(-X) = COS(X)
+        --        b) COS(X) = SIN(MATH_PI_OVER_2 - X)
+        --        c) COS(MATH_PI + X)  = -COS(X)
+        --        d) COS(X) = 1.0 - X*X/2.0 if ABS(X) < EPS
+        --        e) COS(X) = 1.0 - 0.5*X**2 + (X**4)/4! if
+        --                                           EPS< ABS(X) <BASE_EPS
+        --
+        constant EPS : REAL := BASE_EPS*BASE_EPS;
+
+        variable XLOCAL : REAL := ABS(X);
+        variable VALUE: REAL;
+        variable TEMP : REAL;
+
+    begin
+        -- Make XLOCAL < MATH_2_PI
+        if XLOCAL > MATH_2_PI then
+                TEMP := FLOOR(XLOCAL/MATH_2_PI);
+                XLOCAL := XLOCAL - TEMP*MATH_2_PI;
+        end if;
+
+        if XLOCAL < 0.0 then
+                assert FALSE
+                        report "XLOCAL <= 0.0 after reduction in COS(X)"
+                        severity ERROR;
+                XLOCAL := -XLOCAL;
+        end if;
+
+        -- Compute value for special cases
+        if XLOCAL = 0.0  or XLOCAL = MATH_2_PI then
+                return 1.0;
+        end if;
+
+        if  XLOCAL = MATH_PI then
+                return -1.0;
+        end if;
+
+        if XLOCAL = MATH_PI_OVER_2 or XLOCAL = MATH_3_PI_OVER_2 then
+                return 0.0;
+        end if;
+
+        TEMP := ABS(XLOCAL);
+        if ( TEMP < EPS) then
+                return (1.0 - 0.5*TEMP*TEMP);
+        else
+                if (TEMP < BASE_EPS) then
+                        return (1.0 -0.5*TEMP*TEMP + TEMP*TEMP*TEMP*TEMP/24.0);
+                end if;
+        end if;
+
+        TEMP := ABS(XLOCAL -MATH_2_PI);
+        if ( TEMP < EPS) then
+                return (1.0 - 0.5*TEMP*TEMP);
+        else
+                if (TEMP < BASE_EPS) then
+                        return (1.0 -0.5*TEMP*TEMP + TEMP*TEMP*TEMP*TEMP/24.0);
+                end if;
+        end if;
+
+        TEMP := ABS (XLOCAL - MATH_PI);
+        if TEMP < EPS then
+                return (-1.0 + 0.5*TEMP*TEMP);
+        else
+                if (TEMP < BASE_EPS) then
+                        return (-1.0 +0.5*TEMP*TEMP - TEMP*TEMP*TEMP*TEMP/24.0);
+                end if;
+        end if;
+
+        -- Compute value for general cases
+        return SIN(MATH_PI_OVER_2 - XLOCAL);
+   end COS;
+
+   function TAN (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) TAN(0.0) = 0.0
+        --        b) TAN(-X) = -TAN(X)
+        --        c) Returns REAL'LOW on error if X < 0.0
+        --        d) Returns REAL'HIGH on error if X > 0.0
+
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable XLOCAL : REAL := ABS(X) ;
+        variable VALUE: REAL;
+        variable TEMP : REAL;
+
+    begin
+        -- Make 0.0 <= XLOCAL <= MATH_2_PI
+        if XLOCAL > MATH_2_PI then
+                TEMP := FLOOR(XLOCAL/MATH_2_PI);
+                XLOCAL := XLOCAL - TEMP*MATH_2_PI;
+        end if;
+
+        if XLOCAL < 0.0 then
+                assert FALSE
+                        report "XLOCAL <= 0.0 after reduction in TAN(X)"
+                        severity ERROR;
+                XLOCAL := -XLOCAL;
+        end if;
+
+        -- Check validity of argument
+        if XLOCAL = MATH_PI_OVER_2 then
+                assert FALSE
+                        report "X is a multiple of MATH_PI_OVER_2 in TAN(X)"
+                        severity ERROR;
+                if NEGATIVE then
+                        return(REAL'LOW);
+                else
+                        return(REAL'HIGH);
+                end if;
+        end if;
+
+        if XLOCAL = MATH_3_PI_OVER_2 then
+                assert FALSE
+                        report "X is a multiple of MATH_3_PI_OVER_2 in TAN(X)"
+                        severity ERROR;
+                if NEGATIVE then
+                        return(REAL'HIGH);
+                else
+                        return(REAL'LOW);
+                end if;
+        end if;
+
+        -- Compute value for special cases
+        if XLOCAL = 0.0 or XLOCAL = MATH_PI then
+                return 0.0;
+        end if;
+
+        -- Compute value for general cases
+        VALUE := SIN(XLOCAL)/COS(XLOCAL);
+        if NEGATIVE then
+                return -VALUE;
+        else
+                return VALUE;
+        end if;
+   end TAN;
+
+   function ARCSIN (X : in REAL ) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) ARCSIN(-X) = -ARCSIN(X)
+        --        b) Returns X on error
+
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable XLOCAL : REAL := ABS(X);
+        variable VALUE : REAL;
+
+   begin
+      -- Check validity of arguments
+      if XLOCAL > 1.0 then
+         assert FALSE
+                report "ABS(X) > 1.0 in ARCSIN(X)"
+                severity ERROR;
+         return X;
+      end if;
+
+      -- Compute value for special cases
+      if XLOCAL = 0.0 then
+         return 0.0;
+      elsif XLOCAL = 1.0 then
+         if NEGATIVE then
+                return -MATH_PI_OVER_2;
+         else
+                return MATH_PI_OVER_2;
+         end if;
+      end if;
+
+      -- Compute value for general cases
+      if XLOCAL < 0.9 then
+         VALUE := ARCTAN(XLOCAL/(SQRT(1.0 - XLOCAL*XLOCAL)));
+      else
+         VALUE := MATH_PI_OVER_2 - ARCTAN(SQRT(1.0 - XLOCAL*XLOCAL)/XLOCAL);
+      end if;
+
+      if NEGATIVE then
+         VALUE := -VALUE;
+      end if;
+
+      return VALUE;
+   end ARCSIN;
+
+   function ARCCOS (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) ARCCOS(-X) = MATH_PI - ARCCOS(X)
+        --        b) Returns X on error
+
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable XLOCAL : REAL := ABS(X);
+        variable VALUE : REAL;
+
+   begin
+      -- Check validity of argument
+      if XLOCAL > 1.0 then
+         assert FALSE
+                report "ABS(X) > 1.0 in ARCCOS(X)"
+                severity ERROR;
+         return X;
+      end if;
+
+      -- Compute value for special cases
+      if X = 1.0 then
+         return 0.0;
+      elsif X = 0.0 then
+         return MATH_PI_OVER_2;
+      elsif X = -1.0 then
+         return MATH_PI;
+      end if;
+
+      -- Compute value for general cases
+      if XLOCAL > 0.9 then
+         VALUE := ARCTAN(SQRT(1.0 - XLOCAL*XLOCAL)/XLOCAL);
+      else
+         VALUE := MATH_PI_OVER_2 - ARCTAN(XLOCAL/SQRT(1.0 - XLOCAL*XLOCAL));
+      end if;
+
+
+      if NEGATIVE then
+         VALUE := MATH_PI - VALUE;
+      end if;
+
+      return VALUE;
+   end ARCCOS;
+
+
+   function ARCTAN (Y : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) ARCTAN(-Y) = -ARCTAN(Y)
+        --        b) ARCTAN(Y) = -ARCTAN(1.0/Y) + MATH_PI_OVER_2 for |Y| > 1.0
+        --        c) ARCTAN(Y) = Y for |Y| < EPS
+
+        constant EPS : REAL := BASE_EPS*BASE_EPS*BASE_EPS;
+
+        variable NEGATIVE : BOOLEAN := Y < 0.0;
+        variable RECIPROCAL : BOOLEAN;
+        variable YLOCAL : REAL := ABS(Y);
+        variable VALUE : REAL;
+
+   begin
+      -- Make argument |Y| <=1.0
+      if YLOCAL > 1.0 then
+                YLOCAL := 1.0/YLOCAL;
+                RECIPROCAL := TRUE;
+      else
+                RECIPROCAL := FALSE;
+      end if;
+
+      -- Compute value for special cases
+      if YLOCAL = 0.0 then
+         if RECIPROCAL then
+                if NEGATIVE then
+                        return (-MATH_PI_OVER_2);
+                else
+                        return (MATH_PI_OVER_2);
+                end if;
+         else
+                return 0.0;
+         end if;
+      end if;
+
+      if YLOCAL < EPS then
+         if NEGATIVE then
+                if RECIPROCAL then
+                        return (-MATH_PI_OVER_2 + YLOCAL);
+                else
+                        return -YLOCAL;
+                end if;
+         else
+                if RECIPROCAL then
+                        return (MATH_PI_OVER_2 - YLOCAL);
+                else
+                        return YLOCAL;
+                end if;
+         end if;
+      end if;
+
+      -- Compute value for general cases
+      VALUE :=  CORDIC( 1.0, YLOCAL, 0.0, 27, VECTORING )(2);
+
+      if RECIPROCAL then
+         VALUE := MATH_PI_OVER_2 - VALUE;
+      end if;
+
+      if NEGATIVE then
+        VALUE := -VALUE;
+      end if;
+
+      return VALUE;
+   end ARCTAN;
+
+
+   function ARCTAN (Y : in REAL; X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --         a) Returns 0.0 on error
+
+        variable YLOCAL : REAL;
+        variable VALUE : REAL;
+   begin
+
+     -- Check validity of arguments
+     if (Y = 0.0 and X = 0.0 ) then
+           assert FALSE report
+                "ARCTAN(0.0, 0.0) is undetermined"
+                severity ERROR;
+           return 0.0;
+     end if;
+
+     -- Compute value for special cases
+     if Y = 0.0 then
+        if X > 0.0 then
+           return 0.0;
+        else
+           return MATH_PI;
+        end if;
+     end if;
+
+     if X = 0.0 then
+        if Y > 0.0 then
+           return MATH_PI_OVER_2;
+        else
+           return -MATH_PI_OVER_2;
+        end if;
+     end if;
+
+
+     -- Compute value for general cases
+     YLOCAL := ABS(Y/X);
+
+     VALUE := ARCTAN(YLOCAL);
+
+     if X < 0.0 then
+         VALUE := MATH_PI - VALUE;
+     end if;
+
+     if Y < 0.0 then
+         VALUE := -VALUE;
+     end if;
+
+     return VALUE;
+   end ARCTAN;
+
+
+    function SINH (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns (EXP(X) - EXP(-X))/2.0
+        --        b) SINH(-X) = SINH(X)
+
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable XLOCAL : REAL := ABS(X);
+        variable TEMP : REAL;
+        variable VALUE : REAL;
+
+    begin
+        -- Compute value for special cases
+        if XLOCAL = 0.0 then
+                return 0.0;
+        end if;
+
+        -- Compute value for general cases
+        TEMP := EXP(XLOCAL);
+        VALUE := (TEMP - 1.0/TEMP)*0.5;
+
+         if NEGATIVE then
+                VALUE := -VALUE;
+        end if;
+
+        return VALUE;
+    end SINH;
+
+    function  COSH (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns (EXP(X) + EXP(-X))/2.0
+        --        b) COSH(-X) = COSH(X)
+
+        variable XLOCAL : REAL := ABS(X);
+        variable TEMP : REAL;
+        variable VALUE : REAL;
+    begin
+        -- Compute value for special cases
+        if XLOCAL = 0.0 then
+                return 1.0;
+        end if;
+
+
+        -- Compute value for general cases
+        TEMP := EXP(XLOCAL);
+        VALUE := (TEMP + 1.0/TEMP)*0.5;
+
+        return VALUE;
+    end COSH;
+
+    function  TANH (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns (EXP(X) - EXP(-X))/(EXP(X) + EXP(-X))
+        --        b) TANH(-X) = -TANH(X)
+
+        variable NEGATIVE : BOOLEAN := X < 0.0;
+        variable XLOCAL : REAL := ABS(X);
+        variable TEMP : REAL;
+        variable VALUE : REAL;
+
+    begin
+        -- Compute value for special cases
+        if XLOCAL = 0.0 then
+                return 0.0;
+        end if;
+
+        -- Compute value for general cases
+        TEMP := EXP(XLOCAL);
+        VALUE := (TEMP - 1.0/TEMP)/(TEMP + 1.0/TEMP);
+
+        if NEGATIVE then
+            return -VALUE;
+        else
+            return VALUE;
+        end if;
+    end TANH;
+
+    function ARCSINH (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns LOG( X + SQRT( X*X + 1.0))
+
+    begin
+        -- Compute value for special cases
+        if X = 0.0 then
+                return 0.0;
+        end if;
+
+        -- Compute value for general cases
+        return ( LOG( X + SQRT( X*X + 1.0)) );
+    end ARCSINH;
+
+
+
+   function ARCCOSH (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns LOG( X + SQRT( X*X - 1.0));   X >= 1.0
+        --        b) Returns X on error
+
+    begin
+        -- Check validity of arguments
+        if X < 1.0 then
+                 assert FALSE
+                        report "X < 1.0 in ARCCOSH(X)"
+                        severity ERROR;
+                 return X;
+        end if;
+
+        -- Compute value for special cases
+        if X = 1.0 then
+                return 0.0;
+        end if;
+
+        -- Compute value for general cases
+        return ( LOG( X + SQRT( X*X - 1.0)));
+    end ARCCOSH;
+
+    function ARCTANH (X : in REAL) return REAL is
+        -- Description:
+        --        See function declaration in IEEE Std 1076.2-1996
+        -- Notes:
+        --        a) Returns (LOG( (1.0 + X)/(1.0 - X)))/2.0 ; | X | < 1.0
+        --        b) Returns X on error
+    begin
+        -- Check validity of arguments
+        if ABS(X) >= 1.0 then
+                assert FALSE
+                        report "ABS(X) >= 1.0 in ARCTANH(X)"
+                        severity ERROR;
+                return X;
+        end if;
+
+        -- Compute value for special cases
+        if X = 0.0 then
+                return 0.0;
+        end if;
+
+        -- Compute value for general cases
+        return( 0.5*LOG( (1.0+X)/(1.0-X) ) );
+    end ARCTANH;
+
+end  MATH_REAL;
diff --git a/cores/generate_core.tcl b/cores/generate_core.tcl
new file mode 100644 (file)
index 0000000..1905d5d
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/local/bin/wish
+
+proc GetPlatform {} {
+       global tcl_platform
+
+       set cpu  $tcl_platform(machine)
+
+       switch $cpu {
+               intel -
+               i*86* {
+                       set cpu ix86
+               }
+               x86_64 {
+                       if {$tcl_platform(wordSize) == 4} {
+                               set cpu ix86
+                       }
+               }
+       }
+
+       switch $tcl_platform(platform) {
+               windows {
+                       if {$cpu == "amd64"} {
+                               # Do not check wordSize, win32-x64 is an IL32P64 platform.
+                               set cpu x86_64
+                       }
+                       if {$cpu == "x86_64"} {
+                               return "nt64"
+                       } else {
+                               return "nt"
+                       }
+               }
+               unix {
+                       if {$tcl_platform(os) == "Linux"}  {
+                               if {$cpu == "x86_64"} {
+                                       return "lin64"
+                               } else {
+                                       return "lin"
+                               }
+                       } else  {
+                               return "sol"
+                       }
+               }
+       }
+       return "nt"
+}
+
+proc GetCmdLine {lpcfile} {
+       global Para
+
+       if [catch {open $lpcfile r} fileid] {
+               puts "Cannot open $para_file file!"
+               exit -1
+       }
+
+       seek $fileid 0 start
+       set default_match 0
+       while {[gets $fileid line] >= 0} {
+               if {[string first "\[Command\]" $line] == 0} {
+                       set default_match 1
+                       continue
+               }
+               if {[string first "\[" $line] == 0} {
+                       set default_match 0
+               }
+               if {$default_match == 1} {
+                       if [regexp {([^=]*)=(.*)} $line match parameter value] {
+                               if [regexp {([ |\t]*;)} $parameter match] {continue}
+                               if [regexp {(.*)[ |\t]*;} $value match temp] {
+                                       set Para($parameter) $temp
+                               } else {
+                                       set Para($parameter) $value
+                               }
+                       }
+               }
+       }
+       set default_match 0
+       close $fileid
+
+       return $Para(cmd_line)
+}
+
+set platformpath [GetPlatform]
+set Para(sbp_path) [file dirname [info script]]
+set Para(install_dir) $env(TOOLRTF)
+set Para(FPGAPath) "[file join $Para(install_dir) ispfpga bin $platformpath]"
+
+set scuba "$Para(FPGAPath)/scuba"
+set modulename "pll_4x266"
+set lang "vhdl"
+set lpcfile "$Para(sbp_path)/$modulename.lpc"
+set arch "xo3c00f"
+set cmd_line [GetCmdLine $lpcfile]
+set fdcfile "$Para(sbp_path)/$modulename.fdc"
+if {[file exists $fdcfile] == 0} {
+       append scuba " " $cmd_line
+} else {
+       append scuba " " $cmd_line " " -fdc " " \"$fdcfile\"
+}
+set Para(result) [catch {eval exec "$scuba"} msg]
+#puts $msg
diff --git a/cores/generate_ngd.tcl b/cores/generate_ngd.tcl
new file mode 100644 (file)
index 0000000..6232bea
--- /dev/null
@@ -0,0 +1,115 @@
+#!/usr/local/bin/wish
+
+proc GetPlatform {} {
+       global tcl_platform
+
+       set cpu  $tcl_platform(machine)
+
+       switch $cpu {
+               intel -
+               i*86* {
+                       set cpu ix86
+               }
+               x86_64 {
+                       if {$tcl_platform(wordSize) == 4} {
+                               set cpu ix86
+                       }
+               }
+       }
+
+       switch $tcl_platform(platform) {
+               windows {
+                       if {$cpu == "amd64"} {
+                               # Do not check wordSize, win32-x64 is an IL32P64 platform.
+                               set cpu x86_64
+                       }
+                       if {$cpu == "x86_64"} {
+                               return "nt64"
+                       } else {
+                               return "nt"
+                       }
+               }
+               unix {
+                       if {$tcl_platform(os) == "Linux"}  {
+                               if {$cpu == "x86_64"} {
+                                       return "lin64"
+                               } else {
+                                       return "lin"
+                               }
+                       } else  {
+                               return "sol"
+                       }
+               }
+       }
+       return "nt"
+}
+
+set platformpath [GetPlatform]
+set Para(sbp_path) [file dirname [info script]]
+set Para(install_dir) $env(TOOLRTF)
+set Para(FPGAPath) "[file join $Para(install_dir) ispfpga bin $platformpath]"
+set Para(bin_dir) "[file join $Para(install_dir) bin $platformpath]"
+
+set Para(ModuleName) "pll_4x266"
+set Para(Module) "PLL"
+set Para(libname) machxo3lf
+set Para(arch_name) xo3c00f
+set Para(PartType) "LCMXO3LF-2100E"
+
+set Para(tech_syn) machxo3lf
+set Para(tech_cae) machxo3lf
+set Para(Package) "WLCSP49"
+set Para(SpeedGrade) "5"
+set Para(FMax) "100"
+set fdcfile "$Para(sbp_path)/$Para(ModuleName).fdc"
+
+#create response file(*.cmd) for Synpwrap
+proc CreateCmdFile {} {
+       global Para
+
+       file mkdir "$Para(sbp_path)/syn_results"
+       if [catch {open $Para(ModuleName).cmd w} rspFile] {
+               puts "Cannot create response file $Para(ModuleName).cmd."
+               exit -1
+       } else {
+               puts $rspFile "PROJECT: $Para(ModuleName)
+               working_path: \"$Para(sbp_path)/syn_results\"
+               module: $Para(ModuleName)
+               verilog_file_list: \"$Para(sbp_path)/$Para(ModuleName).vhd\"
+               vlog_std_v2001: true
+               constraint_file_name: \"$Para(sbp_path)/$Para(ModuleName).fdc\"
+               suffix_name: edn
+               output_file_name: $Para(ModuleName)
+               write_prf: true
+               disable_io_insertion: true
+               force_gsr: false
+               frequency: $Para(FMax)
+               fanout_limit: 50
+               retiming: false
+               pipe: false
+               part: $Para(PartType)
+               speed_grade: $Para(SpeedGrade)
+               "
+               close $rspFile
+       }
+}
+
+#synpwrap
+CreateCmdFile
+set synpwrap "$Para(bin_dir)/synpwrap"
+if {[file exists $fdcfile] == 0} {
+       set Para(result) [catch {eval exec $synpwrap -rem -e $Para(ModuleName) -target $Para(tech_syn)} msg]
+} else {
+       set Para(result) [catch {eval exec $synpwrap -rem -e $Para(ModuleName) -target $Para(tech_syn) -fdc $fdcfile} msg]
+}
+#puts $msg
+
+#edif2ngd
+set edif2ngd "$Para(FPGAPath)/edif2ngd"
+set Para(result) [catch {eval exec $edif2ngd -l $Para(libname) -d $Para(PartType) -nopropwarn \"syn_results/$Para(ModuleName).edn\" $Para(ModuleName).ngo} msg]
+#puts $msg
+
+#ngdbuild
+set ngdbuild "$Para(FPGAPath)/ngdbuild"
+set Para(result) [catch {eval exec $ngdbuild -addiobuf -dt -a $Para(arch_name) $Para(ModuleName).ngo $Para(ModuleName).ngd} msg]
+#puts $msg
diff --git a/cores/msg_file.log b/cores/msg_file.log
new file mode 100644 (file)
index 0000000..56ba57d
--- /dev/null
@@ -0,0 +1,29 @@
+SCUBA, Version Diamond (64-bit) 3.7.0.96.1
+Tue Apr  5 17:14:32 2016
+  
+Copyright (c) 1991-1994 by NeoCAD Inc. All rights reserved.
+Copyright (c) 1995 AT&T Corp.   All rights reserved.
+Copyright (c) 1995-2001 Lucent Technologies Inc.  All rights reserved.
+Copyright (c) 2001 Agere Systems   All rights reserved.
+Copyright (c) 2002-2016 Lattice Semiconductor Corporation,  All rights reserved.
+  
+BEGIN SCUBA Module Synthesis
+  
+    Issued command   : /d/jspc29/lattice/diamond/3.7_x64/ispfpga/bin/lin64/scuba -w -n pll_4x266 -lang vhdl -synth synplify -arch xo3c00f -type pll -fin 125 -fclkop 250 -fclkop_tol 1.0 -fclkos 250 -fclkos_tol 0.0 -fclkos2 250 -fclkos2_tol 0.0 -fclkos3 250 -fclkos3_tol 0.0 -trimp 0 -phasep 0 -trimp_r -trims 0 -phases 45 -trims_r -phases2 90 -phases3 135 -phase_cntl STATIC -fb_mode 5 
+    Circuit name     : pll_4x266
+    Module type      : pll
+    Module Version   : 5.7
+    Ports            : 
+    Inputs       : CLKI
+    Outputs      : CLKOP, CLKOS, CLKOS2, CLKOS3
+    I/O buffer       : not inserted
+    EDIF output      : pll_4x266.edn
+    VHDL output      : pll_4x266.vhd
+    VHDL template    : pll_4x266_tmpl.vhd
+    VHDL purpose     : for synthesis and simulation
+    Bus notation     : big endian
+    Report output    : pll_4x266.srp
+    Estimated Resource Usage:
+  
+END   SCUBA Module Synthesis
+
diff --git a/cores/pll_4x266.edn b/cores/pll_4x266.edn
new file mode 100644 (file)
index 0000000..f9864e6
--- /dev/null
@@ -0,0 +1,324 @@
+(edif pll_4x266
+  (edifVersion 2 0 0)
+  (edifLevel 0)
+  (keywordMap (keywordLevel 0))
+  (status
+    (written
+      (timestamp 2016 4 5 17 14 32)
+      (program "SCUBA" (version "Diamond (64-bit) 3.7.0.96.1"))))
+      (comment "/d/jspc29/lattice/diamond/3.7_x64/ispfpga/bin/lin64/scuba -w -n pll_4x266 -lang vhdl -synth synplify -arch xo3c00f -type pll -fin 125 -fclkop 250 -fclkop_tol 1.0 -fclkos 250 -fclkos_tol 0.0 -fclkos2 250 -fclkos2_tol 0.0 -fclkos3 250 -fclkos3_tol 0.0 -trimp 0 -phasep 0 -trimp_r -trims 0 -phases 45 -trims_r -phases2 90 -phases3 135 -phase_cntl STATIC -fb_mode 5 ")
+  (library ORCLIB
+    (edifLevel 0)
+    (technology
+      (numberDefinition))
+    (cell VLO
+      (cellType GENERIC)
+      (view view1
+        (viewType NETLIST)
+        (interface
+          (port Z
+            (direction OUTPUT)))))
+    (cell EHXPLLJ
+      (cellType GENERIC)
+      (view view1
+        (viewType NETLIST)
+        (interface
+          (port CLKI
+            (direction INPUT))
+          (port CLKFB
+            (direction INPUT))
+          (port PHASESEL1
+            (direction INPUT))
+          (port PHASESEL0
+            (direction INPUT))
+          (port PHASEDIR
+            (direction INPUT))
+          (port PHASESTEP
+            (direction INPUT))
+          (port LOADREG
+            (direction INPUT))
+          (port STDBY
+            (direction INPUT))
+          (port PLLWAKESYNC
+            (direction INPUT))
+          (port RST
+            (direction INPUT))
+          (port RESETM
+            (direction INPUT))
+          (port RESETC
+            (direction INPUT))
+          (port RESETD
+            (direction INPUT))
+          (port ENCLKOP
+            (direction INPUT))
+          (port ENCLKOS
+            (direction INPUT))
+          (port ENCLKOS2
+            (direction INPUT))
+          (port ENCLKOS3
+            (direction INPUT))
+          (port PLLCLK
+            (direction INPUT))
+          (port PLLRST
+            (direction INPUT))
+          (port PLLSTB
+            (direction INPUT))
+          (port PLLWE
+            (direction INPUT))
+          (port PLLADDR4
+            (direction INPUT))
+          (port PLLADDR3
+            (direction INPUT))
+          (port PLLADDR2
+            (direction INPUT))
+          (port PLLADDR1
+            (direction INPUT))
+          (port PLLADDR0
+            (direction INPUT))
+          (port PLLDATI7
+            (direction INPUT))
+          (port PLLDATI6
+            (direction INPUT))
+          (port PLLDATI5
+            (direction INPUT))
+          (port PLLDATI4
+            (direction INPUT))
+          (port PLLDATI3
+            (direction INPUT))
+          (port PLLDATI2
+            (direction INPUT))
+          (port PLLDATI1
+            (direction INPUT))
+          (port PLLDATI0
+            (direction INPUT))
+          (port CLKOP
+            (direction OUTPUT))
+          (port CLKOS
+            (direction OUTPUT))
+          (port CLKOS2
+            (direction OUTPUT))
+          (port CLKOS3
+            (direction OUTPUT))
+          (port LOCK
+            (direction OUTPUT))
+          (port INTLOCK
+            (direction OUTPUT))
+          (port REFCLK
+            (direction OUTPUT))
+          (port CLKINTFB
+            (direction OUTPUT))
+          (port DPHSRC
+            (direction OUTPUT))
+          (port PLLACK
+            (direction OUTPUT))
+          (port PLLDATO7
+            (direction OUTPUT))
+          (port PLLDATO6
+            (direction OUTPUT))
+          (port PLLDATO5
+            (direction OUTPUT))
+          (port PLLDATO4
+            (direction OUTPUT))
+          (port PLLDATO3
+            (direction OUTPUT))
+          (port PLLDATO2
+            (direction OUTPUT))
+          (port PLLDATO1
+            (direction OUTPUT))
+          (port PLLDATO0
+            (direction OUTPUT)))))
+    (cell pll_4x266
+      (cellType GENERIC)
+      (view view1
+        (viewType NETLIST)
+        (interface
+          (port CLKI
+            (direction INPUT))
+          (port CLKOP
+            (direction OUTPUT))
+          (port CLKOS
+            (direction OUTPUT))
+          (port CLKOS2
+            (direction OUTPUT))
+          (port CLKOS3
+            (direction OUTPUT)))
+        (property NGD_DRC_MASK (integer 1))
+        (contents
+          (instance scuba_vlo_inst
+            (viewRef view1 
+              (cellRef VLO)))
+          (instance PLLInst_0
+            (viewRef view1 
+              (cellRef EHXPLLJ))
+            (property DDRST_ENA
+              (string "DISABLED"))
+            (property DCRST_ENA
+              (string "DISABLED"))
+            (property MRST_ENA
+              (string "DISABLED"))
+            (property PLLRST_ENA
+              (string "DISABLED"))
+            (property INTFB_WAKE
+              (string "DISABLED"))
+            (property STDBY_ENABLE
+              (string "DISABLED"))
+            (property DPHASE_SOURCE
+              (string "DISABLED"))
+            (property PLL_USE_WB
+              (string "DISABLED"))
+            (property CLKOS3_FPHASE
+              (string "6"))
+            (property CLKOS3_CPHASE
+              (string "1"))
+            (property CLKOS2_FPHASE
+              (string "4"))
+            (property CLKOS2_CPHASE
+              (string "1"))
+            (property CLKOS_FPHASE
+              (string "2"))
+            (property CLKOS_CPHASE
+              (string "1"))
+            (property CLKOP_FPHASE
+              (string "0"))
+            (property CLKOP_CPHASE
+              (string "1"))
+            (property PLL_LOCK_MODE
+              (string "0"))
+            (property CLKOS_TRIM_DELAY
+              (string "0"))
+            (property CLKOS_TRIM_POL
+              (string "RISING"))
+            (property CLKOP_TRIM_DELAY
+              (string "0"))
+            (property CLKOP_TRIM_POL
+              (string "RISING"))
+            (property FRACN_DIV
+              (string "0"))
+            (property FRACN_ENABLE
+              (string "DISABLED"))
+            (property FREQUENCY_PIN_CLKOS3
+              (string "250.000000"))
+            (property OUTDIVIDER_MUXD2
+              (string "DIVD"))
+            (property PREDIVIDER_MUXD1
+              (string "0"))
+            (property VCO_BYPASS_D0
+              (string "DISABLED"))
+            (property CLKOS3_ENABLE
+              (string "ENABLED"))
+            (property FREQUENCY_PIN_CLKOS2
+              (string "250.000000"))
+            (property OUTDIVIDER_MUXC2
+              (string "DIVC"))
+            (property PREDIVIDER_MUXC1
+              (string "0"))
+            (property VCO_BYPASS_C0
+              (string "DISABLED"))
+            (property CLKOS2_ENABLE
+              (string "ENABLED"))
+            (property FREQUENCY_PIN_CLKOS
+              (string "250.000000"))
+            (property OUTDIVIDER_MUXB2
+              (string "DIVB"))
+            (property PREDIVIDER_MUXB1
+              (string "0"))
+            (property VCO_BYPASS_B0
+              (string "DISABLED"))
+            (property CLKOS_ENABLE
+              (string "ENABLED"))
+            (property FREQUENCY_PIN_CLKOP
+              (string "250.000000"))
+            (property OUTDIVIDER_MUXA2
+              (string "DIVA"))
+            (property PREDIVIDER_MUXA1
+              (string "0"))
+            (property VCO_BYPASS_A0
+              (string "DISABLED"))
+            (property CLKOP_ENABLE
+              (string "ENABLED"))
+            (property FREQUENCY_PIN_CLKI
+              (string "125.000000"))
+            (property ICP_CURRENT
+              (string "10"))
+            (property LPF_RESISTOR
+              (string "24"))
+            (property CLKOS3_DIV
+              (string "2"))
+            (property CLKOS2_DIV
+              (string "2"))
+            (property CLKOS_DIV
+              (string "2"))
+            (property CLKOP_DIV
+              (string "2"))
+            (property CLKFB_DIV
+              (string "2"))
+            (property CLKI_DIV
+              (string "1"))
+            (property FEEDBK_PATH
+              (string "INT_DIVA")))
+          (net LOCK
+            (joined
+              (portRef LOCK (instanceRef PLLInst_0))))
+          (net CLKFB_t
+            (joined
+              (portRef CLKFB (instanceRef PLLInst_0))
+              (portRef CLKINTFB (instanceRef PLLInst_0))))
+          (net scuba_vlo
+            (joined
+              (portRef Z (instanceRef scuba_vlo_inst))
+              (portRef PLLADDR4 (instanceRef PLLInst_0))
+              (portRef PLLADDR3 (instanceRef PLLInst_0))
+              (portRef PLLADDR2 (instanceRef PLLInst_0))
+              (portRef PLLADDR1 (instanceRef PLLInst_0))
+              (portRef PLLADDR0 (instanceRef PLLInst_0))
+              (portRef PLLDATI7 (instanceRef PLLInst_0))
+              (portRef PLLDATI6 (instanceRef PLLInst_0))
+              (portRef PLLDATI5 (instanceRef PLLInst_0))
+              (portRef PLLDATI4 (instanceRef PLLInst_0))
+              (portRef PLLDATI3 (instanceRef PLLInst_0))
+              (portRef PLLDATI2 (instanceRef PLLInst_0))
+              (portRef PLLDATI1 (instanceRef PLLInst_0))
+              (portRef PLLDATI0 (instanceRef PLLInst_0))
+              (portRef PLLWE (instanceRef PLLInst_0))
+              (portRef PLLSTB (instanceRef PLLInst_0))
+              (portRef PLLRST (instanceRef PLLInst_0))
+              (portRef PLLCLK (instanceRef PLLInst_0))
+              (portRef ENCLKOS3 (instanceRef PLLInst_0))
+              (portRef ENCLKOS2 (instanceRef PLLInst_0))
+              (portRef ENCLKOS (instanceRef PLLInst_0))
+              (portRef ENCLKOP (instanceRef PLLInst_0))
+              (portRef RESETD (instanceRef PLLInst_0))
+              (portRef RESETC (instanceRef PLLInst_0))
+              (portRef RESETM (instanceRef PLLInst_0))
+              (portRef RST (instanceRef PLLInst_0))
+              (portRef PLLWAKESYNC (instanceRef PLLInst_0))
+              (portRef STDBY (instanceRef PLLInst_0))
+              (portRef LOADREG (instanceRef PLLInst_0))
+              (portRef PHASESTEP (instanceRef PLLInst_0))
+              (portRef PHASEDIR (instanceRef PLLInst_0))
+              (portRef PHASESEL1 (instanceRef PLLInst_0))
+              (portRef PHASESEL0 (instanceRef PLLInst_0))))
+          (net CLKOS3
+            (joined
+              (portRef CLKOS3)
+              (portRef CLKOS3 (instanceRef PLLInst_0))))
+          (net CLKOS2
+            (joined
+              (portRef CLKOS2)
+              (portRef CLKOS2 (instanceRef PLLInst_0))))
+          (net CLKOS
+            (joined
+              (portRef CLKOS)
+              (portRef CLKOS (instanceRef PLLInst_0))))
+          (net CLKOP
+            (joined
+              (portRef CLKOP)
+              (portRef CLKOP (instanceRef PLLInst_0))))
+          (net CLKI
+            (joined
+              (portRef CLKI)
+              (portRef CLKI (instanceRef PLLInst_0))))))))
+  (design pll_4x266
+    (cellRef pll_4x266
+      (libraryRef ORCLIB)))
+)
diff --git a/cores/pll_4x266.ipx b/cores/pll_4x266.ipx
new file mode 100644 (file)
index 0000000..1e203ff
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<DiamondModule name="pll_4x266" module="PLL" VendorName="Lattice Semiconductor Corporation" generator="IPexpress" date="2016 04 05 17:14:33.785" version="5.8" type="Module" synthesis="synplify" source_format="VHDL">
+  <Package>
+               <File name="pll_4x266.lpc" type="lpc" modified="2016 04 05 17:14:32.000"/>
+               <File name="pll_4x266.vhd" type="top_level_vhdl" modified="2016 04 05 17:14:32.000"/>
+               <File name="pll_4x266_tmpl.vhd" type="template_vhdl" modified="2016 04 05 17:14:32.000"/>
+  </Package>
+</DiamondModule>
diff --git a/cores/pll_4x266.jhd b/cores/pll_4x266.jhd
new file mode 100644 (file)
index 0000000..1c8c0fd
--- /dev/null
@@ -0,0 +1,5 @@
+MODULE pll_4x266 DEFIN pll_4x266.vhd
+       SUBMODULE EHXPLLJ
+               INSTANCE PLLInst_0
+       SUBMODULE VLO
+               INSTANCE scuba_vlo_inst
diff --git a/cores/pll_4x266.lpc b/cores/pll_4x266.lpc
new file mode 100644 (file)
index 0000000..3d397ba
--- /dev/null
@@ -0,0 +1,87 @@
+[Device]
+Family=machxo3lf
+PartType=LCMXO3LF-2100E
+PartName=LCMXO3LF-2100E-5UWG49CTR
+SpeedGrade=5
+Package=WLCSP49
+OperatingCondition=COM
+Status=S
+
+[IP]
+VendorName=Lattice Semiconductor Corporation
+CoreType=LPM
+CoreStatus=Demo
+CoreName=PLL
+CoreRevision=5.8
+ModuleName=pll_4x266
+SourceFormat=VHDL
+ParameterFileVersion=1.0
+Date=04/05/2016
+Time=17:14:32
+
+[Parameters]
+Verilog=0
+VHDL=1
+EDIF=1
+Destination=Synplicity
+Expression=None
+Order=None
+IO=0
+mode=Frequency
+CLKI=125
+CLKI_DIV=1
+BW=10.504
+VCO=500.000
+fb_mode=INT_OP
+CLKFB_DIV=2
+FRACN_ENABLE=0
+FRACN_DIV=0
+DynamicPhase=STATIC
+ClkEnable=0
+Standby=0
+Enable_sel=0
+PLLRst=0
+PLLMRst=0
+ClkOS2Rst=0
+ClkOS3Rst=0
+LockSig=0
+LockStk=0
+WBProt=0
+OPBypass=0
+OPUseDiv=0
+CLKOP_DIV=2
+FREQ_PIN_CLKOP=250
+OP_Tol=1.0
+CLKOP_AFREQ=250.000000
+CLKOP_PHASEADJ=0
+CLKOP_TRIM_POL=Rising
+CLKOP_TRIM_DELAY=0
+EnCLKOS=1
+OSBypass=0
+OSUseDiv=0
+CLKOS_DIV=2
+FREQ_PIN_CLKOS=250
+OS_Tol=0.0
+CLKOS_AFREQ=250.000000
+CLKOS_PHASEADJ=45
+CLKOS_TRIM_POL=Rising
+CLKOS_TRIM_DELAY=0
+EnCLKOS2=1
+OS2Bypass=0
+OS2UseDiv=0
+CLKOS2_DIV=2
+FREQ_PIN_CLKOS2=250
+OS2_Tol=0.0
+CLKOS2_AFREQ=250.000000
+CLKOS2_PHASEADJ=90
+EnCLKOS3=1
+OS3Bypass=0
+OS3UseDiv=0
+CLKOS3_DIV=2
+FREQ_PIN_CLKOS3=250
+OS3_Tol=0.0
+CLKOS3_AFREQ=250.000000
+CLKOS3_PHASEADJ=135
+
+[Command]
+cmd_line= -w -n pll_4x266 -lang vhdl -synth synplify -arch xo3c00f -type pll -fin 125 -fclkop 250 -fclkop_tol 1.0 -fclkos 250 -fclkos_tol 0.0 -fclkos2 250 -fclkos2_tol 0.0 -fclkos3 250 -fclkos3_tol 0.0 -trimp 0 -phasep 0 -trimp_r -trims 0 -phases 45 -trims_r -phases2 90 -phases3 135 -phase_cntl STATIC -fb_mode 5
diff --git a/cores/pll_4x266.naf b/cores/pll_4x266.naf
new file mode 100644 (file)
index 0000000..1ec155b
--- /dev/null
@@ -0,0 +1,5 @@
+CLKI  i
+CLKOP  o
+CLKOS  o
+CLKOS2  o
+CLKOS3  o
diff --git a/cores/pll_4x266.sort b/cores/pll_4x266.sort
new file mode 100644 (file)
index 0000000..d2de70f
--- /dev/null
@@ -0,0 +1 @@
+pll_4x266.vhd
diff --git a/cores/pll_4x266.srp b/cores/pll_4x266.srp
new file mode 100644 (file)
index 0000000..060856c
--- /dev/null
@@ -0,0 +1,26 @@
+SCUBA, Version Diamond (64-bit) 3.7.0.96.1
+Tue Apr  5 17:14:32 2016
+
+Copyright (c) 1991-1994 by NeoCAD Inc. All rights reserved.
+Copyright (c) 1995 AT&T Corp.   All rights reserved.
+Copyright (c) 1995-2001 Lucent Technologies Inc.  All rights reserved.
+Copyright (c) 2001 Agere Systems   All rights reserved.
+Copyright (c) 2002-2016 Lattice Semiconductor Corporation,  All rights reserved.
+
+    Issued command   : /d/jspc29/lattice/diamond/3.7_x64/ispfpga/bin/lin64/scuba -w -n pll_4x266 -lang vhdl -synth synplify -arch xo3c00f -type pll -fin 125 -fclkop 250 -fclkop_tol 1.0 -fclkos 250 -fclkos_tol 0.0 -fclkos2 250 -fclkos2_tol 0.0 -fclkos3 250 -fclkos3_tol 0.0 -trimp 0 -phasep 0 -trimp_r -trims 0 -phases 45 -trims_r -phases2 90 -phases3 135 -phase_cntl STATIC -fb_mode 5 
+    Circuit name     : pll_4x266
+    Module type      : pll
+    Module Version   : 5.7
+    Ports            : 
+       Inputs       : CLKI
+       Outputs      : CLKOP, CLKOS, CLKOS2, CLKOS3
+    I/O buffer       : not inserted
+    EDIF output      : pll_4x266.edn
+    VHDL output      : pll_4x266.vhd
+    VHDL template    : pll_4x266_tmpl.vhd
+    VHDL purpose     : for synthesis and simulation
+    Bus notation     : big endian
+    Report output    : pll_4x266.srp
+    Element Usage    :
+        EHXPLLJ : 1
+    Estimated Resource Usage:
diff --git a/cores/pll_4x266.sym b/cores/pll_4x266.sym
new file mode 100644 (file)
index 0000000..fe0bde9
Binary files /dev/null and b/cores/pll_4x266.sym differ
diff --git a/cores/pll_4x266.vhd b/cores/pll_4x266.vhd
new file mode 100644 (file)
index 0000000..7ff3200
--- /dev/null
@@ -0,0 +1,170 @@
+-- VHDL netlist generated by SCUBA Diamond (64-bit) 3.7.0.96.1
+-- Module  Version: 5.7
+--/d/jspc29/lattice/diamond/3.7_x64/ispfpga/bin/lin64/scuba -w -n pll_4x266 -lang vhdl -synth synplify -arch xo3c00f -type pll -fin 125 -fclkop 250 -fclkop_tol 1.0 -fclkos 250 -fclkos_tol 0.0 -fclkos2 250 -fclkos2_tol 0.0 -fclkos3 250 -fclkos3_tol 0.0 -trimp 0 -phasep 0 -trimp_r -trims 0 -phases 45 -trims_r -phases2 90 -phases3 135 -phase_cntl STATIC -fb_mode 5 
+
+-- Tue Apr  5 17:14:32 2016
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+-- synopsys translate_off
+library MACHXO3L;
+use MACHXO3L.components.all;
+-- synopsys translate_on
+
+entity pll_4x266 is
+    port (
+        CLKI: in  std_logic; 
+        CLKOP: out  std_logic; 
+        CLKOS: out  std_logic; 
+        CLKOS2: out  std_logic; 
+        CLKOS3: out  std_logic);
+end pll_4x266;
+
+architecture Structure of pll_4x266 is
+
+    -- internal signal declarations
+    signal LOCK: std_logic;
+    signal CLKOS3_t: std_logic;
+    signal CLKOS2_t: std_logic;
+    signal CLKOS_t: std_logic;
+    signal CLKOP_t: std_logic;
+    signal CLKFB_t: std_logic;
+    signal scuba_vlo: std_logic;
+
+    -- local component declarations
+    component VLO
+        port (Z: out  std_logic);
+    end component;
+    component EHXPLLJ
+        generic (INTFB_WAKE : in String; DDRST_ENA : in String; 
+                DCRST_ENA : in String; MRST_ENA : in String; 
+                PLLRST_ENA : in String; DPHASE_SOURCE : in String; 
+                STDBY_ENABLE : in String; OUTDIVIDER_MUXD2 : in String; 
+                OUTDIVIDER_MUXC2 : in String; 
+                OUTDIVIDER_MUXB2 : in String; 
+                OUTDIVIDER_MUXA2 : in String; 
+                PREDIVIDER_MUXD1 : in Integer; 
+                PREDIVIDER_MUXC1 : in Integer; 
+                PREDIVIDER_MUXB1 : in Integer; 
+                PREDIVIDER_MUXA1 : in Integer; PLL_USE_WB : in String; 
+                PLL_LOCK_MODE : in Integer; 
+                CLKOS_TRIM_DELAY : in Integer; 
+                CLKOS_TRIM_POL : in String; 
+                CLKOP_TRIM_DELAY : in Integer; 
+                CLKOP_TRIM_POL : in String; FRACN_DIV : in Integer; 
+                FRACN_ENABLE : in String; FEEDBK_PATH : in String; 
+                CLKOS3_FPHASE : in Integer; CLKOS2_FPHASE : in Integer; 
+                CLKOS_FPHASE : in Integer; CLKOP_FPHASE : in Integer; 
+                CLKOS3_CPHASE : in Integer; CLKOS2_CPHASE : in Integer; 
+                CLKOS_CPHASE : in Integer; CLKOP_CPHASE : in Integer; 
+                VCO_BYPASS_D0 : in String; VCO_BYPASS_C0 : in String; 
+                VCO_BYPASS_B0 : in String; VCO_BYPASS_A0 : in String; 
+                CLKOS3_ENABLE : in String; CLKOS2_ENABLE : in String; 
+                CLKOS_ENABLE : in String; CLKOP_ENABLE : in String; 
+                CLKOS3_DIV : in Integer; CLKOS2_DIV : in Integer; 
+                CLKOS_DIV : in Integer; CLKOP_DIV : in Integer; 
+                CLKFB_DIV : in Integer; CLKI_DIV : in Integer);
+        port (CLKI: in  std_logic; CLKFB: in  std_logic; 
+            PHASESEL1: in  std_logic; PHASESEL0: in  std_logic; 
+            PHASEDIR: in  std_logic; PHASESTEP: in  std_logic; 
+            LOADREG: in  std_logic; STDBY: in  std_logic; 
+            PLLWAKESYNC: in  std_logic; RST: in  std_logic; 
+            RESETM: in  std_logic; RESETC: in  std_logic; 
+            RESETD: in  std_logic; ENCLKOP: in  std_logic; 
+            ENCLKOS: in  std_logic; ENCLKOS2: in  std_logic; 
+            ENCLKOS3: in  std_logic; PLLCLK: in  std_logic; 
+            PLLRST: in  std_logic; PLLSTB: in  std_logic; 
+            PLLWE: in  std_logic; PLLADDR4: in  std_logic; 
+            PLLADDR3: in  std_logic; PLLADDR2: in  std_logic; 
+            PLLADDR1: in  std_logic; PLLADDR0: in  std_logic; 
+            PLLDATI7: in  std_logic; PLLDATI6: in  std_logic; 
+            PLLDATI5: in  std_logic; PLLDATI4: in  std_logic; 
+            PLLDATI3: in  std_logic; PLLDATI2: in  std_logic; 
+            PLLDATI1: in  std_logic; PLLDATI0: in  std_logic; 
+            CLKOP: out  std_logic; CLKOS: out  std_logic; 
+            CLKOS2: out  std_logic; CLKOS3: out  std_logic; 
+            LOCK: out  std_logic; INTLOCK: out  std_logic; 
+            REFCLK: out  std_logic; CLKINTFB: out  std_logic; 
+            DPHSRC: out  std_logic; PLLACK: out  std_logic; 
+            PLLDATO7: out  std_logic; PLLDATO6: out  std_logic; 
+            PLLDATO5: out  std_logic; PLLDATO4: out  std_logic; 
+            PLLDATO3: out  std_logic; PLLDATO2: out  std_logic; 
+            PLLDATO1: out  std_logic; PLLDATO0: out  std_logic);
+    end component;
+    attribute FREQUENCY_PIN_CLKOS3 : string; 
+    attribute FREQUENCY_PIN_CLKOS2 : string; 
+    attribute FREQUENCY_PIN_CLKOS : string; 
+    attribute FREQUENCY_PIN_CLKOP : string; 
+    attribute FREQUENCY_PIN_CLKI : string; 
+    attribute ICP_CURRENT : string; 
+    attribute LPF_RESISTOR : string; 
+    attribute FREQUENCY_PIN_CLKOS3 of PLLInst_0 : label is "250.000000";
+    attribute FREQUENCY_PIN_CLKOS2 of PLLInst_0 : label is "250.000000";
+    attribute FREQUENCY_PIN_CLKOS of PLLInst_0 : label is "250.000000";
+    attribute FREQUENCY_PIN_CLKOP of PLLInst_0 : label is "250.000000";
+    attribute FREQUENCY_PIN_CLKI of PLLInst_0 : label is "125.000000";
+    attribute ICP_CURRENT of PLLInst_0 : label is "10";
+    attribute LPF_RESISTOR of PLLInst_0 : label is "24";
+    attribute syn_keep : boolean;
+    attribute NGD_DRC_MASK : integer;
+    attribute NGD_DRC_MASK of Structure : architecture is 1;
+
+begin
+    -- component instantiation statements
+    scuba_vlo_inst: VLO
+        port map (Z=>scuba_vlo);
+
+    PLLInst_0: EHXPLLJ
+        generic map (DDRST_ENA=> "DISABLED", DCRST_ENA=> "DISABLED", 
+        MRST_ENA=> "DISABLED", PLLRST_ENA=> "DISABLED", INTFB_WAKE=> "DISABLED", 
+        STDBY_ENABLE=> "DISABLED", DPHASE_SOURCE=> "DISABLED", 
+        PLL_USE_WB=> "DISABLED", CLKOS3_FPHASE=>  6, CLKOS3_CPHASE=>  1, 
+        CLKOS2_FPHASE=>  4, CLKOS2_CPHASE=>  1, CLKOS_FPHASE=>  2, 
+        CLKOS_CPHASE=>  1, CLKOP_FPHASE=>  0, CLKOP_CPHASE=>  1, 
+        PLL_LOCK_MODE=>  0, CLKOS_TRIM_DELAY=>  0, CLKOS_TRIM_POL=> "RISING", 
+        CLKOP_TRIM_DELAY=>  0, CLKOP_TRIM_POL=> "RISING", FRACN_DIV=>  0, 
+        FRACN_ENABLE=> "DISABLED", OUTDIVIDER_MUXD2=> "DIVD", 
+        PREDIVIDER_MUXD1=>  0, VCO_BYPASS_D0=> "DISABLED", CLKOS3_ENABLE=> "ENABLED", 
+        OUTDIVIDER_MUXC2=> "DIVC", PREDIVIDER_MUXC1=>  0, VCO_BYPASS_C0=> "DISABLED", 
+        CLKOS2_ENABLE=> "ENABLED", OUTDIVIDER_MUXB2=> "DIVB", 
+        PREDIVIDER_MUXB1=>  0, VCO_BYPASS_B0=> "DISABLED", CLKOS_ENABLE=> "ENABLED", 
+        OUTDIVIDER_MUXA2=> "DIVA", PREDIVIDER_MUXA1=>  0, VCO_BYPASS_A0=> "DISABLED", 
+        CLKOP_ENABLE=> "ENABLED", CLKOS3_DIV=>  2, CLKOS2_DIV=>  2, 
+        CLKOS_DIV=>  2, CLKOP_DIV=>  2, CLKFB_DIV=>  2, CLKI_DIV=>  1, 
+        FEEDBK_PATH=> "INT_DIVA")
+        port map (CLKI=>CLKI, CLKFB=>CLKFB_t, PHASESEL1=>scuba_vlo, 
+            PHASESEL0=>scuba_vlo, PHASEDIR=>scuba_vlo, 
+            PHASESTEP=>scuba_vlo, LOADREG=>scuba_vlo, STDBY=>scuba_vlo, 
+            PLLWAKESYNC=>scuba_vlo, RST=>scuba_vlo, RESETM=>scuba_vlo, 
+            RESETC=>scuba_vlo, RESETD=>scuba_vlo, ENCLKOP=>scuba_vlo, 
+            ENCLKOS=>scuba_vlo, ENCLKOS2=>scuba_vlo, ENCLKOS3=>scuba_vlo, 
+            PLLCLK=>scuba_vlo, PLLRST=>scuba_vlo, PLLSTB=>scuba_vlo, 
+            PLLWE=>scuba_vlo, PLLADDR4=>scuba_vlo, PLLADDR3=>scuba_vlo, 
+            PLLADDR2=>scuba_vlo, PLLADDR1=>scuba_vlo, 
+            PLLADDR0=>scuba_vlo, PLLDATI7=>scuba_vlo, 
+            PLLDATI6=>scuba_vlo, PLLDATI5=>scuba_vlo, 
+            PLLDATI4=>scuba_vlo, PLLDATI3=>scuba_vlo, 
+            PLLDATI2=>scuba_vlo, PLLDATI1=>scuba_vlo, 
+            PLLDATI0=>scuba_vlo, CLKOP=>CLKOP_t, CLKOS=>CLKOS_t, 
+            CLKOS2=>CLKOS2_t, CLKOS3=>CLKOS3_t, LOCK=>LOCK, 
+            INTLOCK=>open, REFCLK=>open, CLKINTFB=>CLKFB_t, DPHSRC=>open, 
+            PLLACK=>open, PLLDATO7=>open, PLLDATO6=>open, PLLDATO5=>open, 
+            PLLDATO4=>open, PLLDATO3=>open, PLLDATO2=>open, 
+            PLLDATO1=>open, PLLDATO0=>open);
+
+    CLKOS3 <= CLKOS3_t;
+    CLKOS2 <= CLKOS2_t;
+    CLKOS <= CLKOS_t;
+    CLKOP <= CLKOP_t;
+end Structure;
+
+-- synopsys translate_off
+library MACHXO3L;
+configuration Structure_CON of pll_4x266 is
+    for Structure
+        for all:VLO use entity MACHXO3L.VLO(V); end for;
+        for all:EHXPLLJ use entity MACHXO3L.EHXPLLJ(V); end for;
+    end for;
+end Structure_CON;
+
+-- synopsys translate_on
diff --git a/cores/pll_4x266_generate.log b/cores/pll_4x266_generate.log
new file mode 100644 (file)
index 0000000..7a13545
--- /dev/null
@@ -0,0 +1,44 @@
+Starting process: Module
+
+Starting process: 
+
+SCUBA, Version Diamond (64-bit) 3.7.0.96.1
+Tue Apr  5 17:14:32 2016
+
+Copyright (c) 1991-1994 by NeoCAD Inc. All rights reserved.
+Copyright (c) 1995 AT&T Corp.   All rights reserved.
+Copyright (c) 1995-2001 Lucent Technologies Inc.  All rights reserved.
+Copyright (c) 2001 Agere Systems   All rights reserved.
+Copyright (c) 2002-2016 Lattice Semiconductor Corporation,  All rights reserved.
+
+BEGIN SCUBA Module Synthesis
+
+    Issued command   : /d/jspc29/lattice/diamond/3.7_x64/ispfpga/bin/lin64/scuba -w -n pll_4x266 -lang vhdl -synth synplify -arch xo3c00f -type pll -fin 125 -fclkop 250 -fclkop_tol 1.0 -fclkos 250 -fclkos_tol 0.0 -fclkos2 250 -fclkos2_tol 0.0 -fclkos3 250 -fclkos3_tol 0.0 -trimp 0 -phasep 0 -trimp_r -trims 0 -phases 45 -trims_r -phases2 90 -phases3 135 -phase_cntl STATIC -fb_mode 5 
+    Circuit name     : pll_4x266
+    Module type      : pll
+    Module Version   : 5.7
+    Ports            : 
+       Inputs       : CLKI
+       Outputs      : CLKOP, CLKOS, CLKOS2, CLKOS3
+    I/O buffer       : not inserted
+    EDIF output      : pll_4x266.edn
+    VHDL output      : pll_4x266.vhd
+    VHDL template    : pll_4x266_tmpl.vhd
+    VHDL purpose     : for synthesis and simulation
+    Bus notation     : big endian
+    Report output    : pll_4x266.srp
+    Estimated Resource Usage:
+
+END   SCUBA Module Synthesis
+
+File: pll_4x266.lpc created.
+
+
+End process: completed successfully.
+
+
+Total Warnings:  0
+
+Total Errors:  0
+
+
diff --git a/cores/pll_4x266_tmpl.vhd b/cores/pll_4x266_tmpl.vhd
new file mode 100644 (file)
index 0000000..121fadf
--- /dev/null
@@ -0,0 +1,14 @@
+-- VHDL module instantiation generated by SCUBA Diamond (64-bit) 3.7.0.96.1
+-- Module  Version: 5.7
+-- Tue Apr  5 17:14:32 2016
+
+-- parameterized module component declaration
+component pll_4x266
+    port (CLKI: in  std_logic; CLKOP: out  std_logic; 
+        CLKOS: out  std_logic; CLKOS2: out  std_logic; 
+        CLKOS3: out  std_logic);
+end component;
+
+-- parameterized module component instance
+__ : pll_4x266
+    port map (CLKI=>__, CLKOP=>__, CLKOS=>__, CLKOS2=>__, CLKOS3=>__);
diff --git a/dbowk/compile.pl b/dbowk/compile.pl
new file mode 100755 (executable)
index 0000000..1c4427f
--- /dev/null
@@ -0,0 +1,447 @@
+#!/usr/bin/perl
+use Data::Dumper;
+use warnings;
+use strict;
+use FileHandle;
+use Getopt::Long;
+use Term::ANSIColor qw(:constants);
+
+
+my $FAMILYNAME="LatticeECP3";
+my $DEVICENAME="LFE3-150EA";
+my $PACKAGE="FPBGA1156";
+my $SPEEDGRADE="8";
+
+
+my %config = do "config_compile.pl";
+
+
+my $TOPNAME                      = $config{TOPNAME};
+my $lattice_path                 = $config{lattice_path};
+my $synplify_path                = $config{synplify_path}; 
+my $lm_license_file_for_synplify = $config{lm_license_file_for_synplify};
+my $lm_license_file_for_par      = $config{lm_license_file_for_par};
+my $synplify_command             = $config{synplify_command};
+
+#my $synplify_locale_workaround   = "en_US\@UTF-8";
+my $synplify_locale_workaround   = "C";
+my $lattice_bin_path             = "$lattice_path/bin/lin64"; # note the lin/lin64 at the end, no isfgpa needed
+
+my $include_TDC                  = $config{include_TDC} || 0;
+my $include_GBE                  = $config{include_GBE} || 0;
+my $twr_number_of_errors         = $config{twr_number_of_errors} || 10;
+my $pinout_file                  = $config{pinout_file} || $TOPNAME;
+my $nodelist_file                = $config{nodelist_file} || 'nodelist.txt';
+
+$FAMILYNAME = $config{Familyname} if $config{Familyname};
+$DEVICENAME = $config{Devicename} if $config{Devicename};
+$PACKAGE    = $config{Package} if $config{Package};
+$SPEEDGRADE = $config{Speedgrade} if $config{Speedgrade};
+
+###################################################################################
+#Settings for this project
+
+###################################################################################
+
+###################################################################################
+#Options for the script
+my $help = "";
+my $isMultiPar = 0; # set it to zero for single par run on the local machine
+my $nrNodes    = 0; # set it to one for single par run on the local machine
+my $all        = 1;
+my $syn        = 0;
+my $map        = 0;
+my $par        = 0;
+my $timing     = 0;
+my $bitgen     = 0;
+my $con        = 0;
+my $guidefile  = 0;
+my $parallel   = '';
+
+my $result = GetOptions (
+    "h|help"   => \$help,
+    "m|mpar=i" => \$nrNodes,
+    "a|all"    => \$all,
+    "c|con"    => \$con,
+    "s|syn"    => \$syn,
+    "mp|map"   => \$map,
+    "p|par"    => \$par,
+    "t|timing" => \$timing,
+    "b|bitgen" => \$bitgen,
+    "g|guide"  => \$guidefile,
+    "mc|multicore" => \$parallel
+    );
+
+
+
+if($help) {
+    print "Usage: compile_priph_gsi.de <OPTIONS><ARGUMENTS>\n\n";
+    print "-h  --help\tPrints the usage manual.\n";
+    print "-a  --all\tRun all compile script. By default the script is going to run the whole process.\n";
+    print "-s  --syn\tRun synthesis part of the compile script.\n";
+    print "-c  --con\tCompile constraints only.\n";
+    print "-mp --map\tRun map part of the compile script.\n";
+    print "-p  --par\tRun par part of the compile script.\n";
+    print "-t  --timing\tRun timing analysis part of the compile script.\n";
+    print "-b  --bitgen\tRun bit generation part of the compile script.\n";
+    print "-m  --mpar\tSwitch for multi par. \"-m <number_of_nodes>\" (Default = off)\n";
+    print "\t\tThe node list file name has to be edited in the script. (Default = nodes_lxhadeb07.txt)\n";
+    print "\n";
+    exit;
+}
+
+if ($nrNodes!=0){
+    $isMultiPar=1;
+}
+if ($con!=0 || $syn!=0 || $map!=0 || $par!=0 || $timing!=0 || $bitgen!=0){
+    $all=0;
+}
+$parallel = '&' if $parallel;
+
+###################################################################################
+
+
+# source the standard lattice environment
+$ENV{bindir}="$lattice_bin_path";
+
+#open my $SOURCE, "bash -c '. $lattice_bin_path/diamond_env >& /dev/null; env'|" or
+#  die "Can't fork: $!";
+#while (<$SOURCE>) {
+#  if (/^(.*)=(.*)/) {
+#      print "setting A:$1 nach ${2}\n";
+#    $ENV{$1} = ${2} ;
+#  }
+#}
+#close $SOURCE;
+
+
+$ENV{'PAR_DESIGN_NAME'}=$TOPNAME;
+$ENV{'SYNPLIFY'}=$synplify_path;
+$ENV{'LC_ALL'}=$synplify_locale_workaround;
+$ENV{'SYN_DISABLE_RAINBOW_DONGLE'}=1;
+$ENV{'LM_LICENSE_FILE'}=$lm_license_file_for_synplify;
+$ENV{'SYNPLIFY_BINARY'}=$config{synplify_binary};
+
+
+
+
+
+
+my $WORKDIR = "workdir";
+unless(-d $WORKDIR) {
+  mkdir $WORKDIR or die "can't create workdir '$WORKDIR': $!";
+  system ("cd workdir; ../../../trb3/base/linkdesignfiles.sh; cd ..;");
+}
+
+system("ln -sfT $lattice_path $WORKDIR/lattice-diamond");
+
+
+if($con==1 || $all==1){
+  #create full lpf file
+  print GREEN, "Generating constraints file...\n\n", RESET;
+  system("cp ../pinout/$pinout_file.lpf $WORKDIR/$TOPNAME.lpf");
+
+#   system("cat ../pinout/trb3sc_basic.lpf >> $WORKDIR/$TOPNAME.lpf");
+  my $c = "cat ../pinout/basic_constraints.lpf >> $WORKDIR/$TOPNAME.lpf";
+  system($c);
+
+  system("cat $TOPNAME.lpf >> $WORKDIR/$TOPNAME.lpf");
+
+  if($include_TDC) {
+    #system("cat ../../trb3sc/tdc_release/trbnet_constraints.lpf >> $WORKDIR/$TOPNAME.lpf");
+    system("cat ../../trb3sc/tdc_release/tdc_constraints_64.lpf >> $WORKDIR/$TOPNAME.lpf");
+    system("cat ../../trb3sc/tdc_release/unimportant_lines_constraints.lpf >> $WORKDIR/$TOPNAME.lpf");
+
+    #change the Ring buffer name in the constraints file according to the config.vhd
+    my $fh = new FileHandle("<config.vhd");
+    my @a = <$fh>;
+    $fh -> close;
+    my $ringbuffersize = 5;
+    
+    foreach (@a)
+    {
+       if(/constant\s*RING_BUFFER_SIZE/)
+       {
+           my $tmp = $1 if $_ =~ /(:=.*;)/;
+           $ringbuffersize = $1 if $1 =~ /(\d+)/;
+       }
+    }
+
+    my @newline;
+    $fh = new FileHandle("<$WORKDIR/$TOPNAME".".lpf");
+    @a = <$fh>;
+    $fh -> close;
+    
+    foreach (@a)
+    {
+       if ($ringbuffersize == 0) {
+           $_ =~ s/Buffer_128.The_Buffer/Buffer_32.The_Buffer/g;
+       }
+       elsif ($ringbuffersize == 1 || $ringbuffersize == 5) {
+           $_ =~ s/Buffer_128.The_Buffer/Buffer_64.The_Buffer/g;
+       }
+       elsif ($ringbuffersize == 2) {
+           $_ =~ s/Buffer_128.The_Buffer/Buffer_96.The_Buffer/g;
+       }
+       elsif ($ringbuffersize == 3 || $ringbuffersize == 7) {
+           $_ =~ s/Buffer_128.The_Buffer/Buffer_128.The_Buffer/g;
+       }
+       else {
+           print "unknown ringbuffer size... \n";
+           exit 129;
+       }
+
+       push(@newline,$_);
+    }
+    $fh = new FileHandle(">$WORKDIR/$TOPNAME".".lpf");
+    print $fh @newline;
+    $fh -> close;
+  }
+
+  if($include_GBE) {
+    }
+
+  #copy delay line to project folder
+  if($include_TDC) {
+    system("rm $WORKDIR/Adder_304.ngo");
+    system("ln -s ../../../tdc/base/cores/ecp3/TDC/Adder_304.ngo $WORKDIR/Adder_304.ngo");
+    }
+  }
+
+if($guidefile &&  -f "$TOPNAME.ncd") {
+  system("cp $TOPNAME.ncd guidefile.ncd");
+  $guidefile = " -g guidefile.ncd "
+  }
+else {
+  $guidefile = "";
+  }
+  
+#generate timestamp
+my $t=time;
+my $fh = new FileHandle(">$WORKDIR/version.vhd");
+die "could not open file" if (! defined $fh);
+print $fh <<EOF;
+
+--## attention, automatically generated. Don't change by hand.
+library ieee;
+USE IEEE.std_logic_1164.ALL;
+USE IEEE.std_logic_ARITH.ALL;
+USE IEEE.std_logic_UNSIGNED.ALL;
+use ieee.numeric_std.all;
+
+package version is
+
+    constant VERSION_NUMBER_TIME  : integer   := $t;
+
+end package version;
+EOF
+$fh->close;
+
+system("env| grep LM_");
+my $r     = "";
+my $c     = "";
+my @a     = ();
+my $tpmap = $TOPNAME . "_map" ;
+
+chdir $WORKDIR;
+if($syn==1 || $all==1){
+    print GREEN, "Starting synthesis process...\n\n", RESET;
+    $c="$synplify_command -batch ../$TOPNAME.prj";
+    $r=execute($c, "do_not_exit" );
+
+    $fh = new FileHandle("<$TOPNAME".".srr");
+    @a = <$fh>;
+    $fh -> close;
+    
+    foreach (@a)
+    {
+        if(/\@E:/)
+        {
+            print "\n";
+            $c="cat $TOPNAME.srr | egrep --color \"\@E:\"";
+            system($c);
+            print RED, "ERROR in the log file $TOPNAME.srr Exiting...\n\n", RESET;
+            exit 129;
+        }
+    }
+}
+
+
+
+$ENV{'LM_LICENSE_FILE'}=$lm_license_file_for_par;
+
+if($map==1 || $all==1){
+    print GREEN, "Starting mapping process...\n\n", RESET;
+
+    $c=qq| edif2ngd -path "../" -path "." -l $FAMILYNAME -d $DEVICENAME "$TOPNAME.edf" "$TOPNAME.ngo" |;
+    execute($c);
+    
+    $c=qq|edfupdate -t "$TOPNAME.tcy" -w "$TOPNAME.ngo" -m "$TOPNAME.ngo" "$TOPNAME.ngx"|;
+    execute($c);
+    
+    $c=qq|ngdbuild -a $FAMILYNAME -d $DEVICENAME -p "$lattice_path/ispfpga/ep5c00/data" -dt "$TOPNAME.ngo" "$TOPNAME.ngd"|;
+    execute($c);
+    
+    $c=qq|map -retime -split_node -a $FAMILYNAME -p $DEVICENAME -t $PACKAGE -s $SPEEDGRADE "$TOPNAME.ngd" -pr "$TOPNAME.prf" -o "$tpmap.ncd" -mp "$TOPNAME.mrp" "$TOPNAME.lpf"|;
+    execute($c);
+
+    $c=qq|htmlrpt -mrp $TOPNAME.mrp $TOPNAME|;
+    execute($c);
+
+    $fh = new FileHandle("<$TOPNAME"."_mrp.html");
+    @a = <$fh>;
+    $fh -> close;
+    my $i=1;
+    my $print=0;
+    foreach (@a)
+    {
+        if(/WARNING/|$print)
+        {
+            if((grep /WARNING - map: There are semantic errors in the preference file/, $_) & ($i == 1))
+            {
+                last;
+            }
+            elsif(grep /WARNING - map: There are semantic errors in the preference file/, $_)
+            {
+                print YELLOW, "There are errors in the constraints file. Better have a look...\n\n", RESET;
+                #sleep(5); # ERROR -> sleep is effective before the print
+                last;
+            }
+            elsif ($i == 1)
+            {
+                print RED,"\n\n", RESET;
+                print RED,"#################################################\n", RESET;
+                print RED,"CONSTRAINTS ERRORS\n", RESET;
+                print RED,"#################################################\n\n", RESET;
+            }
+            $print=1;
+            if(grep /WARNING.*UGROUP/, $_)
+            {
+                print RED, $_, RESET;
+            }
+            elsif(grep /FC|hitBuf|ff_en/, $_)
+            {
+                print YELLOW, $_, RESET;
+            }
+            else
+            {
+                print $_;
+            }
+            $i++;
+        }
+    }
+}
+
+if($par==1 || $all==1){
+    print GREEN, "Starting placement process...\n\n", RESET;
+
+    system("rm $TOPNAME.ncd");
+    if ($isMultiPar)
+    {
+        $c=qq|LC_ALL=en_US.UTF-8; par -m ../../scripts/$nodelist_file -n $nrNodes  -f "../par.p2t" $tpmap.ncd $TOPNAME.dir $TOPNAME.prf;|;
+        execute($c);
+
+        # find and copy the .ncd file which has met the timing constraints
+        $fh = new FileHandle("<$TOPNAME".".par");
+        my @a = <$fh>;
+        my $isSuccess = 0;
+        $fh -> close;
+        my $i=1;
+        foreach (@a)
+        {
+            my @line = split(/\s+/, $_);
+
+            if(@line && ($line[2] =~ m/^[0-9]+$/) && ($line[4] =~ m/^[0-9]+$/))
+            {        
+                    if(($line[2] == 0) && ($line[4] == 0))
+                    {
+                        print GREEN, "Copying $line[0].ncd file to workdir\n", RESET;
+                        my $c="cp $TOPNAME.dir/$line[0].ncd $TOPNAME.ncd";
+                        system($c);
+                        print "\n\n";
+                        $isSuccess = 1;
+                        last;
+                    }
+            }
+        }
+        
+        if (!$isSuccess){
+            print RED, "\n\n", RESET;
+            print RED, "#################################################\n", RESET;
+            print RED, "#           !!!PAR not succesfull!!!            #\n", RESET;
+            print RED, "#################################################\n\n", RESET;
+            exit 129;
+        }
+    }
+    else
+    {
+        $c=qq|par -f "../par.p2t"  $guidefile $tpmap.ncd $TOPNAME.ncd $TOPNAME.prf|;
+        execute($c);
+        #my $c="cp $TOPNAME.dir/5_1.ncd $TOPNAME.ncd";
+        #system($c);
+    }
+    my $c="cat $TOPNAME.par";
+    system($c);
+
+}
+
+
+if($timing==1 || $all==1){
+    print GREEN, "Generating timing report...\n\n", RESET;
+
+    # TWR Timing Report
+    $c=qq|trce -c -v $twr_number_of_errors -o "$TOPNAME.twr.setup" "$TOPNAME.ncd" "$TOPNAME.prf" $parallel|;
+    execute($c);
+    
+    $c=qq|trce -hld -c -v $twr_number_of_errors -o "$TOPNAME.twr.hold" "$TOPNAME.ncd" "$TOPNAME.prf" $parallel|;
+    execute($c);
+
+    # IOR IO Timing Report
+    $c=qq|iotiming -s "$TOPNAME.ncd" "$TOPNAME.prf"|;
+    execute($c);
+
+    my $c="cat $TOPNAME.par";
+    system($c);
+}
+    
+if($bitgen==1 || $all==1){
+    print GREEN, "Generating bit file...\n\n", RESET;
+
+    $c=qq|ltxt2ptxt $TOPNAME.ncd|;
+    execute($c) unless $config{no_ltxt2ptxt} ;
+
+    if($config{make_jed}) {
+      $c=qq|bitgen -w -g CfgMode:Disable -g RamCfg:Reset -g ES:No  -jedec $TOPNAME.ncd $TOPNAME.jed $TOPNAME.prf|;
+      }
+    else {
+      $c=qq|bitgen -w -g CfgMode:Disable -g RamCfg:Reset -g ES:No $TOPNAME.ncd $TOPNAME.bit $TOPNAME.prf|;
+      } 
+    execute($c);
+}
+
+$c=qq|htmlrpt -mrp $TOPNAME.mrp -mtwr $TOPNAME.twr.hold -ptwr $TOPNAME.twr.setup $TOPNAME|;
+execute($c);
+
+if($config{firefox_open}) {
+  $c=qq|firefox $TOPNAME.html|;
+  execute($c);
+  }
+
+chdir "..";
+exit;
+
+sub execute {
+    my ($c, $op) = @_;
+    #print "option: $op \n";
+    $op = "" if(!$op);
+    $c = ". $lattice_bin_path/diamond_env; " . $c;
+    print GREEN, "\n\ncommand to execute: $c \n", RESET;
+    $r=system($c);
+    if($r) {
+        print "$!";
+        if($op ne "do_not_exit") {
+            exit;
+        }
+    }
+    return $r;
+}
diff --git a/dbowk/config_compile.pl b/dbowk/config_compile.pl
new file mode 100644 (file)
index 0000000..6af3742
--- /dev/null
@@ -0,0 +1,26 @@
+Familyname  => 'MachXO3LF',
+Devicename  => 'LCMXO3LF-2100E',
+Package     => 'WLCSP49',
+Speedgrade  => '5',
+
+TOPNAME                      => "testtdc",
+lm_license_file_for_synplify => "1702\@hadeb05.gsi.de", #"27000\@lxcad01.gsi.de";
+lm_license_file_for_par      => "1702\@hadeb05.gsi.de",
+lattice_path                 => '/d/jspc29/lattice/diamond/3.6_x64',
+synplify_path                => '/d/jspc29/lattice/synplify/K-2015.09/',
+synplify_command             => "/d/jspc29/lattice/diamond/3.6_x64/bin/lin64/synpwrap -fg -options",
+# synplify_command             => "/d/jspc29/lattice/synplify/J-2014.09-SP2/bin/synplify_premier_dp",
+# synplify_command             => "ssh -p 59222 jmichel\@cerberus \"cd /home/jmichel/git/trb3sc/template/workdir; LM_LICENSE_FILE=27000\@lxcad01.gsi.de /opt/synplicity/K-2015.09/bin/synplify_premier_dp -batch ../trb3sc_basic.prj\" #",
+nodelist_file                => 'nodelist_frankfurt.txt',
+
+
+#Include only necessary lpf files
+#pinout_file                  => '', #name of pin-out file, if not equal TOPNAME
+include_TDC                  => 0,
+include_GBE                  => 0,
+
+#Report settings
+firefox_open                 => 0,
+twr_number_of_errors         => 20,
+no_ltxt2ptxt                 => 1,  #if there is no serdes being used
+make_jed                     => 1,
diff --git a/dbowk/config_compile_frankfurt.pl b/dbowk/config_compile_frankfurt.pl
new file mode 100644 (file)
index 0000000..6af3742
--- /dev/null
@@ -0,0 +1,26 @@
+Familyname  => 'MachXO3LF',
+Devicename  => 'LCMXO3LF-2100E',
+Package     => 'WLCSP49',
+Speedgrade  => '5',
+
+TOPNAME                      => "testtdc",
+lm_license_file_for_synplify => "1702\@hadeb05.gsi.de", #"27000\@lxcad01.gsi.de";
+lm_license_file_for_par      => "1702\@hadeb05.gsi.de",
+lattice_path                 => '/d/jspc29/lattice/diamond/3.6_x64',
+synplify_path                => '/d/jspc29/lattice/synplify/K-2015.09/',
+synplify_command             => "/d/jspc29/lattice/diamond/3.6_x64/bin/lin64/synpwrap -fg -options",
+# synplify_command             => "/d/jspc29/lattice/synplify/J-2014.09-SP2/bin/synplify_premier_dp",
+# synplify_command             => "ssh -p 59222 jmichel\@cerberus \"cd /home/jmichel/git/trb3sc/template/workdir; LM_LICENSE_FILE=27000\@lxcad01.gsi.de /opt/synplicity/K-2015.09/bin/synplify_premier_dp -batch ../trb3sc_basic.prj\" #",
+nodelist_file                => 'nodelist_frankfurt.txt',
+
+
+#Include only necessary lpf files
+#pinout_file                  => '', #name of pin-out file, if not equal TOPNAME
+include_TDC                  => 0,
+include_GBE                  => 0,
+
+#Report settings
+firefox_open                 => 0,
+twr_number_of_errors         => 20,
+no_ltxt2ptxt                 => 1,  #if there is no serdes being used
+make_jed                     => 1,
diff --git a/dbowk/dbo.lpf b/dbowk/dbo.lpf
new file mode 100644 (file)
index 0000000..25446dd
--- /dev/null
@@ -0,0 +1,74 @@
+UGROUP "ffarr0group" 
+  BLKNAME THE_TDC/ffarr[0]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][1]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][2]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][3]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][4]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][5]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][6]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[0][7]
+  ;
+  
+UGROUP "ffarr12group" 
+  BLKNAME THE_TDC/ffarr[1]
+  BLKNAME THE_TDC/ffarr[2]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][1]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][1]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][2]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][2]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][3]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][3]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][4]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][4]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][5]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][5]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][6]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][6]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[1][7]
+  BLKNAME THE_TDC/gen_ffarr_first.0.ffarr[2][7]
+  ;   
+          
+  
+REGION "FFARR0"  "R2C15" 1 4 DEVSIZE;
+REGION "FFARR12" "R2C17" 1 2 DEVSIZE;
+LOCATE UGROUP "ffarr0group"  REGION "FFARR0";
+LOCATE UGROUP "ffarr12group" REGION "FFARR12";
+
+USE PRIMARY NET "THE_TDC/CLKa*";
+USE PRIMARY NET "THE_TDC_CLKa*";
+USE PRIMARY NET "THE_TDC/CLKa[0]";
+USE PRIMARY NET "THE_TDC/CLKa[1]";
+USE PRIMARY NET "THE_TDC/CLKa[2]";
+USE PRIMARY NET "THE_TDC/CLKa[3]";
+USE PRIMARY NET "THE_TDC_CLKa[0]";
+USE PRIMARY NET "THE_TDC_CLKa[1]";
+USE PRIMARY NET "THE_TDC_CLKa[2]";
+USE PRIMARY NET "THE_TDC_CLKa[3]";
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dbowk/dbo.prj b/dbowk/dbo.prj
new file mode 100644 (file)
index 0000000..2c29a5d
--- /dev/null
@@ -0,0 +1,81 @@
+#--  Synopsys, Inc.
+#--  Version J-2015.03L-SP1
+#--  Project file /d/jspc22/trb/git/LogicBox/diamond/LogicBox/run_options.txt
+
+#project files
+
+add_file -vhdl -lib work "/d/jspc29/lattice/diamond/3.6_x64/cae_library/synthesis/vhdl/machxo3lf.vhd"
+
+add_file -vhdl -lib work "../../trbnet/lattice/machxo3/fifo_9x2k_oreg.vhd"
+add_file -vhdl -lib work "../../trbnet/trb_net_std.vhd"
+add_file -vhdl -lib work "../code/uart_sctrl.vhd"
+add_file -vhdl -lib work "../code/sedcheck.vhd"
+add_file -vhdl -lib work "../cores/pll_4x266.vhd"
+add_file -vhdl -lib work "../code/ffarray.vhd"
+add_file -vhdl -lib work "../../trbnet/special/uart_rec.vhd"
+add_file -vhdl -lib work "../../trbnet/special/uart_trans.vhd"
+add_file -vhdl -lib work "testtdc.vhd"
+
+
+
+#implementation: "LogicBox"
+impl -add workdir -type fpga
+
+#
+#implementation attributes
+
+set_option -vlog_std v2001
+set_option -project_relative_includes 1
+
+#par_1 attributes
+set_option -job par_1 -add par
+
+#device options
+set_option -technology MACHXO3LF
+set_option -part LCMXO3LF_2100E
+set_option -package UWG49CTR
+set_option -speed_grade -5
+set_option -part_companion ""
+
+#compilation/mapping options
+set_option -top_module "logicbox"
+
+# mapper_options
+set_option -frequency 1
+set_option -write_verilog 0
+set_option -write_vhdl 0
+set_option -srs_instrumentation 1
+
+# Lattice XP
+set_option -maxfan 1000
+set_option -disable_io_insertion 0
+set_option -retiming 0
+set_option -pipe 1
+set_option -forcegsr false
+set_option -fix_gated_and_generated_clocks 1
+set_option -rw_check_on_ram 1
+set_option -update_models_cp 0
+set_option -syn_edif_array_rename 1
+set_option -Write_declared_clocks_only 1
+
+# sequential_optimization_options
+set_option -symbolic_fsm_compiler 1
+
+# Compiler Options
+set_option -compiler_compatible 0
+set_option -resource_sharing 1
+set_option -multi_file_compilation_unit 1
+
+# Compiler Options
+set_option -auto_infer_blackbox 0
+
+#automatic place and route (vendor) options
+set_option -write_apr_constraint 1
+
+#set result format/file last
+project -result_format "edif"
+project -result_file "workdir/testtdc.edf"
+
+#set log file 
+set_option log_file "workdir/testtdc.srf" 
+impl -active "workdir"
diff --git a/dbowk/dbo.vhd b/dbowk/dbo.vhd
new file mode 100644 (file)
index 0000000..22c73ee
--- /dev/null
@@ -0,0 +1,232 @@
+library ieee;\r
+use ieee.std_logic_1164.all;\r
+use ieee.numeric_std.all;\r
+\r
+library machxo3lf;\r
+use machxo3lf.all;\r
+\r
+library work;\r
+use work.trb_net_std.all;\r
+\r
+entity logicbox is\r
+  port(\r
+    CLK    : in  std_logic;\r
+  \r
+    DEBUG  : out std_logic_vector(3 downto 0);\r
+    LVDS   : in  std_logic_vector(1 downto 0);\r
+       \r
+       LED    : inout std_logic_vector(3 downto 0);\r
+       \r
+       STATUSI  : in  std_logic;\r
+       STATUSO  : in  std_logic;\r
+       CONTROLI : out std_logic;\r
+       CONTROLO : out std_logic;\r
+       \r
+       RX_OUT : out std_logic;\r
+       TX_IN  : in  std_logic;\r
+       CBUS   : in  std_logic\r
+       );\r
+end entity;\r
+\r
+architecture arch of logicbox is\r
+  signal clk_i, clk_osc : std_logic;\r
+  signal clk_p : std_logic_vector(3 downto 0);\r
+  signal led_i : std_logic_vector(3 downto 0);\r
+  signal timer_i : unsigned(31 downto 0) := (others => '0');\r
+  signal config  : std_logic_vector(3 downto 0);\r
+  signal led_highz : std_logic;\r
\r
+  type led_timer_t is array(0 to 3) of unsigned(24 downto 0);\r
+  signal led_timer : led_timer_t;\r
+  signal led_state : std_logic_vector(3 downto 0);\r
\r
+  signal uart_rx_data : std_logic_vector(31 downto 0);\r
+  signal uart_tx_data : std_logic_vector(31 downto 0);\r
+  signal uart_addr    : std_logic_vector(7 downto 0);\r
+  signal bus_read     : std_logic := '0';\r
+  signal bus_write    : std_logic := '0';\r
+  signal bus_ready    : std_logic; \r
+  \r
+  signal input_i         : std_logic_vector(3 downto 0);\r
+  signal input_selected  : std_logic_vector(3 downto 0); \r
+  signal input_stretched, input_hold : std_logic_vector(3 downto 0);\r
+  signal input_reg_0, input_reg_1, input_reg_2 : std_logic_vector(3 downto 0);\r
\r
+  signal edge_rising, edge_falling : std_logic_vector(3 downto 0);\r
+  signal pulser       : std_logic;\r
+  signal reg         : std_logic_vector(31 downto 0);\r
+  signal last_config : std_logic_vector(3 downto 0);\r
\r
+  signal sed_error : std_logic;\r
+  signal sed_debug : std_logic_vector(31 downto 0);\r
+  signal controlsed_i : std_logic_vector(3 downto 0);\r
\r
+  signal f_read, f_empty : std_logic;\r
+  signal f_data          : std_logic_vector(8 downto 0);\r
\r
+  component OSCH\r
+    generic (NOM_FREQ: string := "133.00");\r
+    port (\r
+      STDBY :IN std_logic;\r
+      OSC   :OUT std_logic;\r
+      SEDSTDBY :OUT std_logic\r
+      );\r
+  end component; \r
\r
+begin\r
+\r
+input_selected <= '0' & '0' & LVDS(1) & LVDS(0);\r
+\r
+input_hold  <= input_selected or (input_hold and not input_reg_0);\r
+\r
+input_reg_0 <= input_selected or input_hold when rising_edge(clk_i);\r
+input_reg_1 <= input_reg_0 when rising_edge(clk_i);\r
+input_reg_2 <= input_reg_1 when rising_edge(clk_i);\r
+\r
+\r
+---------------------------------------------------------------------------\r
+-- LED\r
+---------------------------------------------------------------------------\r
+  PROC_LED : process begin\r
+    wait until rising_edge(clk_i);\r
+    if not (config = last_config) and timer_i(27) = '0'  then\r
+      led_i <= config;  \r
+    elsif STATUSI = '0' then\r
+      led_i <= led_state;\r
+    else\r
+      led_i <= led_state(2) & led_state(3) & led_state(0) & led_state(1);\r
+    end if;  \r
+  end process;\r
+\r
+  PROC_LED_STATE : process begin\r
+    wait until rising_edge(clk_i);\r
+    for i in 0 to 2 loop\r
+      if (input_reg_2(i) xor input_reg_1(i)) = '1' and (led_timer(i)(23 downto 21) > 0) then\r
+        led_state(i) <= not led_state(i);\r
+        led_timer(i) <= 0;\r
+      elsif led_timer(i)(23) = '1' then\r
+        led_state(i) <= input_reg_1(i);\r
+      else\r
+        led_timer(i) <= led_timer(i) + 1;\r
+      end if;\r
+    end loop;\r
+  end process;  \r
+  \r
+  \r
+---------------------------------------------------------------------------\r
+-- Clock\r
+---------------------------------------------------------------------------\r
+clk_source: OSCH\r
+  generic map ( NOM_FREQ => "133" )\r
+  port map (\r
+    STDBY    => '0',\r
+    OSC      => clk_osc,\r
+    SEDSTDBY => open\r
+  );\r
+clk_i <= CLK;\r
+\r
+timer_i <= timer_i + 1 when rising_edge(clk_i);\r
+\r
+\r
+\r
+\r
+---------------------------------------------------------------------------\r
+-- Read configuration switch\r
+---------------------------------------------------------------------------\r
+process begin\r
+  wait until rising_edge(clk_i);\r
+  \r
+\r
+  if timer_i(27 downto 10) = 0 then\r
+    led_highz   <= '1';\r
+    last_config <= config;\r
+    if timer_i(9 downto 0) = "11"&x"ff" then\r
+      config <= not LED;\r
+    end if;\r
+  else\r
+    led_highz <= '0';\r
+  end if;\r
+end process;  \r
+\r
+LED <= led_i when led_highz = '0' else "ZZZZ";\r
+-- LED <= sed_debug(3 downto 0);\r
+\r
+---------------------------------------------------------------------------\r
+-- UART\r
+---------------------------------------------------------------------------\r
+THE_UART : entity work.uart_sctrl\r
+  generic map(\r
+    CLOCK_SPEED => 125000000\r
+    )\r
+  port map(\r
+    CLK     => clk_i,\r
+    RESET   => '0',\r
+    UART_RX => TX_IN,\r
+    UART_TX => RX_OUT,\r
+    \r
+    DATA_OUT  => uart_rx_data,\r
+    DATA_IN   => uart_tx_data,\r
+    ADDR_OUT  => uart_addr,       \r
+    WRITE_OUT => bus_write,\r
+    READ_OUT  => bus_read,\r
+    READY_IN  => bus_ready,\r
+    \r
+    DEBUG     => open\r
+    );\r
+\r
+\r
+PROC_REGS : process begin\r
+  wait until rising_edge(clk_i);\r
+  bus_ready <= '0';\r
+  f_read <= '0';\r
+  if bus_read = '1' then\r
+    bus_ready <= '1';\r
+    case uart_addr is\r
+      when x"00" => uart_tx_data <= x"0000000" & config;\r
+      when x"10" => uart_tx_data <= reg;\r
+      when x"80" => \r
+        f_read <= '1';\r
+        uart_tx_data <= "000" & f_empty & x"0000" & "000" & f_data;\r
+      when x"ee" => uart_tx_data <= sed_debug;\r
+    end case;\r
+  elsif bus_write = '1' then\r
+    case uart_addr is\r
+      when x"10" => reg <= uart_rx_data;\r
+         when x"ee" => controlsed_i <= uart_rx_data(3 downto 0);\r
+    end case;\r
+  end if;\r
+end process;\r
+\r
+\r
+THE_SED : entity work.sedcheck\r
+  port map(\r
+    CLK        => clk_i,\r
+    ERROR_OUT  => sed_error,\r
+    \r
+    CONTROL_IN => controlsed_i,\r
+    DEBUG      => sed_debug\r
+    );\r
+\r
+---------------------------------------------------------------------------\r
+-- LVDS\r
+---------------------------------------------------------------------------    \r
+\r
+THE_TDC :  entity work.ffarray\r
+  port map(\r
+    CLK        => clk_i,\r
+    RESET_IN   => '0',\r
+    SIGNAL_IN  => LVDS(0),\r
+    \r
+    DATA_OUT   => f_data,\r
+    READ_IN    => f_read,\r
+    EMPTY_OUT  => f_empty\r
+    );\r
+\r
+\r
+DEBUG <= '0' & '0' & LVDS(1) & LVDS(0);\r
+\r
+\r
+end architecture;\r
+\r
+       \r
+       
\ No newline at end of file
diff --git a/dbowk/par.p2t b/dbowk/par.p2t
new file mode 100644 (file)
index 0000000..39a0684
--- /dev/null
@@ -0,0 +1,21 @@
+-w
+-i 15
+-l 5
+-n 1
+-y
+-s 12
+-t 1
+-c 1
+-e 2
+#-g guidefile.ncd
+#-m nodelist.txt
+# -w
+# -i 6
+# -l 5
+# -n 1
+# -t 1
+# -s 1
+# -c 0
+# -e 0
+#
+-exp parCDP=1:parCDR=1:parPlcInLimit=0:parPlcInNeighborSize=1:parPathBased=ON:parHold=ON:parHoldLimit=10000:paruseNBR=1