Esempio n. 1
0
 public Cpu(AddrSpace addrspace) { a = addrspace; }
Esempio n. 2
0
        static void Main(string[] args)
        {
            AddrSpace a = new AddrSpace();

            /* Load up ROM */
            //string fname = "../../../jcasm/bin/Debug/test.bin";
            //string fname = "D:/tysos/branches/tysila3/tl/tl/bin/Debug/test.bin";
            string fname = "D:/cygwin64/home/jncro/fpga/loader.bin";
            System.IO.FileStream rom = new System.IO.FileStream(fname,
                System.IO.FileMode.Open);
            a.AddRegion(new RAM(4096, new System.IO.BinaryReader(rom)), 0);

            /* Add devices */
            a.AddRegion(new RAM(512 * 1024), 0x400000);
            a.AddRegion(new RAM(512 * 1024), 0x800000);
            a.AddRegion(new UART(), 0xc00000);
            a.AddRegion(new SPI(), 0x1400000);

            var irq = new IRQController();
            a.AddRegion(irq, 0x1c00000);

            var timer = new Timer();
            a.AddRegion(timer, 0x1800000);
            irq.irqs[0] = timer;

            a.AddRegion(new Vga(), 0x1000000);

            /* Create cpu */
            Cpu c = new Cpu(a);

            Dictionary<uint, bool> bpoints = new Dictionary<uint, bool>();

            //Console.TreatControlCAsInput = true;
            Console.CancelKeyPress += Console_CancelKeyPress;

            while(true)
            {
                timer.Tick();
                irq.Tick();
                if (irq.IsIRQSignalled())
                {
                    c.IRQ();
                    irq.AckIRQ();
                }

                if (bpoints.ContainsKey(c.PC))
                    sstep = true;

                if (sstep)
                {
                    System.Console.Write(c.ToString());
                    string s = System.Console.ReadLine();
                    if (s != null)
                    {
                        if (s == "c" | s == "g" | s == "r")
                            sstep = false;
                        if (s.StartsWith("b "))
                        {
                            s = s.Substring(2);
                            uint bpval = 0;
                            if (s.StartsWith("0x"))
                            {
                                s = s.Substring(2);
                                bpval = uint.Parse(s, System.Globalization.NumberStyles.HexNumber);
                            }
                            else
                                bpval = uint.Parse(s);

                            bpoints[bpval] = true;
                        }
                    }
                }
                c.Tick();
            }
        }