protected override void DeclareAlgorithm()
            {
                SignalRef curStateRef = SignalRef.Create(_cpb._stateSignal, SignalRef.EReferencedProperty.Cur);
                LiteralReference lrCurState = new LiteralReference(curStateRef);
                Array stateValues = _cpb._stateSignal.Descriptor.ElementType.CILType.GetEnumValues();

                // Insert neutral pre-sets
                _flowSpec.NeutralFlow.ToProcess().Implement(this);

                // State-dependent MUX
                Switch(lrCurState);
                {
                    for (int cstep = 0; cstep < stateValues.Length; cstep++)
                    {
                        Case(LiteralReference.CreateConstant(stateValues.GetValue(cstep)));
                        {
                            Comment(_flowSpec.GetComment(cstep));
                            _flowSpec.GetFlow(cstep).ToProcess().Implement(this);
                        }
                        EndCase();
                    }
                    DefaultCase();
                    {
                        _flowSpec.NeutralFlow.ToProcess().Implement(this);
                    }
                    EndCase();
                }
                EndSwitch();
            }
                public CommonClockProcess(SignalDescriptor clk)
                {
                    Contract.Requires<ArgumentNullException>(clk != null);

                    Clk = clk;
                    var frame = new DefaultAlgorithmBuilder();

                    var srClk = SignalRef.Create(Clk, SignalRef.EReferencedProperty.RisingEdge);
                    var lrClk = new LiteralReference(srClk);
                    frame.If(lrClk);
                    BodyBuilder = frame.BeginSubAlgorithm();
                    frame.EndIf();
                    FrameBuilder = frame;
                }
 public override Expression TransformLiteralReference(LiteralReference expr)
 {
     var sref = expr.ReferencedObject as SignalRef;
     if (sref != null)
     {
         var iaa = sref.Indices.Select(ia => ia.Select(i => MakeIntegerResult(i.Accept(this))).ToArray());
         sref = new SignalRef(
             sref.Desc,
             sref.Prop,
             iaa,
             sref.IndexSample,
             sref.IsStaticIndex);
         expr = new LiteralReference(sref, expr.Mode);
     }
     return expr;
 }
Beispiel #4
0
 protected override void DeclareAlgorithm()
 {
     SignalRef curState = SignalRef.Create(_taSite._curState, SignalRef.EReferencedProperty.Cur);
     SignalRef incState = SignalRef.Create(_taSite._incState, SignalRef.EReferencedProperty.Next);
     LiteralReference lrCurState = new LiteralReference(curState);
     Array stateValues = _taSite._tState.GetEnumValues();
     Switch(lrCurState);
     {
         for (int i = 0; i < stateValues.Length; i++)
         {
             object curValue = stateValues.GetValue(i);
             object incValue = stateValues.GetValue((i + 1) % stateValues.Length);
             Case(LiteralReference.CreateConstant(curValue));
             {
                 Store(incState, LiteralReference.CreateConstant(incValue));
             }
             EndCase();
         }
     }
     EndSwitch();
 }
