Example #1
0
        private void Exec(TicTok tictok)
        {
            var cw = SEQ.Instance().ControlWord;

            if (string.Equals(cw["CALL"], "1", StringComparison.Ordinal))
            {
                // PC return address being set
                if (string.Equals(cw["RTNA"], "0", StringComparison.Ordinal))
                {
                    RegContent = Convert.ToString(0xFFFE - 0x0800 - 1, 2);
                    ram.SetMARContent(RegContent);
                }
                else
                {
                    RegContent = Convert.ToString(0xFFFF - 0x0800 - 1, 2);
                    ram.SetMARContent(RegContent);
                }
            }

            // Active Low, Pull on Tok
            if (string.Equals(cw["LM_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tok)
            {
                // Store Wbus val in MAR
                RegContent = Wbus.Instance().Value;

                // Send the MAR data to the RAM
                ram.IncomingMARData(RegContent);
            }
        }
Example #2
0
            public override Stm ProcessEntryExit1(Stm body)
            {
                Temp.Temp newTemp;
                for (int i = 0; i < 8; ++i)
                {
                    newTemp = new Temp.Temp();
                    body    = new SEQ(new MOVE(new TEMP(newTemp), new TEMP(Reg[16 + i])), body);
                    body    = new SEQ(body, new MOVE(new TEMP(Reg[16 + i]), new TEMP(newTemp)));
                }
                newTemp = new Temp.Temp();
                body    = new SEQ(new MOVE(new TEMP(newTemp), new TEMP(Reg[31])), body);
                body    = new SEQ(body, new MOVE(new TEMP(Reg[31]), new TEMP(newTemp)));

                int count = 0;

                for (AccessList ptr = Formals; ptr != null; ptr = ptr.Tail)
                {
                    if (ptr.Head is InReg)
                    {
                        body = new SEQ(new MOVE(ptr.Head.Exp(null), new TEMP(A(count))), body);
                        ++count;
                    }
                }
                for (; count < 4; count++)
                {
                    body = new SEQ(new MOVE(new TEMP(new Temp.Temp()), new TEMP(A(count))), body);
                }
                return(body);
            }
Example #3
0
        private void Exec(TicTok tictok)
        {
            var cw = SEQ.Instance().ControlWord;

            // Both tied to the same signal from ram so when ram is emitting then MDR is changed as well
            if (string.Equals(cw["EM_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tic)
            {
                RegContent = ram.RegContent;
            }

            // LM_ is tied to MAR -> RAM so i did LR_ for MDR -> RAM
            if (string.Equals(cw["LR_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tic)
            {
                ram.SetWordAtMARAddress(RegContent);
            }

            // Active High, Push on Tic
            if (string.Equals(cw["EMDR"], "1", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tic)
            {
                //Wbus.Instance().Value = RegContent;
                Multiplexer.Instance().PassThroughToBus(RegContent, Convert.ToBoolean(Convert.ToInt16(cw["UB"])), Convert.ToBoolean(Convert.ToInt16(cw["CLR"])));
            }

            // Active Low, Pull on Tok
            if (string.Equals(cw["LMDR_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tok)
            {
                //RegContent = Wbus.Instance().Value;
                RegContent = Multiplexer.Instance().PassThroughToRegister(Convert.ToBoolean(Convert.ToInt16(cw["UB"])));
            }
        }
Example #4
0
        public void TestToString()
        {
            Clock  clock  = new Clock();
            TicTok tictok = new TicTok();

            tictok.Init();;
            int  TState = 0;
            AReg areg   = new AReg();
            BReg breg   = new BReg();
            IReg ireg   = new IReg();
            OReg oreg   = new OReg();
            RAM  ram    = new RAM();

            PC   pc   = new PC(ref areg);
            ALU  alu  = new ALU(ref areg, ref breg);
            MReg mreg = new MReg(ref ram);
            SEQ  seq  = SEQ.Instance();

            Wbus.Instance().Value = "00000000";
            Flags.Instance().Clear();

            Frame frame = new Frame(ireg.ToString(), TState, areg, breg, ireg, mreg, oreg, pc, alu, ram.RAMDump(), ram, seq, Wbus.Instance().ToString(), Flags.Instance(), _decoder);

            _ = frame.ToString();
            _ = frame.OutputRegister();
        }
Example #5
0
        //---------------------------------------------------------------------------
        private void UserButton_Click_6(object sender, RoutedEventArgs e)
        {
            if (!m_bConnect || m_nAxis < 0)
            {
                return;
            }

            //mc_Acs.fn_SetBuffer(m_nAxis, true); //HOME

            int nHomeNo = MOTR.ManNoHome((EN_MOTR_ID)m_nAxis);

            if (!fn_UserMsg($"{STRING_MOTOR_ID[m_nAxis]} Motor Home?", EN_MSG_TYPE.Check))
            {
                return;
            }

            SEQ.fn_Reset();

            if (nHomeNo == 32) //Z-Axis
            {
                if (SEQ_SPIND.fn_IsExistTool() && !FM.fn_IsLvlMaster())
                {
                    fn_UserMsg("Please remove tool");
                    return;
                }
            }
            MAN.fn_ManProcOn(nHomeNo, true, false);
        }
Example #6
0
        public void Exec(TicTok tictok)
        {
            var cw = SEQ.Instance().ControlWord;

            // Active Hi, Count on Tic
            if (string.Equals(cw["CP"], "1", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tic)
            {
                int count = BinConverter.Bin8ToInt(RegContent);
                count++;
                RegContent = BinConverter.IntToBin16(count);
            }

            // Active Hi, Push on Tic
            if (string.Equals(cw["EP"], "1", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tic)
            {
                // Send PC to the WBus
                Wbus.Instance().Value = RegContent;
            }

            // Active Low - Broadside Load, Pull
            if (string.Equals(cw["LP_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tok)
            {
                RegContent = Wbus.Instance().Value;
            }
        }
Example #7
0
        //---------------------------------------------------------------------------
        private void btDoor_M_Click(object sender, RoutedEventArgs e)
        {
            //Door Open Button Click
            UserButton selBtn = sender as UserButton;

            switch (selBtn.Name)
            {
            case "btDoor_O":     //Main Door Open

                if (SEQ._bAuto)
                {
                    return;                 //JUNG/200814
                }
                SEQ.fn_SetDoorLock(ccOpen);
                SEQ.fn_SetDoorLock_Side(ccOpen);
                break;

            case "btDoor_C":     //Main Door Close
                SEQ.fn_SetDoorLock(ccClose);
                SEQ.fn_SetDoorLock_Side(ccClose);
                break;

            case "btSDoor_O":     //Side door open
                SEQ.fn_SetDoorLock_Side(ccOpen);
                break;

            case "btSDoor_C":     //Side Door Close
                SEQ.fn_SetDoorLock_Side(ccClose);
                break;

            default:
                break;
            }
        }
Example #8
0
        //---------------------------------------------------------------------------
        private void btReset_Click(object sender, RoutedEventArgs e)
        {
            //Reset Click
            UserFunction.fn_WriteLog("ALARM - Reset Click");

            SEQ.fn_Reset();
            this.Hide();
        }
Example #9
0
        private void Exec(TicTok tictok)
        {
            var cw = SEQ.Instance().ControlWord;

            string aluResult = alu.RegContent;

            // Active Low, Pull on Tok
            if (aluResult[^ 1].Equals('1') && string.Equals(cw["LO_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tok)
Example #10
0
 private void Menu_Import_SEQ()
 {
     byte[] data = FileUtil.OpenFile(FileFilters.SEQ, FileFilters.Any);
     if (data != null)
     {
         SEQ seq = SEQ.Load(data);
         oldmusicentry.SEP.SEQs.Add(seq);
         AddNode(new OldSEQController(this, seq));
     }
 }
Example #11
0
        public void TestToString()
        {
            Clock  clock  = new Clock();
            TicTok tictok = new TicTok();

            tictok.Init();

            int  TState = 0;
            AReg areg   = new AReg();
            TReg treg   = new TReg();
            BReg breg   = new BReg();
            CReg creg   = new CReg();
            IReg ireg   = new IReg();

            IPort1 port1 = new IPort1();
            IPort2 port2 = new IPort2();

            MDR mdr = new MDR();
            RAM ram = new RAM();

            mdr.SetRefToRAM(ref ram);

            ALU alu = new ALU(ref areg, ref treg);

            OReg3 oreg3 = new OReg3(ref alu);
            OReg4 oreg4 = new OReg4(ref alu);

            HexadecimalDisplay hexadecimalDisplay = new HexadecimalDisplay(ref oreg3);


            Flag flagReg = new Flag(ref alu);
            PC   pc      = new PC(ref flagReg);
            MAR  mar     = new MAR(ref ram);
            SEQ  seq     = SEQ.Instance();

            Wbus.Instance().Value = string.Concat(Enumerable.Repeat('0', 16));

            Instruction currentInstruction = new Instruction
            {
                OpCode         = "ADD B",
                BinCode        = "10000000",
                TStates        = 4,
                AffectsFlags   = true,
                AddressingMode = AddressingMode.Register,
                Bytes          = 1
            };

            Frame frame = new Frame(currentInstruction, TState, port1, port2, pc, mar, ram,
                                    ram.RAMDump(), mdr, ireg, SEQ.Instance(),
                                    Wbus.Instance().Value, areg, alu, flagReg,
                                    treg, breg, creg, oreg3, oreg4, hexadecimalDisplay);

            _ = frame.ToString();
            _ = frame.OutputRegister();
        }
Example #12
0
        /// <summary>
        /// Gets the correct BaseFile class by comparing the file with the known header signatures.
        /// </summary>
        /// <param name="filePath">Filepath</param>
        /// <returns></returns>
        public static BaseFile GetTypeFromFile(string filePath)
        {
            byte[] buffer;
            using (BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open)))
            {
                if (reader.BaseStream.Length < 256)
                {
                    buffer = new byte[reader.BaseStream.Length];
                    reader.Read(buffer, 0, buffer.Length);
                }
                else
                {
                    buffer = new byte[256];
                    reader.Read(buffer, 0, 256);
                }
            }

            if (BG.Compare(buffer))
            {
                return(new BGFile(filePath));
            }
            if (LZB.Compare(buffer))
            {
                return(new LZBFile(filePath));
            }
            if (PACK.Compare(buffer))
            {
                return(new PBFile(filePath));
            }
            if (SEQ.Compare(buffer))
            {
                return(new SEQFile(filePath));
            }
            if (STR.Compare(filePath))
            {
                return(new STRFile(filePath));
            }
            if (TIM.Compare(buffer))
            {
                return(new TIMFile(filePath));
            }
            if (VB.Compare(buffer))
            {
                return(new VBFile(filePath));
            }
            if (VH.Compare(buffer))
            {
                return(new VHFile(filePath));
            }
            if (XA.Compare(filePath))
            {
                return(new XAFile(filePath));
            }
            return(new BaseFile(filePath));
        }
Example #13
0
        private void Menu_Replace_SEQ()
        {
            int i = oldmusicentrycontroller.OldMusicEntry.SEP.SEQs.IndexOf(seq);

            byte[] data = FileUtil.OpenFile(FileFilters.SEQ, FileFilters.Any);
            if (data != null)
            {
                seq = SEQ.Load(data);
                oldmusicentrycontroller.OldMusicEntry.SEP.SEQs[i] = seq;
            }
        }
Example #14
0
 public OldSEQController(OldMusicEntryController oldmusicentrycontroller, SEQ seq)
 {
     this.oldmusicentrycontroller = oldmusicentrycontroller;
     this.seq              = seq;
     Node.Text             = "SEQ";
     Node.ImageKey         = "seq";
     Node.SelectedImageKey = "seq";
     AddMenu("Replace SEQ", Menu_Replace_SEQ);
     AddMenu("Delete SEQ", Menu_Delete_SEQ);
     AddMenuSeparator();
     AddMenu("Export SEQ", Menu_Export_SEQ);
     AddMenu("Export SEQ as MIDI", Menu_Export_SEQ_MIDI);
 }
Example #15
0
 //--------------------------------------------------------------------------
 public bool MoveCyl(int aNum, int Act)
 {
     //Run Actuator.
     if (aNum < 0 || aNum >= m_iNumOfACT)
     {
         return(false);
     }
     if (!SEQ.fn_CheckDstbActr(aNum, Act))
     {
         return(false);
     }
     return(Actuator[aNum].Run(Act));
 }
Example #16
0
        public void TestUnsubscribe()
        {
            Clock  clock  = new Clock();
            TicTok tictok = new TicTok();

            tictok.Init();;

            AReg areg = new AReg();
            BReg breg = new BReg();
            IReg ireg = new IReg();
            OReg oreg = new OReg();
            RAM  ram  = new RAM();

            PC   pc   = new PC(ref areg);
            ALU  alu  = new ALU(ref areg, ref breg);
            MReg mreg = new MReg(ref ram);
            SEQ  seq  = SEQ.Instance();

            seq.Load(GetInstructionSet());

            Wbus.Instance().Value = "00000000";
            Flags.Instance().Clear();

            areg.Subscribe(clock);
            breg.Subscribe(clock);
            ireg.Subscribe(clock);
            mreg.Subscribe(clock);
            oreg.Subscribe(clock);
            pc.Subscribe(clock);
            alu.Subscribe(clock); // ALU must come after A and B
            ram.Subscribe(clock);

            for (int i = 0; i < 500; i++)
            {
                clock.SendTicTok(tictok);
                tictok.ToggleClockState();
                clock.SendTicTok(tictok);
                tictok.ToggleClockState();
            }

            // UnSub all
            clock.EndTransmission();

            for (int i = 0; i < 500; i++)
            {
                clock.SendTicTok(tictok);
                tictok.ToggleClockState();
                clock.SendTicTok(tictok);
                tictok.ToggleClockState();
            }
        }
Example #17
0
        public override void SimThink(Sim s)
        {
            switch (Action)
            {
            case AIMode.Idle:
                break;

            case AIMode.Init:
                lifetime      = 0;
                nextSimAction = SimConsts.time[(int)SimConsts.times.t2];
                Action        = AIMode.Seek;
                break;

            case AIMode.Load:
                break;

            case AIMode.Seek:
                if (nextSimAction > 0)
                {
                    --nextSimAction;
                }
                else if (!rodeElevator)
                {
                    needRemoval = true;
                    Action      = AIMode.Idle;
                    SEQ.Enqueue(new SimEvent(EventType.Idle, s.Time, EventTarg.Person, this.Name, Fl));
                    if (Fl == floor.first)
                    {
                        s.fl1Q.Enqueue(this);
                    }
                    else
                    {
                        s.fl2Q.Enqueue(this);
                    }
                }
                else
                {
                    SEQ.Enqueue(new SimEvent(EventType.Terminate, s.Time, EventTarg.Person, this.Name, Fl));
                    needRemoval = true;
                    count--;
                }
                break;

            case AIMode.Unload:
                break;

            default:
                break;
            }
            ++lifetime;
        }
Example #18
0
        private void Exec(TicTok tictok)
        {
            string cw = SEQ.Instance().ControlWord;

            //  TODO - Find a better way of using the mask to get the value
            //          Currently is using hardcoded magic numbers

            // Active Low, Pull on Tok
            if (cw[11] == '0' && tictok.ClockState == TicTok.State.Tok)
            {
                // Store Wbus val in A
                RegContent = Wbus.Instance().Value;
            }
        }
Example #19
0
        public Frame(Instruction instruction, int TState, IPort1 ip1, IPort2 ip2, PC pc, MAR mar, RAM ram,
                     List <string> ramContents, MDR mdr, IReg ireg, SEQ seq, string wbus_string,
                     AReg areg, ALU alu, Flag flagReg, TReg treg, BReg breg, CReg creg,
                     OReg3 oreg3, OReg4 oreg4, HexadecimalDisplay hexadecimalDisplay)
        {
            InstructionData = instruction;
            if (InstructionData.OpCode.Contains(','))
            {
                InstructionData.OpCode = InstructionData.OpCode.Replace(",", string.Empty);
            }

            this.TState = TState;

            this.AReg = areg.ToString_Frame_Use();
            this.BReg = breg.ToString_Frame_Use();
            this.CReg = creg.ToString_Frame_Use();
            this.TReg = treg.ToString_Frame_Use();
            this.IReg = ireg.ToString_Frame_Use();  // The real ToString() is in use with a substring in it.  This is needed for proper operation
            this.MAR  = mar.ToString_Frame_Use();
            this.MDR  = mdr.RegContent;

            this.PC   = pc.RegContent;
            this.ALU  = alu.ToString();
            this.WBus = wbus_string;

            this.OPort1             = oreg3.ToString_Frame_Use();
            this.OPort2             = oreg4.ToString_Frame_Use();
            this.HexadecimalDisplay = hexadecimalDisplay.RegContent;

            this.RAM = ramContents;

            this.SEQ     = seq.ToString();
            this.WBus    = wbus_string; // I didnt want to mess with the Singleton in the frame, so the value will just be passed as a string
            this.RAM_Reg = ram.ToString_Frame_Use();
            this.Flags   = flagReg.RegContent;

            if (instruction == null)
            {
                this.IReg = "???";
            }

            if (TState > 3)
            {
                Instruction = InstructionData.OpCode;
            }
            else
            {
                Instruction = "???";
            }
        }
Example #20
0
        public void TestUpdate()
        {
            try
            {
                Clock  clock  = new Clock();
                TicTok tictok = new TicTok();

                tictok.Init();

                AReg areg = new AReg();
                BReg breg = new BReg();
                IReg ireg = new IReg();
                OReg oreg = new OReg();
                RAM  ram  = new RAM();

                PC   pc   = new PC(ref areg);
                ALU  alu  = new ALU(ref areg, ref breg);
                MReg mreg = new MReg(ref ram);
                SEQ  seq  = SEQ.Instance();
                seq.Load(GetInstructionSet());

                Wbus.Instance().Value = "00000000";
                Flags.Instance().Clear();

                areg.Subscribe(clock);
                breg.Subscribe(clock);
                ireg.Subscribe(clock);
                mreg.Subscribe(clock);
                oreg.Subscribe(clock);
                pc.Subscribe(clock);
                alu.Subscribe(clock); // ALU must come after A and B
                ram.Subscribe(clock);

                clock.IsEnabled = true;

                for (int i = 0; i < 500; i++)
                {
                    clock.SendTicTok(tictok);
                    tictok.ToggleClockState();
                    clock.SendTicTok(tictok);
                    tictok.ToggleClockState();
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
Example #21
0
        private void Exec(TicTok tictok)
        {
            var cw = SEQ.Instance().ControlWord;

            // Active Hi, Push on Tic
            if (string.Equals(cw["ET"], "1", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tic)
            {
                // Send Temp to the WBus
                Multiplexer.Instance().PassThroughToBus(RegContent, Convert.ToBoolean(Convert.ToInt16(cw["UB"])), Convert.ToBoolean(Convert.ToInt16(cw["CLR"])));
            }

            // Active Low, Pull on Tok
            if (string.Equals(cw["LT_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tok)
            {
                // Store Wbus val in Temp
                RegContent = Wbus.Instance().Value[8..];
Example #22
0
            public Exp TranslateRecordExp(Level home, List <Exp> field)
            {
                Temp.Temp addr  = new Temp.Temp();
                Expr      alloc = home.Frame.ExternalCall("_record",
                                                          new Tree.ExpList(new CONST(
                                                                               (field.Count == 0 ? 1 : field.Count) * home.Frame.WordSize()), null));
                Stm init = new EXP(new CONST(0));

                for (int i = field.Count - 1; i >= 0; --i)
                {
                    Expr offset = new BINOP(BINOP.Op.Plus, new TEMP(addr), new CONST(i * home.Frame.WordSize()));
                    Expr v      = field[i].UnEx();
                    init = new SEQ(new MOVE(new MEM(offset), v), init);
                }
                return(new Ex(new ESEQ(new SEQ(new MOVE(new TEMP(addr), alloc), init), new TEMP(addr))));
            }
Example #23
0
        //---------------------------------------------------------------------------
        //Update Timer
        private void fn_tmUpdate(object sender, EventArgs e)
        {
            //
            m_UpdateTimer.Stop();

            SEQ_SPIND.fn_UpdateFlag(ref gdFlag01);
            SEQ_POLIS.fn_UpdateFlag(ref gdFlag02);
            SEQ_CLEAN.fn_UpdateFlag(ref gdFlag03);
            SEQ_STORG.fn_UpdateFlag(ref gdFlag04);
            SEQ_TRANS.fn_UpdateFlag(ref gdFlag05);

            SEQ.fn_UpdateFlag(ref gdFlag06);

            //
            m_UpdateTimer.Start();
        }
Example #24
0
        //--------------------------------------------------------------------------
        //Update.
        public void fn_Update()
        {
            bool isOk = true;

            for (int i = 0; i < m_iNumOfACT; i++)
            {
                Actuator[i].Update();

                //Check Actuator Status.
                if (Err(i) == 1)
                {
                    m_bRptActr[i] = false;
                }

                //Changing Timer.
                if (!m_bRptActrIng)
                {
                    continue;
                }
                if (m_bRptActr[i])
                {
                    if (!SEQ.fn_CheckDstbActr(i, m_iRptCmd))
                    {
                        m_bRptActrIng = false; continue;
                    }
                    MoveCyl(i, m_iRptCmd);
                    if (!Complete(i, m_iRptCmd))
                    {
                        isOk = false;
                    }
                }
            }

            m_ChngActrOnTimer.OnDelay(isOk, m_iChngActrDlay);
            if (m_ChngActrOnTimer.Out)
            {
                m_ChngActrOnTimer.Clear();
                if (m_iRptCmd == (int)EN_ACTR_CMD.Fwd)
                {
                    m_iRptCmd = (int)EN_ACTR_CMD.Bwd;
                }
                else
                {
                    m_iRptCmd = (int)EN_ACTR_CMD.Fwd;
                }
            }
        }
Example #25
0
        private void Exec(TicTok tictok)
        {
            string cw = SEQ.Instance().ControlWord;

            //  TODO - Find a better way of using the mask to get the value
            //          Currently is using hardcoded magic numbers

            // Active Low, Pull on Tok
            if (cw[2] == '0' && tictok.ClockState == TicTok.State.Tok)
            {
                // Store Wbus val in A
                RegContent = Wbus.Instance().Value.Substring(4, 4);

                // Send the MAR data to the RAM
                ram.IncomingMARData(RegContent);
            }
        }
Example #26
0
        public void CheckForJumpCondition()
        {
            var cw = SEQ.Instance().ControlWord;

            string jumpType = cw["JC"];

            WontJump = jumpType switch
            {
                "001" => flagReg.Signed, //JM
                "010" => flagReg.Zero,   //JNZ
                "011" => !flagReg.Zero,  //JZ
                "100" => true,
                "101" => true,
                "110" => true,
                "111" => true,
                _ => true
            };
        }
Example #27
0
            public Exp TranslateSeqExp(ExpList el, bool isVOID)
            {
                if (el == null)
                {
                    return(new Ex(new CONST(0)));
                }
                if (el.Tail == null)
                {
                    return(el.Head);
                }
                if (el.Tail.Tail == null)
                {
                    if (isVOID)
                    {
                        return(new Nx(new SEQ(el.Head.UnNx(), el.Tail.Head.UnNx())));
                    }
                    else
                    {
                        return(new Ex(new ESEQ(el.Head.UnNx(), el.Tail.Head.UnEx())));
                    }
                }
                ExpList ptr = el.Tail, prev = el;
                SEQ     res = null;

                for (; ptr.Tail != null; ptr = ptr.Tail)
                {
                    if (res == null)
                    {
                        res = new SEQ(prev.Head.UnNx(), ptr.Head.UnNx());
                    }
                    else
                    {
                        res = new SEQ(res, ptr.Head.UnNx());
                    }
                }
                if (isVOID)
                {
                    return(new Nx(new SEQ(res, ptr.Head.UnNx())));
                }
                else
                {
                    return(new Ex(new ESEQ(res, ptr.Head.UnEx())));
                }
            }
Example #28
0
        private void Exec(TicTok tictok)
        {
            string cw = SEQ.Instance().ControlWord;

            //  TODO - Find a better way of using the mask to get the value
            //          Currently is using hardcoded magic numbers

            // Active Low, Push on Tic
            if (cw[5] == '0' & tictok.ClockState == TicTok.State.Tic)
            {
                // Send A to the WBus
                Wbus.Instance().Value = "0000" + RegContent.Substring(4, 4); //Instruction register only outputs the least significant bits to the WBus
            }

            // Active Low, Pull on Tok
            if (cw[4] == '0' && tictok.ClockState == TicTok.State.Tok)
            {
                RegContent = Wbus.Instance().Value;
            }
        }
Example #29
0
        public void TestControlWordTableInit()
        {
            SEQ.Instance().Load(GetInstructionSet());

            const int INT_COUNT     = 6;
            const int T_STATE_COUNT = 6;

            string[] INSTRUCTIONS = new string[6] {
                "0000", "0001", "0010", "0011", "1110", "1111"
            };

            for (int instruction = 0; instruction < INT_COUNT; instruction++)
            {
                for (int tstate = 0; tstate < T_STATE_COUNT; tstate++)
                {
                    string temp = INSTRUCTIONS[instruction];
                    // T States start at 1, not 0
                    Assert.AreNotEqual <string>(SEQ.Instance().UpdateControlWordReg(tstate + 1, temp), "", "Control Table not properly initialized");
                }
            }
        }
Example #30
0
        private void Exec(TicTok tictok)
        {
            var cw = SEQ.Instance().ControlWord;

            // Active Hi, Push on Tic
            if (string.Equals(cw["EA"], "1", StringComparison.Ordinal) & tictok.ClockState == TicTok.State.Tic)
            {
                // Send A to the WBus while checking if we want to output to the bus upper or lower 8 bits
                Multiplexer.Instance().PassThroughToBus(RegContent, Convert.ToBoolean(Convert.ToInt16(cw["UB"])), Convert.ToBoolean(Convert.ToInt16(cw["CLR"])));
            }

            // Active Low, Pull on Tok
            if (string.Equals(cw["LA_"], "0", StringComparison.Ordinal) && tictok.ClockState == TicTok.State.Tok)
            {
                // Special logic so we dont have immediate feedback when ALU -> A happens on the updated fetch cycle
                // Only applies to A Register
                if (string.Equals(cw["EU"], "1", StringComparison.Ordinal))
                {
                    return;
                }

                // Store Wbus val in A
                RegContent = Wbus.Instance().Value[8..];
Example #31
0
 public Exp TranslateRecordExp(Level home, List<Exp> field)
 {
     Temp.Temp addr = new Temp.Temp();
     Expr alloc = home.Frame.ExternalCall("_record",
         new Tree.ExpList(new CONST(
             (field.Count == 0 ? 1 : field.Count) * home.Frame.WordSize()), null));
     Stm init = new EXP(new CONST(0));
     for (int i = field.Count - 1; i >= 0; --i)
     {
         Expr offset = new BINOP(BINOP.Op.Plus, new TEMP(addr), new CONST(i * home.Frame.WordSize()));
         Expr v = field[i].UnEx();
         init = new SEQ(new MOVE(new MEM(offset), v), init);
     }
     return new Ex(new ESEQ(new SEQ(new MOVE(new TEMP(addr), alloc), init), new TEMP(addr)));
 }
Example #32
0
 void PrintStm(SEQ s, int d)
 {
     Indent(d); SayLn("SEQ("); PrintStm(s.Left, d + 1); SayLn(",");
     PrintStm(s.Right, d + 1); Say(")");
 }
Example #33
0
 public Exp TranslateSeqExp(ExpList el, bool isVOID)
 {
     if (el == null) return new Ex(new CONST(0));
     if (el.Tail == null) return el.Head;
     if (el.Tail.Tail == null)
         if (isVOID)
             return new Nx(new SEQ(el.Head.UnNx(), el.Tail.Head.UnNx()));
         else
             return new Ex(new ESEQ(el.Head.UnNx(), el.Tail.Head.UnEx()));
     ExpList ptr = el.Tail, prev = el;
     SEQ res = null;
     for (; ptr.Tail != null; ptr = ptr.Tail)
     {
         if (res == null)
             res = new SEQ(prev.Head.UnNx(), ptr.Head.UnNx());
         else
             res = new SEQ(res, ptr.Head.UnNx());
     }
     if (isVOID)
         return new Nx(new SEQ(res, ptr.Head.UnNx()));
     else
         return new Ex(new ESEQ(res, ptr.Head.UnEx()));
 }