예제 #1
0
        private static void ApplyDebug(HartConfiguration config, string mode)
        {
            var toUpper = mode.ToUpper();

            if (toUpper == "ON")
            {
                config.Debug = DebugMode.Enabled;
            }
        }
예제 #2
0
        private static void ApplyVerbose(HartConfiguration config, string mode)
        {
            var toUpper = mode.ToUpper();

            if (toUpper == "ON")
            {
                config.VerboseMode = true;
            }
        }
예제 #3
0
        private static void ApplyRvMode(HartConfiguration config, string mode)
        {
            var toUpper = mode.ToUpper();

            if (toUpper.Equals("ON"))
            {
                config.RvMode = true;
            }
        }
예제 #4
0
        public void Setup()
        {
            var configuration = new HartConfiguration();

            configuration.Architecture = Architecture.Rv64I;
            configuration.RvMode       = true;

            hart = new HartCore64();
            hart.Configure(configuration);

            te = new TestEnvironment();
        }
예제 #5
0
        public void Setup()
        {
            var configuration = new HartConfiguration();

            configuration.Architecture = Architecture.Rv32I;
            configuration.RvMode       = false;

            hart = new HartCore32(Architecture.Rv32I);
            hart.Configure(configuration);

            te = new TestEnvironment();
        }
예제 #6
0
파일: Host.cs 프로젝트: sovr610/PatoSim
        private void ReadRv(HartConfiguration config, IHart hart)
        {
            var rvParser = new RvParser();
            var program  = rvParser.Parse(config.Source);

            Console.WriteLine("\n## Program details:\n");

            // The program counter starts at 0
            ulong programCounter = Convert.ToUInt64(config.RvLoadOffset);

            hart.Init(programCounter);

            var opcodes = program.GetOpcodes();

            Console.WriteLine(program.GetOpcodeLines());
            hart.Load(programCounter, opcodes);
        }
예제 #7
0
파일: Host.cs 프로젝트: sovr610/PatoSim
        private void ReadOpcode(HartConfiguration config, IHart hart)
        {
            var lowLwevelParser = new Parser();
            var myProgram       = lowLwevelParser.Parse(config.Source);

            Console.WriteLine("\n## Program details:\n");
            Console.WriteLine(myProgram.GetHumanReadableContent());

            //
            // Init the RISC V hart and start the simulation
            //

            hart.Init(myProgram.InitialProgramCounter);

            // Load each modules to the memory
            foreach (var subRoutineMarker in myProgram.GetSubRoutineMarker())
            {
                var data = myProgram.GetSubRoutine(subRoutineMarker);
                hart.Load(subRoutineMarker, data);
            }
        }
예제 #8
0
        private static void ApplyCpu(HartConfiguration config, string mode)
        {
            var          toUpper      = mode.ToUpper();
            Architecture architecture = Architecture.Unknown;

            if (toUpper == "RV32I")
            {
                architecture = Architecture.Rv32I;
            }

            if (toUpper == "RV32E")
            {
                architecture = Architecture.Rv32E;
            }

            if (toUpper == "RV64I")
            {
                architecture = Architecture.Rv64I;
            }

            config.Architecture = architecture;
        }
예제 #9
0
파일: Host.cs 프로젝트: sovr610/PatoSim
        private IHart Build(HartConfiguration config)
        {
            IHart hart = null;

            var architecture = config.Architecture;

            if (architecture == Architecture.Rv32E || architecture == Architecture.Rv32I)
            {
                hart = new HartCore32(architecture);
            }

            if (architecture == Architecture.Rv64I)
            {
                hart = new HartCore64();
            }

            if (hart == null)
            {
                throw new RiscVSimException("Unsupported architecture detected!");
            }

            return(hart);
        }