Beispiel #5
0
            protected override void DeclareAlgorithm()
            {
                Signal<StdLogic> clkInst = _icb._host.AutoBinder.GetSignal<StdLogic>(EPortUsage.Clock, "Clk", null, '0');
                SignalRef clkRising = SignalRef.Create(clkInst.Descriptor, SignalRef.EReferencedProperty.RisingEdge);
                LiteralReference lrClkRising = new LiteralReference(clkRising);

                If(lrClkRising);
                {
                    for (int i = 0; i < _icb._stageInSignals.Count; i++)
                    {
                        var slotCurInst = _icb._stageOutSignals[i];
                        SignalRef slotCur = SignalRef.Create(slotCurInst, SignalRef.EReferencedProperty.Next);

                        var slotNextInst = _icb._stageInSignals[i];
                        SignalRef slotNext = SignalRef.Create(slotNextInst, SignalRef.EReferencedProperty.Cur);
                        LiteralReference lrSlotNext = new LiteralReference(slotNext);

                        Store(slotCur, lrSlotNext);
                    }
                }
                EndIf();
            }
                protected override void DeclareAlgorithm()
                {
                    var srClk = SignalRef.Create(_taSite._clk, SignalRef.EReferencedProperty.RisingEdge);
                    var lrClk = new LiteralReference(srClk);
                    var srWrEn = _taSite.NeedWriteAccess ? SignalRef.Create(_taSite._wrEn, SignalRef.EReferencedProperty.Cur) : null;
                    var lrWrEn = _taSite.NeedWriteAccess ? new LiteralReference(srWrEn) : null;
                    var srAddr = SignalRef.Create(_taSite._addr, SignalRef.EReferencedProperty.Cur);
                    var lrAddr = new LiteralReference(srAddr);
                    var srDataIn = _taSite.NeedWriteAccess ? SignalRef.Create(_taSite._dataIn, SignalRef.EReferencedProperty.Cur) : null;
                    var lrDataIn = _taSite.NeedWriteAccess ? new LiteralReference(srDataIn) : null;
                    var srDataOut = SignalRef.Create(_taSite._dataOut, SignalRef.EReferencedProperty.Next);
                    var hi = LiteralReference.CreateConstant(StdLogic._1);
                    var addrUType = TypeDescriptor.GetTypeOf(((StdLogicVector)_taSite._addr.InitialValue).UnsignedValue);
                    var uAddr = IntrinsicFunctions.Cast(lrAddr, typeof(StdLogicVector), addrUType);
                    var iAddr = IntrinsicFunctions.Cast(uAddr, addrUType.CILType, typeof(int));
                    var array = _taSite._array;
                    var lrArray = new LiteralReference(array.ArrayLit);
                    var elemType = array.ElementType;
                    var aref = new ArrayRef(lrArray, elemType, iAddr);
                    var convDataIn = _taSite.NeedWriteAccess ? IntrinsicFunctions.Cast(lrDataIn, typeof(StdLogicVector), elemType) : null;
                    var convAref = IntrinsicFunctions.Cast(aref, elemType.CILType, _taSite._dataOut.ElementType);

                    If(lrClk);
                    {
                        Store(srDataOut, convAref);
                        if (_taSite.NeedWriteAccess)
                        {
                            If(Expression.Equal(lrWrEn, hi));
                            {
                                Store(aref, convDataIn);
                            }
                            EndIf();
                        }
                    }
                    EndIf();
                }
            protected override void DeclareAlgorithm()
            {
                BuildFlowMap();

                var grouped = _enablingStatesMap.GroupBy(kvp => kvp.Key.Target);

                SignalRef curStateRef = SignalRef.Create(_cpb._stateSignal, SignalRef.EReferencedProperty.Cur);
                LiteralReference lrCurState = new LiteralReference(curStateRef);
                Array stateValues = _cpb._stateSignal.Descriptor.ElementType.CILType.GetEnumValues();

                foreach (var group in grouped)
                {
                    if (group.Count() > 1)
                    {
                        var target = group.Key;
                        Flow elseFlow;
                        if (!_elseFlows.TryGetValue(target, out elseFlow))
                            continue;
                        foreach (var kvp in group)
                        {
                            var whenFlow = kvp.Key;
                            var states = kvp.Value;
                            var cond = Expression.Equal(lrCurState, LiteralReference.CreateConstant(states[0]));
                            for (int i = 1; i < states.Count; i++)
                                cond = cond | Expression.Equal(lrCurState, LiteralReference.CreateConstant(states[i]));
                            var conditional = Expression.Conditional(
                                cond,
                                whenFlow.GetRHS(),
                                elseFlow.GetRHS());
                            Store(target, conditional);
                        }
                    }
                    else
                    {
                        var onlyFlow = group.Single().Key;
                        if (!_elseFlows.ContainsKey(onlyFlow.Target))
                            continue;
                        Store(onlyFlow.Target, onlyFlow.GetRHS());
                    }
                }
            }
        public override Expression TransformLiteralReference(LiteralReference expr)
        {
            return base.TransformLiteralReference(expr);
            //FIXME: Code below is problematic when ReferencedObject is an array.
            //Array will be replaced by its content which is not the intended behavior.
#if false
            object constValue;
            if (expr.ReferencedObject.IsConst(out constValue))
            {
                return LiteralReference.CreateConstant(constValue);
            }
            else
            {
                return base.TransformLiteralReference(expr);
            }
#endif
        }
        public virtual void AssembleStagedDecoderSync(int[] syms, int selWidth, 
            LiteralReference lrCWSelSlice, IAutoBinder binder, IAlgorithmBuilder pbuilder,
            bool registered)
        {
            if (NumSymbols < 2)
                return;

            CreateSelSymbol(binder, registered);

            pbuilder.Switch(lrCWSelSlice);

            for (int i = 0; i < syms.Length; i++)
            {
                var selValue = StdLogicVector.FromUInt((uint)i, selWidth);
                pbuilder.Case(LiteralReference.CreateConstant(selValue));

                int sym = syms[i];
                var symbol = _selSymbols.GetValue(sym - 1);
                pbuilder.Store(
                    _symbol.SignalInstance.ToSignalRef(SignalRef.EReferencedProperty.Next),
                    LiteralReference.CreateConstant(symbol));

                pbuilder.EndCase();
            }

            pbuilder.DefaultCase();
            {
                pbuilder.Store(
                    _symbol.SignalInstance.ToSignalRef(SignalRef.EReferencedProperty.Next),
                    LiteralReference.CreateConstant(StdLogicVector.Xs(NumSymbols)));
            }
            pbuilder.EndCase();

            if (registered)
            {
                pbuilder.Store(
                    _symbold.SignalInstance.ToSignalRef(SignalRef.EReferencedProperty.Next),
                    _symbol.SignalInstance.ToSignalRef(SignalRef.EReferencedProperty.Cur));
            }

            pbuilder.EndSwitch();
        }
