Exemplo n.º 1
0
        /// <summary>
        /// Input connections to device
        /// </summary>
        /// <param name="cycle">Zero-based program cycle number</param>
        /// <returns></returns>
        private static List <Connection> Connections(int cycle)
        {
            var conns = new List <Connection>();

            var instr = ActiveInstr(cycle - PIPELINE_DELAY);

            PortStatus mux2APortOut_Stat;
            PortStatus mux2BPortOut_Stat;
            PortStatus shifterPortOut_Stat;

            PortStatus macMux2APortIn_Stat;
            PortStatus macMux2BPortIn_Stat;
            PortStatus macShifterPortIn_Stat;

            InputsUsed(cycle,
                       out mux2APortOut_Stat,
                       out mux2BPortOut_Stat,
                       out shifterPortOut_Stat,
                       out macMux2APortIn_Stat,
                       out macMux2BPortIn_Stat,
                       out macShifterPortIn_Stat);

            var activeLabel_Mux_2A  = Mux2Model.OutputCalc(Bank.Bank_A, cycle).FormattedValue;
            var activeLabel_Mux_2B  = Mux2Model.OutputCalc(Bank.Bank_B, cycle).FormattedValue;
            var activeLabel_Shifter = ShifterModel.OutputCalc(cycle).FormattedValue;

            // Show inputs based on connection:
            conns.Add(new Connection(
                          BusType.Data,
                          DevicePort.Mux_2A,
                          mux2APortOut_Stat,
                          activeLabel_Mux_2A,
                          null,
                          DevicePort.MAC,
                          macMux2APortIn_Stat));

            conns.Add(new Connection(
                          BusType.Data,
                          DevicePort.Mux_2B,
                          mux2BPortOut_Stat,
                          activeLabel_Mux_2B,
                          null,
                          DevicePort.MAC,
                          macMux2BPortIn_Stat));

            conns.Add(new Connection(
                          BusType.Data,
                          DevicePort.Shifter,
                          shifterPortOut_Stat,
                          activeLabel_Shifter,
                          null,
                          DevicePort.MAC,
                          macShifterPortIn_Stat));

            return(conns);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new instance of this device for the given cycle
        /// </summary>
        /// <param name="bankID">BankID of the device</param>
        /// <param name="cycle">Zero-based program cycle number</param>
        public Mux3Model(Bank bankID, int cycle) : base(bankID, cycle, VALUE_WIDTH, 0, PIPELINE_DELAY)
        {
            // name
            name = bankID == Bank.Bank_A
                                ? DevicePort.Mux_3A.ToString()
                                : DevicePort.Mux_3B.ToString();

            // instructions
            instructions.Add(InstrForCycle(bankID, cycle));
            instructions.Add(InstrForCycle(bankID, cycle - 1));

            // connectionInputs
            connectionInputs = Connections(bankID, cycle);

            // output
            output = OutputCalc(bankID, cycle);

            // pipelineItems
            pipelineItems = new List <PipelineItem>();
            for (int i = 0; i < instructions.Count; i++)
            {
                var        instr       = instructions[i];
                DevicePort activeInput = DevicePort.Default;
                long?      activeValue = null;

                if (i == 1)
                {
                    switch (instr)
                    {
                    case "ba":                              // Bus to ALU
                    case "sa":                              // Shifter to ALU
                    case "bra":                             // Bus to RAM, RAM to ALU
                    case "sra":                             // Shifter to RAM, RAM to ALU
                        activeInput = bankID == Bank.Bank_A
                                                                ? DevicePort.Mux_2A
                                                                : DevicePort.Mux_2B;
                        activeValue = Mux2Model.OutputCalc(bankID, cycle).Value;
                        break;

                    case "brm":                             // Bus to RAM, to MAC
                    case "srm":                             // Shifter to RAM to MAC
                        activeInput = DevicePort.MAC;
                        activeValue = MACModel.OutputCalc(cycle).Value;
                        break;

                    default:
                        break;
                    }
                }

                var pipelineItem = new PipelineItem();

                var lvValue = new LabeledValue <long?>("In:");
                lvValue.Value          = activeValue.HasValue ? activeValue.Value : (long?)null;
                lvValue.FormattedValue = FormatValue(VALUE_WIDTH, lvValue.Value);
                pipelineItem.Input     = lvValue;

                var lvValueSrc = new LabeledValue <DevicePort?>("Src:");
                lvValueSrc.Value          = activeInput == DevicePort.Default ? (DevicePort?)null : activeInput;
                lvValueSrc.FormattedValue = lvValueSrc.Value.ToString();
                pipelineItem.InputSource  = lvValueSrc;

                PipelineItems.Add(pipelineItem);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Input connections to device
        /// </summary>
        /// <param name="bankID">BankID of the device</param>
        /// <param name="cycle">Zero-based program cycle number</param>
        /// <returns></returns>
        private static List <Connection> Connections(Bank bankID, int cycle)
        {
            var conns = new List <Connection>();

            DevicePort mux2PortOut      = DevicePort.Default;
            DevicePort macPortOut       = DevicePort.Default;
            DevicePort mux3Mux2PortIn   = DevicePort.Default;
            DevicePort mux2MacRamPortIn = DevicePort.Default;

            PortStatus mux2PortOut_Stat;
            PortStatus macPortOut_Stat;
            PortStatus mux3Mux2PortIn_Stat;
            PortStatus mux2MacRamPortIn_Stat;

            InputsUsed(bankID, cycle,
                       out mux2PortOut_Stat,
                       out macPortOut_Stat,
                       out mux3Mux2PortIn_Stat,
                       out mux2MacRamPortIn_Stat);

            var mux2_label = Mux2Model.OutputCalc(bankID, cycle).FormattedValue;
            var mac_label  = MACModel.OutputCalc(cycle).FormattedValue;

            switch (bankID)
            {
            case Bank.Bank_A:
                mux2PortOut      = DevicePort.Mux_2A;
                macPortOut       = DevicePort.MAC;
                mux3Mux2PortIn   = DevicePort.Mux_3A;
                mux2MacRamPortIn = DevicePort.Mux_3A;
                break;

            case Bank.Bank_B:
                mux2PortOut      = DevicePort.Mux_2B;
                macPortOut       = DevicePort.MAC;
                mux3Mux2PortIn   = DevicePort.Mux_3B;
                mux2MacRamPortIn = DevicePort.Mux_3B;
                break;

            default:
                break;
            }

            conns.Add(new Connection(
                          BusType.Data,
                          mux2PortOut,
                          mux2PortOut_Stat,
                          mux2_label,
                          null,
                          mux3Mux2PortIn,
                          mux3Mux2PortIn_Stat));

            conns.Add(new Connection(
                          BusType.Data,
                          macPortOut,
                          macPortOut_Stat,
                          mac_label,
                          null,
                          mux2MacRamPortIn,
                          mux2MacRamPortIn_Stat));

            return(conns);
        }