Beispiel #1
0
        public Mux(List <FIRIO> choises, Output decider, FirrtlNode defNode, bool isVectorIndexer = false) : base(defNode)
        {
            choises = choises.Select(x => x.GetOutput()).ToList();
            if (!choises.All(x => x.IsPassiveOfType <Output>()))
            {
                throw new Exception("Inputs to mux must all be passive output types.");
            }

            this.Choises         = choises.Select(x => x.Flip(this)).ToArray();
            this.Decider         = new Input(this, decider.Type);
            this.Result          = choises.First().Copy(this);
            this.IsVectorIndexer = isVectorIndexer;
            foreach (var res in Result.Flatten())
            {
                res.RemoveType();
            }

            for (int i = 0; i < Choises.Length; i++)
            {
                choises[i].ConnectToInput(Choises[i]);
            }
            decider.ConnectToInput(Decider);

            AddOneToManyPairedIO(Result, Choises.ToList());

            this.ChoiseInputs  = Choises.SelectMany(x => x.Flatten().Cast <Input>()).ToArray();
            this.ResultOutputs = Result.Flatten().Cast <Output>().ToArray();
        }
        public VectorAssign(Vector input, Output index, Output condition, FirrtlNode defNode) : base(defNode)
        {
            if (!input.IsPassiveOfType <Input>())
            {
                throw new Exception("Vector assign input must be a passive input type.");
            }

            this.VecIn  = (Vector)input.Copy(this);
            this.Index  = (Input)index.Flip(this);
            this.Value  = VecIn.GetIndex(0).Copy(this);
            this.VecOut = (Vector)input.Flip(this);

            this.VecInputs   = VecIn.Flatten().Cast <Input>().ToArray();
            this.VecOutputs  = VecOut.Flatten().Cast <Output>().ToArray();
            this.ValueInputs = Value.Flatten().Cast <Input>().ToArray();

            Input[] inputs = input.Flatten().Cast <Input>().ToArray();
            for (int i = 0; i < inputs.Length; i++)
            {
                inputs[i].TransferConnectionsTo(VecInputs[i]);
                VecOutputs[i].ConnectToInput(inputs[i], false, false, condition);
            }

            index.ConnectToInput(Index);

            Index.SetName("Index");
            Value.SetName("Value");
        }
Beispiel #3
0
        private void AddIO(FIRIO externalIO, FIRIO internalIO)
        {
            Debug.Assert(externalIO.Flatten().All(x => x.Node == this));
            Debug.Assert(internalIO.Flatten().All(x => x.Node == this));

            ExternalIO.Add(externalIO.Name, externalIO);
            InternalIO.Add(internalIO.Name, internalIO);
            AllIOInOrder.Add(internalIO);

            AddPairedIO(externalIO, internalIO);
        }
Beispiel #4
0
 internal void BypassWireIO()
 {
     IOHelper.BypassWire(GetInputs(), GetOutputs());
     Debug.Assert(In.Flatten().All(x => !x.IsConnectedToAnything()));
     Debug.Assert(Result.Flatten().All(x => !x.IsConnectedToAnything()));
 }