Пример #1
0
        private void CreateStateValues()
        {
            string cname  = _code.Name;
            string ename  = "E_" + cname + "_State";
            Type   tState = CreateEnum(ename, _stateLookup.Count);

            _stateType = tState;
            TypeDescriptor tdState = (TypeDescriptor)tState;
            // do not add type - it will be assigned during post-processing
            //_code.Owner.AddChild(tdState, ename);
            Array enumValues = tState.GetEnumValues();

            foreach (StateInfo si in _stateLookup.Values)
            {
                int i = si.StateIndex;
                si.StateValue            = enumValues.GetValue(i);
                si.StateExpr.PlaceHolder = LiteralReference.CreateConstant(si.StateValue);
            }
            ComponentDescriptor owner = (ComponentDescriptor)_code.Owner;
            string fname   = "m_" + cname + "_State";
            var    initVal = Activator.CreateInstance(tState);
            ISignalOrPortDescriptor sdState = owner.CreateSignalInstance(fname, initVal);
            Type tStateSignal = typeof(Signal <>).MakeGenericType(tState);

            _tComponent = _modBuilder.DefineType(owner.Instance.GetType().FullName, TypeAttributes.Public);
            FieldBuilder fbStateSignal = _tComponent.DefineField(fname, tStateSignal, FieldAttributes.Private);

            _stateSignal = new SignalRef(sdState, SignalRef.EReferencedProperty.Instance);
            _nextStateSignal.PlaceHolder = new SignalRef(sdState, SignalRef.EReferencedProperty.Next);
        }
Пример #2
0
            public override void Establish(IAutoBinder binder)
            {
                if (_allocated)
                {
                    return;
                }

                _brAltFlagP = (SLVSignal)binder.GetSignal(EPortUsage.Default, "BCU_BrP", null, StdLogicVector._0s(1));
                _brAltFlagN = (SLVSignal)binder.GetSignal(EPortUsage.Default, "BCU_BrN", null, StdLogicVector._1s(1));

                _curState = binder.GetSignal(EPortUsage.State, "BCU_CurState", null, null).Descriptor;
                _tState   = _curState.ElementType.CILType;
                Array  enumValues   = _tState.GetEnumValues();
                int    numStates    = enumValues.Length;
                object defaultState = Activator.CreateInstance(_tState);

                _incState  = binder.GetSignal(EPortUsage.Default, "BCU_IncState", null, defaultState).Descriptor;
                _altState  = binder.GetSignal(EPortUsage.Default, "BCU_AltState", null, defaultState).Descriptor;
                _nextState = binder.GetSignal(EPortUsage.Default, "BCU_NextState", null, defaultState).Descriptor;
                IncStateProcessBuilder ispb = new IncStateProcessBuilder(this);
                Function incStateFn         = ispb.GetAlgorithm();

                incStateFn.Name = "BCU_IncState";
                binder.CreateProcess(Process.EProcessKind.Triggered, incStateFn, _curState);
                SyncProcessBuilder spb         = new SyncProcessBuilder(this, binder);
                Function           syncStateFn = spb.GetAlgorithm();

                syncStateFn.Name = "BCU_FSM";
                ISignalOrPortDescriptor sdClock = binder.GetSignal <StdLogic>(EPortUsage.Clock, "Clk", null, '0').Descriptor;

                binder.CreateProcess(Process.EProcessKind.Triggered, syncStateFn, sdClock);

                _allocated = true;
            }
Пример #3
0
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="host">hosting component</param>
 /// <param name="port">port being accessed</param>
 public InlinePortWriteSite(Component host, ISignalOrPortDescriptor port) :
     base(host)
 {
     _host      = host;
     _port      = port;
     _dataWidth = Marshal.SerializeForHW(port.InitialValue).Size;
 }
Пример #4
0
            public void Implement(IAlgorithmBuilder builder)
            {
                IDescriptive            idesc = (IDescriptive)DrivenSignal;
                ISignalOrPortDescriptor desc  = (ISignalOrPortDescriptor)idesc.Descriptor;

                builder.Store(DrivenSignal.ToSignalRef(SignalRef.EReferencedProperty.Next),
                              Source.GetExpression());
            }
Пример #5
0
        /// <summary>
        /// Constructs a signal reference literal.
        /// </summary>
        /// <param name="desc">referenced descriptor</param>
        /// <param name="prop">referenced signal property</param>
        public SignalRef(ISignalOrPortDescriptor desc, EReferencedProperty prop)
        {
            Contract.Requires(desc != null);

            Desc          = desc;
            Prop          = prop;
            Indices       = new List <Expression[]>();
            IndexSample   = new IndexSpec();
            IsStaticIndex = true;
        }