Beispiel #10
0
        public override bool Rewrite(CodeDescriptor decompilee, Expression waitObject, IDecompiler stack, IFunctionBuilder builder)
        {
            if (stack.HasAttribute<Analysis.M2M.HLS>())
            {
                return true;
            }

            var curps = DesignContext.Instance.CurrentProcess;
            SLSignal clk = (SLSignal)curps.Sensitivity[0].Owner;
            SignalRef srEdge;
            if (curps.Predicate.Equals((Func<bool>)clk.RisingEdge))
                srEdge = SignalRef.Create(clk.Descriptor, SignalRef.EReferencedProperty.RisingEdge);
            else
                srEdge = SignalRef.Create(clk.Descriptor, SignalRef.EReferencedProperty.FallingEdge);
            var lrEdge = new LiteralReference(srEdge);

            int nwait = 0;
            var nwaitEx = waitObject.Children[0];
            bool nwaitConst = nwaitEx.IsConst();
            if (nwaitConst)
            {
                nwait = (int)TypeConversions.ConvertValue(
                        nwaitEx.Eval(DefaultEvaluator.DefaultConstEvaluator),
                        typeof(int));
            }

            var fspec = new FunctionSpec(typeof(void))
            {
                IntrinsicRep = IntrinsicFunctions.Wait(WaitParams.EWaitKind.WaitUntil)
            };

            Variable v = null;
            LiteralReference lrV = null;

            if (!nwaitConst || nwait > 3)
            {
                v = new Variable(typeof(int))
                {
                    Name = "_wait_i" + (ictr++)
                };
                builder.DeclareLocal(v);
                lrV = new LiteralReference(v);
                builder.Store(v, LiteralReference.CreateConstant((int)0));
                var loop = builder.Loop();
                builder.If(Expression.Equal(lrV, nwaitEx));
                {
                    builder.Break(loop);
                }
                builder.EndIf();
            }
            int ncalls = 1;
            if (nwaitConst && nwait <= 3)
                ncalls = nwait;
            for (int i = 0; i < ncalls; i++)
            {
                builder.Call(fspec, lrEdge);
            }
            if (!nwaitConst || nwait > 3)
            {
                builder.Store(v, lrV + LiteralReference.CreateConstant((int)1));
                builder.EndLoop();
            }
            return true;
        }
