Exemplo n.º 1
0
        public void Setup()
        {
            var configuration = new HartConfiguration();

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

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

            te = new TestEnvironment();
        }
Exemplo n.º 2
0
        public void LoadRvcGenericTest(IHart hart)
        {
            // in Little Endian!
            var block100 = new List <byte>()
            {
                0xFD, 0x08, // C.ADDI, nzimm = 0x1F, Rs1/Rd = 1 (9)
                0x7D, 0x49, // C.LI, imm = 0x1F, Rd = 2 (10)
                0x2A, 0x89  // C.MV RS1 = 10, RD = 11
            };

            hart.Load(0x100, block100);
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        public void LoadTest1(IHart hart)
        {
            /*
             *  / ! = Start Program Counter
             *  / # = Program Counter Space for content (data and instruction)
             *  ! 100
             # 100
             #  / ADDI x10 = x0 + FF
             #  ;13 05 F0 0F
             #  / ADDI x11 = x0 + FF
             #  ;93 05 F0 0F
             #  / ADD x12 = x10 + x11
             #  ;33 06 B5 00
             #  // Nop
             #  nop
             #  / Jump to 200 using JALR direct jump
             #  ;E7 00 00 20
             #  / Addi x15 = 0 + 1
             #  ;93 07 10 00
             #
             #
             # 200
             #  / ADDI x14 = x0 + 1
             #  ;13 07 23 00
             #  / JALR rd=0, rs1 = 1 => POP
             #  ;67 80 00 00
             *
             */

            var blockAddress100 = new List <byte>()
            {
                0x13, 0x05, 0xF0, 0x0F,
                0x93, 0x05, 0xF0, 0x0F,
                0x33, 0x06, 0xB5, 0x00,
                0xE7, 0x00, 0x00, 0x20,
                0x93, 0x07, 0x10, 0x00
            };

            var blockAddress200 = new List <byte>()
            {
                0x13, 0x07, 0x23, 0x00,
                0x67, 0x80, 0x00, 0x00
            };

            hart.Load(0x100, blockAddress100);
            hart.Load(0x200, blockAddress200);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public void LoadRvc32Test1(IHart hart)
 {
 }