예제 #10
0
파일: Host.cs 프로젝트: sovr610/PatoSim
        public void Run(HartConfiguration config)
        {
            Logger.Info("CPU = {cpu}", config.Architecture);
            Logger.Info("Memory = {memory}", config.Memory);

            // Let#s go!"
            Console.WriteLine("## Configuration");
            Console.WriteLine("# Start : {0}", DateTime.Now.ToUniversalTime());
            Console.WriteLine("# CPU : {0}", config.Architecture);
            Console.WriteLine("# Memory : {0}", config.Memory);
            Console.WriteLine("# Debug : {0}", config.Debug);
            Console.WriteLine("# RvMode = {0}", config.RvMode);

            bool fileExists = File.Exists(config.Source);

            if (fileExists)
            {
                Console.WriteLine("# File : {0}", config.Source);
            }
            else
            {
                Console.WriteLine("## STOP : File does not exists");
            }

            var hart = Build(config);

            hart.Configure(config);

            if (config.RvMode)
            {
                // Read the RV files
                ReadRv(config, hart);
            }
            else
            {
                // If the input format is not the "rv format" use the default opcode one
                ReadOpcode(config, hart);
            }

            //
            //  !Vamos!  Alonsy! Let's go! Auf gehts! ..... Start the simulation.
            //

            var task1 = Task.Run(() => hart.Start());

            Task.WaitAll(new Task[] { task1 });

            // Wait for the end of the task or any debug stop

            Console.WriteLine("## Simulation stopped : {0}", DateTime.Now.ToUniversalTime());

            //
            // Show the states of the register and memory (?)
            //
            var registerState = hart.GetRegisterStates();

            Console.WriteLine(registerState);

            var memoryState = hart.GetMemoryState();

            Console.WriteLine(memoryState);
        }
예제 #11
0
        private static HartConfiguration ReadArgs(string[] args)
        {
            foreach (var arg in args)
            {
                var toUpper = arg.ToUpper();

                // Check for CPU..
                if (toUpper.StartsWith("/CPU:"))
                {
                    cpu = arg;
                }

                // Check for Memory..
                if (toUpper.StartsWith("/MEMORY:"))
                {
                    memory = arg;
                }

                // Check for Debug..
                if (toUpper.StartsWith("/DEBUG:"))
                {
                    debug = arg;
                }

                if (toUpper.StartsWith("/VERBOSE:"))
                {
                    verbose = arg;
                }

                if (toUpper.StartsWith("/RVMODE:"))
                {
                    rv = arg;
                }

                if (toUpper.StartsWith("/RVMODEL:"))
                {
                    rvL = arg;
                }

                if (!arg.StartsWith("/"))
                {
                    file = arg;
                }
            }

            // Set some defaults
            LoadDefaults();


            //
            // Build the configuraton now
            //
            var config = new HartConfiguration();

            var cpuMode     = cpu.Split(new char[] { ':' });
            var memoryMode  = memory.Split(new char[] { ':' });
            var debugMode   = debug.Split(new char[] { ':' });
            var rvMode      = rv.Split(new char[] { ':' });
            var rvModeL     = rvL.Split(new char[] { ':' });
            var verboseMode = verbose.Split(new char[] { ':' });

            ApplyCpu(config, cpuMode[1]);
            ApplyMemory(config, memoryMode[1]);
            ApplyVerbose(config, verboseMode[1]);
            ApplyDebug(config, debugMode[1]);
            ApplyRvMode(config, rvMode[1]);
            ApplyRvModeL(config, rvModeL[1]);

            config.Source = file;
            return(config);
        }
예제 #12
0
        private static void ApplyMemory(HartConfiguration config, string mode)
        {
            var toUpper = mode.ToUpper();

            // keep the default.  others are in the queue...
        }
예제 #13
0
        private static void ApplyRvModeL(HartConfiguration config, string mode)
        {
            int loadPoint = Int32.Parse(mode, System.Globalization.NumberStyles.HexNumber);

            config.RvLoadOffset = loadPoint;
        }