Beispiel #11
0
 protected override void DeclareAlgorithm()
 {
     Signal<StdLogic> clkInst = _binder.GetSignal<StdLogic>(EPortUsage.Clock, "Clk", null, '0');
     SignalRef clkRising = SignalRef.Create(clkInst.Descriptor, SignalRef.EReferencedProperty.RisingEdge);
     LiteralReference lrClkRising = new LiteralReference(clkRising);
     SignalRef altFlagP = SignalRef.Create(_taSite._brAltFlagP, SignalRef.EReferencedProperty.Cur);
     LiteralReference lrAltFlagP = new LiteralReference(altFlagP);
     SignalRef altFlagN = SignalRef.Create(_taSite._brAltFlagN, SignalRef.EReferencedProperty.Cur);
     LiteralReference lrAltFlagN = new LiteralReference(altFlagN);
     SignalRef curState = SignalRef.Create(_taSite._curState, SignalRef.EReferencedProperty.Next);
     SignalRef incState = SignalRef.Create(_taSite._incState, SignalRef.EReferencedProperty.Cur);
     LiteralReference lrIncState = new LiteralReference(incState);
     SignalRef altState = SignalRef.Create(_taSite._altState, SignalRef.EReferencedProperty.Cur);
     LiteralReference lrAltState = new LiteralReference(altState);
     LiteralReference vcc = LiteralReference.CreateConstant((StdLogicVector)"1");
     LiteralReference gnd = LiteralReference.CreateConstant((StdLogicVector)"0");
     If(lrClkRising);
     {
         If(Expression.Equal(lrAltFlagP, vcc) | Expression.Equal(lrAltFlagN, gnd));
         {
             Store(curState, altState);
         }
         Else();
         {
             Store(curState, incState);
         }
         EndIf();
     }
     EndIf();
 }
        public virtual void AssembleStagedDecoderComb(
            ValueFlowCoder vfc,
            LiteralReference lrCWSelSlice,
            IAlgorithmBuilder pbuilder, SLVSignal cwSignal,
            HashSet<ISignalOrPortDescriptor> sensitivity,
            bool registered)
        {
            if (NumSymbols == 0)
            {
                foreach (var target in Targets)
                {
                    pbuilder.Store(target, LiteralReference.CreateConstant(target.Desc.InitialValue));
                }
            }
            else if (NumSymbols == 1)
            {
                var pflow = BwdEnc[0];
                foreach (var flow in pflow.Flows)
                {
                    ImplementFlow(vfc, flow, pbuilder, cwSignal, sensitivity);
                }
            }
            else
            {
                var symbol = registered ? _symbold : _symbol;
                pbuilder.Switch(symbol.SignalInstance.ToSignalRef(SignalRef.EReferencedProperty.Cur));

                for (int i = 0; i < NumSymbols; i++)
                {
                    var selValue = _selSymbols.GetValue(i);
                    var pflow = BwdEnc[i];

                    pbuilder.Case(LiteralReference.CreateConstant(selValue));
                    foreach (var flow in pflow.Flows)
                    {
                        ImplementFlow(vfc, flow, pbuilder, cwSignal, sensitivity);
                    }
                    pbuilder.EndCase();
                }

                var nulls = StdLogicVector._0s(NumSymbols);
                pbuilder.Case(LiteralReference.CreateConstant(nulls));
                {
                    foreach (var target in Targets)
                    {
                        int width = Marshal.SerializeForHW(target.Desc.InitialValue).Size;
                        pbuilder.Store(target, 
                            LiteralReference.CreateConstant(StdLogicVector._0s(width)));
                    }
                }
                pbuilder.EndCase();

                pbuilder.DefaultCase();
                {
                    foreach (var target in Targets)
                    {
                        int width = Marshal.SerializeForHW(target.Desc.InitialValue).Size;
                        pbuilder.Store(target,
                            LiteralReference.CreateConstant(StdLogicVector.Xs(width)));
                    }
                }
                pbuilder.EndCase();

                pbuilder.EndSwitch();
            }
        }
        internal void AssembleDecoder(IAlgorithmBuilder pbuilder, SLVSignal cwSignal, HashSet<ISignalOrPortDescriptor> sensitivity)
        {
            if (_encFlow.NumSymbols == 0)
            {
                foreach (var target in _targets)
                {
                    pbuilder.Store(target, LiteralReference.CreateConstant(target.Desc.InitialValue));
                }
            }
            else if (_encFlow.NumSymbols == 1)
            {
                var pflow = _encFlow.BwdEnc[0];
                foreach (var flow in pflow.Flows)
                {
                    ImplementFlow(flow, pbuilder, cwSignal, sensitivity);
                }
            }
            else
            {
                var lrCWSelSlice = new LiteralReference(
                    ((ISignal)cwSignal[SelOffset + SelWidth - 1, SelOffset])
                        .ToSignalRef(SignalRef.EReferencedProperty.Cur));
                pbuilder.Switch(lrCWSelSlice);

                for (int i = 0; i < _encFlow.NumSymbols; i++)
                {
                    var selValue = StdLogicVector.FromUInt((uint)i, SelWidth);
                    var pflow = _encFlow.BwdEnc[i];

                    if (i + 1 == _encFlow.NumSymbols)
                        pbuilder.DefaultCase();
                    else
                        pbuilder.Case(LiteralReference.CreateConstant(selValue));
                    foreach (var flow in pflow.Flows)
                    {
                        ImplementFlow(flow, pbuilder, cwSignal, sensitivity);
                    }
                    pbuilder.EndCase();                    

                }

                pbuilder.EndSwitch();
            }
        }
