• 大小: 149KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: CPU设计  

资源简介

计算机原理课程实习报告,简单模拟CPU的工作过程,包含代码,实习报告,可运行

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Text.Regularexpressions;

namespace WindowsFormsCPU
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            //通用寄存器初始化
            R0.Text = “00000000“;
            R1.Text = “00000000“;
            R2.Text = “00000000“;
            R3.Text = “00000000“;
            R4.Text = “00000000“;
            R5.Text = “00000000“;
            R6.Text = “00000000“;
            R7.Text = “00000000“;
            R8.Text = “00000000“;
            R9.Text = “00000000“;
            R10.Text = “00000000“;
            R11.Text = “00000000“;
            R12.Text = “00000000“;
            R13.Text = “00000000“;
            R14.Text = “00000000“;
            R15.Text = “00000000“;
            SR.Text = “00000000“;
        }
        //数值初始化
        //指令数组总数
        public int instructionSum = 0;
        //指令的字符串数组
        public string[] instruction;
        //单步执行指令的步数
        public int stepCount = 0;

        //空格指令分割函数,返回的是指令码的字符串
        static string getIrString(string str)
        {
            string[] tempStr;
            tempStr = str.Split(‘ ‘);

            //测试空格分割
            //foreach (string i in tempStr)
            //{
            //    Console.Write(“经过空字符分割的指令“);
            //    Console.WriteLine(i);
            //}
            //空分割测试函数
            Console.WriteLine(“getIrString,返回的指令码是{0}“tempStr[0]);
            return tempStr[0];
        }

        //指令码译码函数,要求形参是完整的指令,返回对应的指令码的字符串
        static string getIrBinaryString(string str)
        {
            str = getIrString(str);
            string tempStr = getIrString(str);
            Console.WriteLine(“getIrBinaryString 指令码{0}“ tempStr);
            if (str == “add“)
                tempStr = “00001100“;
            else if (str == “sub“)
                tempStr = “00001000“;
            else if (str == “Mul“)
                tempStr = “10011100“;
            else if (str == “RJMP“)
                tempStr = “1100“;
            else if (str == “BRMI“)
                tempStr = “11110001“;
            else if (str == “Mov“)
                tempStr = “00101100“;
            else if (str == “Ldi“)
            {
                tempStr = “1110“;
                Console.WriteLine(“getIrBinaryString 中,翻译了Ldi“);
            }
               // tempStr = “1110“;
            else if (str == “Ld“)
                tempStr = “10010000“;
            else if (str == “st“)
                tempStr = “10010010“;
            else if (str == “nop“)
                tempStr = “00000000“;
            tempStr = newStr(tempStr);
            return tempStr;
        }

        //指令拼接部分,返回部分一个长度为8的字符串,将一个字符串复制

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-14 16:31  201614600226吴广丽\
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\
     文件         187  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\App.config
     文件       25288  2018-07-01 20:24  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Form1.Designer.cs
     文件       25285  2018-07-01 22:03  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Form1.cs
     文件        5817  2018-07-01 20:24  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Form1.resx
     文件         527  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Program.cs
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Properties\
     文件        1354  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Properties\AssemblyInfo.cs
     文件        2882  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Properties\Resources.Designer.cs
     文件        5612  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Properties\Resources.resx
     文件        1102  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Properties\Settings.Designer.cs
     文件         249  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\Properties\Settings.settings
     文件        3810  2018-06-30 14:18  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\WindowsFormsCPU.csproj
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\
     文件       24064  2018-07-01 22:03  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\WindowsFormsCPU.exe
     文件         187  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\WindowsFormsCPU.exe.config
     文件       54784  2018-07-01 22:03  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\WindowsFormsCPU.pdb
     文件       24224  2018-07-01 22:37  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\WindowsFormsCPU.vshost.exe
     文件         187  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\WindowsFormsCPU.vshost.exe.config
     文件         490  2018-04-12 07:35  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\bin\Debug\WindowsFormsCPU.vshost.exe.manifest
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\
     目录           0  2018-07-14 16:30  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\
     文件        1453  2018-07-01 17:27  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7192  2018-07-01 22:35  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2018-07-14 16:31  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\TempPE\
     文件           0  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2018-06-30 13:53  201614600226吴广丽\WindowsFormsCPU\WindowsFormsCPU\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
............此处省略11个文件信息

评论

共有 条评论