001/* Decode convolutional code with non-antipodal constellation. 002 003 Copyright (c) 2003-2008 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028package ptolemy.actor.lib.comm; 029 030import ptolemy.data.type.ArrayType; 031import ptolemy.data.type.BaseType; 032import ptolemy.kernel.CompositeEntity; 033import ptolemy.kernel.util.IllegalActionException; 034import ptolemy.kernel.util.NameDuplicationException; 035import ptolemy.kernel.util.Settable; 036 037////////////////////////////////////////////////////////////////////////// 038//// TrellisDecoder 039 040/** 041 The TrellisDecoder is a generalization of the ViterbiDecoder. It 042 can handle trellis coding, which has non-antipodal constellation. 043 For a <i>k</i>/<i>n</i> convolutional code, the constellation 044 should map each codeword into a complex number. Hence the length 045 of the constellation should be a complex array of length 046 2<i><sup>n</sup></i>. For example, a 1/2 rate convolutional code 047 should use 4PSK. a <i>k</i>/3 convolutional code should use 8PSK. 048 <p> 049 The input port of the TrellisDecoder is complex. On each firing, 050 the TrellisDecoder reads one input. The Euclidean distance is defined 051 as the distance between the noisy input and the point in the 052 constellation mapped from the codeword. Like in ViterbiDecoder, 053 this actor produces <i>k</i> outputs on each firing. 054 <p> 055 See ConvolutionalCoder and ViterbiDecoder for details about 056 the meaning of these parameters. 057 <p> 058 For more information on convolutional codes, Viterbi decoder, and 059 trellis coding, see the ConvolutionalCoder actor, ViterbiDecoder 060 actor and Proakis, <i>Digital Communications</i>, Fourth Edition, 061 McGraw-Hill, 2001, pp. 471-477 and pp. 482-485, 062 or Barry, Lee and Messerschmitt, <i>Digital Communication</i>, Third Edition, 063 Kluwer, 2004. 064 <p> 065 @author Ye Zhou, contributor: Edward A. Lee 066 @version $Id$ 067 @since Ptolemy II 4.0 068 @Pt.ProposedRating Yellow (eal) 069 @Pt.AcceptedRating Red (cxh) 070 */ 071public class TrellisDecoder extends ViterbiDecoder { 072 /** Construct an actor with the given container and name. 073 * The output and trigger ports are also constructed. 074 * @param container The container. 075 * @param name The name of this actor. 076 * @exception IllegalActionException If the entity cannot be contained 077 * by the proposed container. 078 * @exception NameDuplicationException If the container already has an 079 * actor with this name. 080 */ 081 public TrellisDecoder(CompositeEntity container, String name) 082 throws NameDuplicationException, IllegalActionException { 083 super(container, name); 084 085 softDecoding.setVisibility(Settable.NONE); 086 softDecoding.setExpression("false"); 087 088 trellisDecoding.setExpression("true"); 089 090 constellation.setTypeEquals(new ArrayType(BaseType.COMPLEX)); 091 constellation.setExpression("{1.0, i, -1.0, -i}"); 092 } 093}