Beispiel #14
0
 private string NotateLiteral(ILiteral literal, LiteralReference.EMode mode)
 {
     LiteralStringifier ls = new LiteralStringifier(this, mode);
     literal.Accept(ls);
     return ls.Result;
 }
 /// <summary>
 /// Transforms a literal reference expression. The default implementation hands over to a literal visitor
 /// and constructs a new literal reference based on the last literal, which can be modified using <c>SetCurrentLiteral</c>.
 /// </summary>
 /// <param name="expr">literal reference</param>
 /// <returns>transformation result</returns>
 public virtual Expression TransformLiteralReference(LiteralReference expr)
 {
     var lit = expr.ReferencedObject;
     lit.Accept(this);
     var result = new LiteralReference(_tlit, expr.Mode);
     result.CopyAttributesFrom(expr);
     return result;
 }
                public void AddAccessor(InlineFieldMapperTransactionSite taSite, bool needRead, bool needWrite)
                {
                    var srWrEn = needWrite ? SignalRef.Create(taSite._wrEn, SignalRef.EReferencedProperty.Cur) : null;
                    var lrWrEn = needWrite ? new LiteralReference(srWrEn) : null;
                    var srDataIn = needWrite ? SignalRef.Create(taSite._dataIn, SignalRef.EReferencedProperty.Cur) : null;
                    var lrDataIn = needWrite ? new LiteralReference(srDataIn) : null;
                    var srDataOut = needRead ? SignalRef.Create(taSite._dataOut, SignalRef.EReferencedProperty.Next) : null;
                    var hi = LiteralReference.CreateConstant(StdLogic._1);
                    var elemType = taSite._literal.Type;
                    var lrVar = new LiteralReference((Literal)taSite._literal);
                    var convDataIn = needWrite ? IntrinsicFunctions.Cast(lrDataIn, typeof(StdLogicVector), elemType) : null;
                    var convVar = needRead ? IntrinsicFunctions.Cast(lrVar, elemType.CILType, taSite._dataOut.ElementType) : null;
                    bool isBool = taSite._literal.Type.CILType.Equals(typeof(bool));
                    var lr1 = LiteralReference.CreateConstant((StdLogicVector)"1");
                    var lr0 = LiteralReference.CreateConstant((StdLogicVector)"0");
                    if (needWrite)
                    {
                        BodyBuilder.If(Expression.Equal(lrWrEn, hi));
                        {
                            if (isBool)
                                BodyBuilder.Store(taSite._literal, Expression.Equal(lrDataIn, lr1));
                            else
                                BodyBuilder.Store(taSite._literal, convDataIn);

                            var diagOut = taSite.Host as ISupportsDiagnosticOutput;
                            if (diagOut != null && diagOut.EnableDiagnostics)
                            {
                                Expression vref = new LiteralReference(taSite.Literal);
                                var fref = taSite.Literal as FieldRef;
                                var field = fref != null ? fref.FieldDesc : null;
                                if (field != null && field.HasAttribute<ActualTypeAttribute>())
                                {
                                    var atype = field.QueryAttribute<ActualTypeAttribute>();
                                    vref = IntrinsicFunctions.Cast(vref, vref.ResultType.CILType, atype.ActualType, true);
                                }
                                BodyBuilder.ReportLine(taSite.Literal.Name + " changed to ", vref);
                            }
                        }
                        BodyBuilder.EndIf();
                    }
                    if (needRead)
                    {
                        if (isBool)
                        {
                            BodyBuilder.If(lrVar);
                            {
                                BodyBuilder.If(lrVar);
                                BodyBuilder.Store(srDataOut, lr1);
                            }
                            BodyBuilder.Else();
                            {
                                BodyBuilder.Store(srDataOut, lr0);
                            }
                            BodyBuilder.EndIf();
                        }
                        else
                        {
                            BodyBuilder.Store(srDataOut, convVar);
                        }
                    }
                }