Пример #6
0
        /// <summary>
        /// Constructs a new instance.
        /// </summary>
        /// <param name="host">hosting component</param>
        /// <param name="port">port descriptor</param>
        public DirectPortReadTransactionSite(Component host, ISignalOrPortDescriptor port)
        {
            _host = host;
            _port = port;

            _portSignal = port as SignalDescriptor;
            if (_portSignal == null)
            {
                _portSignal = (SignalDescriptor)((IPortDescriptor)port).BoundSignal;
            }
        }
Пример #7
0
        /// <summary>
        /// Constructs a signal reference literal.
        /// </summary>
        /// <param name="desc">referenced descriptor</param>
        /// <param name="prop">referenced signal property</param>
        /// <param name="indices">indices to apply</param>
        /// <param name="indexSample">sample index</param>
        /// <param name="isStaticIndex">whether the indices are static (i.e.) constant, in which case the sample index can be taken
        /// for granted</param>
        public SignalRef(ISignalOrPortDescriptor desc, EReferencedProperty prop,
                         IEnumerable <Expression[]> indices, IndexSpec indexSample, bool isStaticIndex)
        {
            Contract.Requires(desc != null);
            Contract.Requires(indices != null);
            Contract.Requires(indexSample != null);
            Contract.Requires(indices.Count() == indexSample.Indices.Length);

            Desc          = desc;
            Prop          = prop;
            Indices       = indices.ToList();
            IndexSample   = indexSample;
            IsStaticIndex = isStaticIndex;
        }
Пример #8
0
 /// <summary>
 /// Creates a new signal reference literal.
 /// </summary>
 /// <param name="desc">referenced descriptor</param>
 /// <param name="prop">referenced property</param>
 public static SignalRef Create(ISignalOrPortDescriptor desc, EReferencedProperty prop)
 {
     Contract.Requires(desc != null);
     return new SignalRef(desc, prop);
 }
Пример #9
0
        /// <summary>
        /// Constructs a signal reference literal.
        /// </summary>
        /// <param name="desc">referenced descriptor</param>
        /// <param name="prop">referenced signal property</param>
        /// <param name="indices">indices to apply</param>
        /// <param name="indexSample">sample index</param>
        /// <param name="isStaticIndex">whether the indices are static (i.e.) constant, in which case the sample index can be taken
        /// for granted</param>
        public SignalRef(ISignalOrPortDescriptor desc, EReferencedProperty prop, 
            IEnumerable<Expression[]> indices, IndexSpec indexSample, bool isStaticIndex)
        {
            Contract.Requires(desc != null);
            Contract.Requires(indices != null);
            Contract.Requires(indexSample != null);
            Contract.Requires(indices.Count() == indexSample.Indices.Length);

            Desc = desc;
            Prop = prop;
            Indices = indices.ToList();
            IndexSample = indexSample;
            IsStaticIndex = isStaticIndex;
        }
Пример #10
0
        /// <summary>
        /// Constructs a signal reference literal.
        /// </summary>
        /// <param name="desc">referenced descriptor</param>
        /// <param name="prop">referenced signal property</param>
        public SignalRef(ISignalOrPortDescriptor desc, EReferencedProperty prop)
        {
            Contract.Requires(desc != null);

            Desc = desc;
            Prop = prop;
            Indices = new List<Expression[]>();
            IndexSample = new IndexSpec();
            IsStaticIndex = true;
        }
Пример #11
0
 /// <summary>
 /// Creates an instruction which stores its operand to a port
 /// </summary>
 public XILInstr WritePort(ISignalOrPortDescriptor sd)
 {
     return(new XILInstr(InstructionCodes.WrPort, sd));
 }
Пример #12
0
 /// <summary>
 /// Creates an instruction which reads from a port
 /// </summary>
 public XILInstr ReadPort(ISignalOrPortDescriptor sd)
 {
     return(new XILInstr(InstructionCodes.RdPort, sd));
 }
Пример #13
0
 /// <summary>
 /// Creates a new signal reference literal.
 /// </summary>
 /// <param name="desc">referenced descriptor</param>
 /// <param name="prop">referenced property</param>
 public static SignalRef Create(ISignalOrPortDescriptor desc, EReferencedProperty prop)
 {
     Contract.Requires(desc != null);
     return(new SignalRef(desc, prop));
 }