示例#1
0
        public void RV32ICoreInitializeTest()
        {
            RV32ICore                core   = new RV32ICore();
            CoreRegister <uint>      ra     = typeof(RV32ICore).GetField("abi_ra", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(core) as CoreRegister <uint>;
            CoreRegisterGroup <uint> rGroup = typeof(RV32ICore).GetField("coreRegisterGroup", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(core) as CoreRegisterGroup <uint>;

            ra.Value = 0x00100020;
            Assert.AreEqual(ra.Value, rGroup[1]);
        }
示例#2
0
        public void RV32InstructionFetch32BTest()
        {
            RV32ICore core = new RV32ICore();

            uint instruction = 0b0100000_00011_00010_000_00001_0110011U; // sub r1, r2, r3

            byte[] buffer = BitConverter.GetBytes(instruction);
            core.OpenInstructionStream(BitConverter.IsLittleEndian ? buffer : buffer.Reverse().ToArray());
            core.ResetCore();

            MethodInfo fetch = typeof(RV32ICore).GetMethod($"{nameof(RISCVSharp)}.{nameof(IRV32Fetch32B)}.Fetch32B", BindingFlags.Instance | BindingFlags.NonPublic);

            fetch.Invoke(core, null);

            FieldInfo           fetched = typeof(RV32ICore).GetField("fetchRegister", BindingFlags.Instance | BindingFlags.NonPublic);
            CoreRegister <uint> reg     = fetched.GetValue(core) as CoreRegister <uint>;

            Console.WriteLine($"Instruction in memory = {instruction.ToString("X8")}, Instruction fetched = {reg.Value.ToString("X8") }");
            Assert.AreEqual(reg.Value, instruction);
        }
示例#3
0
        public void RV32InstructionSplitDecodeTest()
        {
            RV32ICore core = new RV32ICore();

            core.ResetCore();

            uint instruction = 0b0100000_00011_00010_000_00001_0110011U; // sub r1, r2, r3

            // Direct set fetch register
            FieldInfo           fetched = typeof(RV32ICore).GetField("fetchRegister", BindingFlags.Instance | BindingFlags.NonPublic);
            CoreRegister <uint> freg    = new CoreRegister <uint>(instruction);

            fetched.SetValue(core, freg);

            // Decode
            MethodInfo decode = typeof(RV32ICore).GetMethod($"{nameof(RISCVSharp)}.{nameof(IRV32Decode)}.InstructionSplitDecode32B", BindingFlags.Instance | BindingFlags.NonPublic);

            decode.Invoke(core, null);

            Dictionary <string, uint> asserts = new Dictionary <string, uint>()
            {
                { "decodeOpcodeRegister", 0b0110011U },
示例#4
0
        public void PrintCoreRegisterGroupStatusTest()
        {
            RV32ICore core = new RV32ICore();

            Console.WriteLine((core as IRVDebuggable).PrintCoreRegisterGroupStatus());
        }