Beispiel #17
0
        // called during AnalyzeNodeVisitor(ConstantWrapper)
        internal virtual List<ConstantWrapper> AddLiteral(ConstantWrapper constantWrapper, ActivationObject refScope)
        {
            List<ConstantWrapper> nodeList = null;

            // numeric constants that are NaN or Infinity need not apply
            if (!constantWrapper.IsSpecialNumeric)
            {
                // if the constant is only one character long, it's never a good idea to
                // try and replace it
                string constantValue = constantWrapper.ToCode();
                if (constantValue.Length > 1)
                {
                    // go up the chain recursively. return the highest shared
                    // constant node list so we can share it if we need to
                    nodeList = ((ActivationObject)Parent).AddLiteral(constantWrapper, this);

                    // if we haven't created our literal map yet, do so now
                    if (m_literalMap == null)
                    {
                        m_literalMap = new Dictionary<string, LiteralReference>();
                    }

                    // now handle our scope
                    LiteralReference literalReference;
                    // see if this constant is in our map
                    if (m_literalMap.ContainsKey(constantValue))
                    {
                        literalReference = m_literalMap[constantValue];
                        // increment the counter
                        literalReference.Increment();
                        // add this constant wrapper to the list
                        if (!literalReference.ConstantWrapperList.Contains(constantWrapper))
                        {
                            literalReference.ConstantWrapperList.Add(constantWrapper);
                        }

                        // if this is the ref scope, or if the ref scope is not the child scope,
                        // set the child scope to null
                        if (literalReference.ChildScope != null
                          && (refScope == this || refScope != literalReference.ChildScope))
                        {
                            literalReference.ChildScope = null;
                        }
                    }
                    else
                    {
                        // add to the table with count = 1 and our given constant wrapper
                        // if this is the ref scope, child scope is null; otherwise use refScope
                        // if nodelist is null, create a new list; otherwise use the shared list
                        literalReference = new LiteralReference(
                          constantWrapper,
                          (refScope != this ? refScope : null),
                          nodeList
                          );
                        m_literalMap.Add(constantValue, literalReference);
                    }

                    // return whatever list it is we used for our node.
                    // it might be shared, or it might be new if we didn't find a shared list
                    nodeList = literalReference.ConstantWrapperList;
                }
            }

            return nodeList;
        }
 private void ImplementFlow(ValueFlowCoder vfc, Flow flow, IAlgorithmBuilder pbuilder, SLVSignal cwSignal, HashSet<ISignalOrPortDescriptor> sensitivity)
 {
     if (FlowMatrix.IsDontCareFlow(flow))
     {
         int valOffset = vfc.GetValueWordOffset(flow.Target);
         int valWidth = vfc.GetValueWordWidth(flow.Target);
         LiteralReference lrCWValSlice;
         if (flow.Target.Desc.ElementType.CILType.Equals(typeof(StdLogic)))
         {
             lrCWValSlice = new LiteralReference(
                 ((ISignal)cwSignal[valOffset])
                     .ToSignalRef(SignalRef.EReferencedProperty.Cur));
         }
         else
         {
             lrCWValSlice = new LiteralReference(
                 ((ISignal)cwSignal[valOffset + valWidth - 1, valOffset])
                     .ToSignalRef(SignalRef.EReferencedProperty.Cur));
         }
         pbuilder.Store(flow.Target, lrCWValSlice);
     }
     else if (flow is SignalFlow)
     {
         var sflow = flow as SignalFlow;
         pbuilder.Store(flow.Target, sflow.Source);
         sensitivity.Add(sflow.Source.Desc);
     }
     else
     {
         var vflow = flow as ValueFlow;
         pbuilder.Store(vflow.Target,
             LiteralReference.CreateConstant(vflow.Value));
     }
 }
 internal void AssembleStagedDecoderComb(IAlgorithmBuilder pbuilder, SLVSignal cwSignal,
     HashSet<ISignalOrPortDescriptor> sensitivity, bool registered)
 {
     LiteralReference lrCWSelSlice = null;
     if (SelWidth != 0)
     {
         lrCWSelSlice = new LiteralReference(
             ((ISignal)cwSignal[SelOffset + SelWidth - 1, SelOffset])
                 .ToSignalRef(SignalRef.EReferencedProperty.Cur));
     }
     _encFlow.AssembleStagedDecoderComb(_vfc, lrCWSelSlice, pbuilder, cwSignal, sensitivity, registered);
 }
 internal void AssembleStagedDecoderSync(IAutoBinder binder, IAlgorithmBuilder pbuilder, SLVSignal cwSignal, bool registered)
 {
     LiteralReference lrCWSelSlice = null;
     if (SelWidth != 0)
     {
         lrCWSelSlice = new LiteralReference(
             ((ISignal)cwSignal[SelOffset + SelWidth - 1, SelOffset])
                 .ToSignalRef(SignalRef.EReferencedProperty.Cur));
     }
     _encFlow.AssembleStagedDecoderSync(Enumerable.Range(1, _encFlow.NumSymbols).ToArray(),
         SelWidth, lrCWSelSlice, binder, pbuilder, registered);
 }
            protected override void DeclareAlgorithm()
            {
                SignalRef curStateRef = SignalRef.Create(_cpb._stateSignal, SignalRef.EReferencedProperty.Cur);
                LiteralReference lrCurState = new LiteralReference(curStateRef);
                Array stateValues = _cpb._stateSignal.Descriptor.ElementType.CILType.GetEnumValues();

                // Insert neutral pre-sets
                var npflow = new ParFlow();
                foreach (var flow in _flowSpec.NeutralFlow.Flows)
                {
                    if (_nonTristateTargets.Contains(flow.Target))
                        npflow.Add(flow);
                }
                npflow.ToProcess().Implement(this);

                // State-dependent MUX
                Switch(lrCurState);
                {
                    for (int cstep = 0; cstep < stateValues.Length; cstep++)
                    {
                        Case(LiteralReference.CreateConstant(stateValues.GetValue(cstep)));
                        {
                            Comment(_flowSpec.GetComment(cstep));
                            var pflow = new ParFlow();
                            foreach (var flow in _flowSpec.GetFlow(cstep).Flows)
                            {
                                if (_nonTristateTargets.Contains(flow.Target))
                                    pflow.Add(flow);
                            }
                            pflow.ToProcess().Implement(this);
                        }
                        EndCase();
                    }
                    DefaultCase();
                    {
                        npflow.ToProcess().Implement(this);
                    }
                    EndCase();
                }
                EndSwitch();
            }
 public override void AssembleStagedDecoderComb(ValueFlowCoder vfc, LiteralReference lrCWSelSlice, 
     IAlgorithmBuilder pbuilder, SLVSignal cwSignal, HashSet<ISignalOrPortDescriptor> sensitivity,
     bool registered)
 {
     _encFlow0.AssembleStagedDecoderComb(vfc, lrCWSelSlice, pbuilder, cwSignal, sensitivity, registered);
     _encFlow1.AssembleStagedDecoderComb(vfc, lrCWSelSlice, pbuilder, cwSignal, sensitivity, registered);
 }
 public override void AssembleStagedDecoderSync(int[] syms, int selWidth, LiteralReference lrCWSelSlice, 
     IAutoBinder binder, IAlgorithmBuilder pbuilder, bool registered)
 {
     int[] syms0 = syms.Select(i => _encMap0[i - 1]).ToArray();
     int[] syms1 = syms.Select(i => _encMap1[i - 1]).ToArray();
     _encFlow0.AssembleStagedDecoderSync(syms0, selWidth, lrCWSelSlice, binder, pbuilder, registered);
     _encFlow1.AssembleStagedDecoderSync(syms1, selWidth, lrCWSelSlice, binder, pbuilder, registered);
 }
Beispiel #24
0
 public LiteralStringifier(VHDLGenerator vhdg, LiteralReference.EMode mode)
 {
     _vhdg = vhdg;
     Mode = mode;
 }
Beispiel #25
0
 public LiteralStringifier(SystemCGenerator SysCg, LiteralReference.EMode mode)
 {
     _SysCg = SysCg;
     Mode = mode;
 }