你可以帮助我们来翻译此条目,但请勿使用机器翻译。
本文在探讨Minecraft中计算系统的设计和实现。
人类通过编程可以使电脑实现方便的思想交流。
所有计算机系统都有访问内存和至少一个处理单元。在操作期间,处理单元执行命令存储在计算机的内存中。
大多数电脑都是使用红石火把、中继器、粘性活塞或红石灯。它们通过一系列的开关:按钮、拉杆、压力板,等。另外,在手机版等版本,红石非常有限。使用沙子、沙砾和告示牌可能是一个更好的选择。
实现
计算机在许多方面都有应用,它可用作建造一个智能的房子或是用它运作整个城市。 它也可以被用在小游戏方面,比如它可以计算玩家的分数。计算机的应用近乎无限。但请注意,红石计算机运行真的很慢,甚至完成一次最快的计算也需要花上几秒。这也意味着红石计算器没有什么实际用途。
红石计算机的规划
当设计一个计算机(红石或者别的方式)关键的设计决策,将影响组织,规模和潜在的性能计算机应具体施工前的特定组件。
一些事情需要考虑:
*执行模型(内存的计算机组织与程序存储和执行) *字大小(信息块的大小,你的电脑会操作) *指令集(这组操作你的电脑将执行) *内存大小(数量的数据可以存储在内存中)
有一个选择决定将提供强有力的指导在各种组件的设计你的电脑。
Execution Model
指令存储块的技术叫做程序在内存是允许计算机执行各种不同的任务。
使用的设备由计算机来存储和检索这些程序是计算机的执行模型。
世界上最成功的两个执行模型,哈佛和冯·诺依曼,今天将近100%的可用的计算机上运行。
哈佛结构
The Harvard architecture 检索器分离的指令组成一个活跃的程序从数据访问器的程序在执行期间访问。 编写的程序对电脑使用哈佛架构可能执行的任务达到快100%访问主内存总线。但是要注意,某些记忆电路必然是更大的对于那些选择哈佛架构。
冯·诺伊曼结构
The von Neumann architecture使用一个两步的过程来执行指令。首先,加载内存包含下一个指令,然后新指令加载是允许访问相同的内存,因为它执行;使用一个内存的程序和数据促进元编程技术像编译器和自我修改代码。 冯诺依曼体系结构是第一个提出模型的计算和几乎所有真实的计算机是冯·诺依曼在《自然》杂志上。
字号
字大小是计算机物理尺寸的主要因素。 在《我的世界》中,从1位一直到32位的机器已经被成功构建出来。 常见的字大小的组合:
| 数据 | 命令 |
|---|---|
| 4 | 8 |
| 8 | 8 |
| 8 | 16 |
| 16 | 16 |
Data-Word
The amount of information a computer can manipulate at any particular time is representative of the computer's Data Word-size.
In Digital Binary, the computer's Data-Word size ( measured in bits ) is equal to the width of or number of channels in the computers main bus.
Data-Words commonly represent integers, or whole numbers encoded as patterns of binary digits.
The maximum sized number representable by a Binary encoded integer is given by 2 ^ Data-Word width in bits - 1.
Some common Integer data sizes are:
| Max Representable Number | Number of Bits Required |
|---|---|
| 1 ( 2 ^ 1 - 1 ) | 1 |
| 7 ( 2 ^ 3 - 1 ) | 3 |
| 15 ( 2 ^ 4 - 1 ) | 4 |
| 255 ( 2 ^ 8 - 1 ) | 8 |
| 65535 ( 2 ^ 16 - 1 ) | 16 |
| 4294967295 ( 2 ^ 32 - 1 ) | 32 |
Data-Word size also governs the maximum size of numbers which can be processed by a computer's ALU (Arithmetic and Logic Unit).
Instruction-Word
The amount of data a computer needs in order to complete one single instruction is representative of a computers Instruction Word-size.
The Instruction-Word size of a computer is generally a multiple of its Data-Word size, This helps minimize memory misalignment while retrieving instructions during program execution.
计算机的设计
Instruction-Set-Architecture
States
Memory is a set number of bits. In Minecraft, memory usually holds 8 or 16 bits, though 32 bit memory computers have been successfully built before. Each bit is in one of two possible states: on or off. Memory is a series of these ons and offs, which can be used to perform certain tasks.
信号
现实世界计算机使用二进制,一系列的1和0。“1”表示“开”和“0”表示“关”。在"Minecraft,最好的体现是红石:有信号意味着“1”,没有信号表示“0”。然而,根据距离红石从内存存储,它是“0”可以是任何信号强度从0到14。你也可以设计,使“1”信号强度从1到15。
Numbers
Our normal decimal system is a number system in base 10. Binary, the number system within computers, is in base 2. To compare, take a look at 2-digit number. In decimal, the left digit is the 10s digit. In binary, it is the 2s digit. For example in decimal, "10" is read as "ten". In binary, "10" is read as "two". There are two commonly-used methods of converting from decimal to binary:
Highest Bit First: This method requires a bit of intuition. Lets use 42 as an example. We first start by looking for the largest exponential of 2 (i.e. 32 [2^5] or 65536 [2^16]). In this case, its 32. We then subtract that number from the number in question. 42-32=10. Also, the very first bit from the left is a "1". We then step down to the next exponential of 2 and see if it is less than or equal to our current number. For this example, the next one is 16. 16 is not less than 10, so the next bit is "0". We keep doing this until the number reaches 0. Whenever the 2 exponential is less than or equal to the number, subtract them and the next bit is "1". If not, the next bit is "0". To continue our example: 8<10-->10-8=2-->"1" 4>2-->"0" 2=2-->2-2=0-->"1" 1>0-->"0" So our final binary representation of 42 is "101010". Fancy.
Lowest Bit First: This method requires no memorization of 2 exponentials. Instead, it repeatedly divides the number by 2, using the quotient as the next number, and the remainder as the binary bit. Keep in mind, though, that this method writes the binary number from right to left, as opposed to the previous method which wrote it from left to right. Let's reuse our example, 42. 42/2=21 r 0 (right most bit is 0) 21/2=10 r 1 (next bit to the left is 1) 10/2=5 r 0 (next bit to the left is 0) 5/2=2 r 1 (next bit to the left is 1) 2/2=1 r 0 (next bit to the left is 0) 1/2=0 r 1 (next bit to the left is 1)
Quotient is 0, so we stop. This gives us our binary number as "101010". Same as the previous method.
Transitions
Words
指令
功能本质上是由计算机指令构成的,指令的例子包括:
- 加、减、乘、除
- Read/Write from RAM/ROM/tertiary memory
- 读取和写入数据到内存
- 分支的其他部分代码
- 比较寄存器
- 选择一个逻辑函数 (NAND, NOR, NOT etc.)
指令可以被编程到内存,从ROM加载或直接通过一个拉杆或按钮激活。每条指令都有它自己的特定的二进制串分配(e.g. 0000=Load data from register 0001=add A and B 1011=Save RAM into teritary memory etc.)and would probably require its own binary to decimal or binary to BCD to decimal encoders and buses to the ALU/registers.
Classification
Abstraction
Mapping
Symbols
Numbers
功能
形式化
可计算性
变量
变量是数字、字符串字符(套)或布尔值(真或假)存储在RAM中运行一个程序的目的。例如,布尔值可以用来保持信息如果程序已经达到某种状态。以下信息需要保存一个变量:它的名称,类型(数字、字符串或布尔),和价值。变量值,顾名思义,改变。操作可以进行变量。创建变量在运行程序时,一旦项目结束,从内存中删除。当一个程序重启,变量是重现。"我是相同的。
Hierarchies
Memory
Memory is where data for programs is kept. It is volatile (It is deleted when the computer is turned off) and is used for the program to store data. For example, in a program which counts up from 1, 1 is saved to memory, 1 is loaded from memory and 1 is added to it to get 2.
Execution
Semantics
数据
数据是计算机处理的信息,使用二进制表示。
控制单元
Machine-Architecture
数据通道
Processing
算术逻辑单元
ALU是计算机最重要的组件之一,在现实生活和Minecraft中。首先,你必须选择你希望能够实现的功能。大多数时候,这些都是加法、减法和一组逻辑选项 与,或,与非,或者你所喜欢的。你必须建立单位和所有你想要的逻辑门和数学函数和选择哪一个的输出显示。
总线
用总线允许您的计算机的组件相互通信。 一条总线可以通过使用创建红石布线连接你的计算机的运算器,随机储存器,只读储存器,中央处理器和寄存器在一起,这样他们就可以互相之间发送数据。通常是重要的计划,建立你的电脑的组件,这样你不需要创建总线电线过长,或者更糟的是,没有空间来创建总线,在这种情况下,您可以删除的组件并重建一个适当的位置,或者使用国防部像WorldEdit移动组件在其他地方。
存储
随机存取存储器
随机存取存储器也称做RAM 是一种内存使用的程序和灵活的。大多数时候,在Minecraft使其挥发性没有使用,所以做一些最简单的方法是使用d-flip失败和添加一个读写功能。一个是简单的。你可以1触发器然后就栈只要需要,与一个街区的每一个字节。看到下面的计划帮助:
(redstone schematic to be done) Reference the picture if not sure (click on it to get it larger) r=wire p=repeater b=block t=torch on side of block 0=air
Layer 1
00trb00
rpb0tr0
Layer 2
0b0t00b
tbbbbtb
Layer 3
0r0t00r
0rprr0r
三级存储器
三级内存用于压缩存储大量数据的速度。这种内存的数据库,所有的数据实际存储,和物理机制,通常一个机械手臂,必须身体移动数据库获取数据。出于这个原因,它是极其缓慢的,只是用于很少访问的信息。这相当于一个真正的计算机的硬盘或固态驱动器。
机器状态
程序计数器
程序计数器用于记录计算机应该读这行代码。在每个时钟周期,解码器将访问这个计数器为了获取下一个要执行的指令。一些指令会比另一个访问不同的数据量,或任何数据,因此解码器将适量增加程序计数器的下一个指令。使用的计数器也跳转指令控制程序流。
控制路径
processing
控制单元
File:Redstone Computer Control Unit.PNG
总线
File:Redstone Computer Control Busing.PNG
硬盘
File:Redstone Computer Tertiary Memory.PNG
程序内存
File:Redstone Computer Program Memory.PNG
程序内存,最基本,ROM(只读存储器)。ROM是最常用的远程执行一系列任务(如一个程序,因此得名)。它可以用来在用户控件(如图片)或每一行之间的时钟和足够的延迟2不是在同一时间。最简单、最高效的设计之一是一个图中,这可能是也可能不是加上解码器。它可以很容易地扩大,这是另一个优势。
机器状态
File:Redstone Computer Machine State.PNG
程序计数器
时钟
File:Redstone Computer Clock.PNG
时钟同步组件或使用时间。(Minecraft)在大多数情况下,可以避免使用但有时它是计算机的功能所必需的。它基本上可以由红石火把链接成一条线/圈的非门(奇数建议或者你的输出必须“取反”),或从中继器,如上图所示。
提示
- 你也可以使用一些像是WorldEdit的模组
- 如果你在生存模式没有太多的红石中继器 你可以用两个红石火把代替
- 利用颜色进行分区(例如用蓝色羊毛建造RAM(随机存取存贮器),黄色羊毛建造ALU(算术逻辑部件运算器)等)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

