<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.logic.world/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=N00basaurus</id>
	<title>Logic World Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.logic.world/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=N00basaurus"/>
	<link rel="alternate" type="text/html" href="https://wiki.logic.world/wiki/Special:Contributions/N00basaurus"/>
	<updated>2026-05-15T13:38:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=784</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=784"/>
		<updated>2025-10-18T00:27:37Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Expanded the Building a Computer portion of the guide.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code, and each number is called an instruction or opcode. The computer will step through this list one instruction at a time, grabbing each instruction, interpreting it, and performing an action corresponding to that instruction. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
[[File:A schematic view of a very basic control unit.png|thumb|A lookup table takes in as its inputs the content of a step counter and an instruction register, and produces as its outputs various read, write, and function signals. On the clocks rising edge, the step counter is incremented. The lookup table immediately updates its outputs, reading from various components and sending function signals. The write signals do not get sent out though until the falling edge of the clock. As this diagram suggests, the lookup table is in control of its own instruction register, and has the ability to reset the step counter. The instruction register is updated at the beginning of every instruction sequence, and the step counter is reset at the end of every instruction sequence.]]&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the instruction fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and to a pulse for the write signals through the use of a [[Edge Detection|falling edge detector]], while the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory, and the first instruction in that section is primed to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a condition is met, like two numbers being equal or one being greater than the other. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation is key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how programs will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Operands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
&lt;br /&gt;
=== Mental Preparations ===&lt;br /&gt;
Depending on the size and complexity of your computer, the building phase will take several days to several months to complete. This is a full-scale project, so be aware of what you&#039;re committing to. Our example computer is simple, and should only take 1-3 days to build depending on your skill and availability. Even still, you will need to mentally prepare yourself if you&#039;re not used to working on larger scale projects. Things won&#039;t work the first time, you will need to troubleshoot things. You will learn how to do things better as you work on this, give yourself time and space to tear things down and start again if you deem it necessary. Prototypes aren&#039;t just small-scale quick-and-dirty versions of the final product that you assemble to get something done now. &#039;&#039;They&#039;re practice runs&#039;&#039;. They give you the experience needed to determine what works and what doesn&#039;t. Be patient. Be willing to try when you don&#039;t know what to do, and be willing to throw it all away when you find out it doesn&#039;t work.&lt;br /&gt;
&lt;br /&gt;
If you want to know what it takes to carry out a big project, the book &amp;quot;How Big Things Get Done&amp;quot; by Bent Flyvbjerg and Dan Gardner is an invaluable resource. If you read it, you might get the impression that the &amp;quot;correct&amp;quot; way to handle a project like this is to plan every little detail on paper &#039;&#039;before&#039;&#039; you start building.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Do not do this!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The key idea you should take away from this book is there are some things you just don&#039;t think about until you start putting shovels in the ground. Rather than waiting until this moment, instead try putting a spoon in a sandbox first. Do it for real, but on a smaller and cheaper scale.&lt;br /&gt;
&lt;br /&gt;
Nothing is cheaper than a digital sandbox, so Logic World has you covered there. But you&#039;ll still have to build something, make your mistakes, learn, and try again. No amount of forethought will ever prepare you for what you&#039;ve never tried before. Though a bit for forethought is still good practice. &lt;br /&gt;
&lt;br /&gt;
=== Start With The Major Components ===&lt;br /&gt;
What components do you know your computer will need? What are their inputs and outputs? What do they do? These are the best places to start when building a computer.&lt;br /&gt;
&lt;br /&gt;
In our example computer, we know our computer needs an 8-bit ALU. We know this ALU will have 6 functions, and we know it will produce 4 flag outputs along with the normal result output. Start by building that. Use [[Socket|sockets]] to make this component modular and to make connecting to other components easier.&lt;br /&gt;
&lt;br /&gt;
We also know this computer will need registers. We&#039;ll need to be able to read from and write to these registers, but things like the ALU can also access the state of these registers directly. Building a single register with a data in/out connection, a read, write, and enable input, and a state output will allow us to duplicate the design and build our register file much faster.&lt;br /&gt;
&lt;br /&gt;
We can also reuse this design for other registers like the instruction register.&lt;br /&gt;
&lt;br /&gt;
The flag register, instruction pointer register, and step counter will all need to be custom built, as their behavior differs slightly from our register template. But these too are components who&#039;s inputs, outputs, and behaviors are known, and thus can quickly be built in isolation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Test as you go!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
While it may seem like extra work, you&#039;ll want to know that each component is in working order &#039;&#039;before&#039;&#039; you use them in your final build. This isn&#039;t strictly necessary, but as a general rule of thumb when building things, it &#039;&#039;&#039;&#039;&#039;never&#039;&#039;&#039;&#039;&#039; works right the first time. When it comes time to put everything together, it&#039;s better to only have to deal with issues that arise at that level, rather than to run around trying to fix every problem with every component at every level.&lt;br /&gt;
&lt;br /&gt;
Continue to build each of the remaining components in isolation. Moving on to a small portion of [[switch]]-based program memory, and any other major components you might discover you need along the way, such as [[Multiplexer|multiplexers]], [[Decoder|decoders]], and smaller [[Lookup Table|lookup tables]] for controlling things like translating portions of the instruction register into control lines for the general purpose registers or the ALU. &#039;&#039;Save the control lookup table for last!&#039;&#039; As the inputs and outputs of this component will change as you begin to define what components you have and what their inputs/outputs are.&lt;br /&gt;
&lt;br /&gt;
For example, we may discover that it&#039;d be much easier to send a single &amp;quot;register read/write&amp;quot; line to the registers, and then use a decoder to translate bits from the instruction register into enable lines to exact fine control over the individual registers.&lt;br /&gt;
&lt;br /&gt;
Or, we may discover that our lookup table needs to take the state of our flag register into account when performing certain instructions. &lt;br /&gt;
&lt;br /&gt;
These are things we discover as we build, and as such, it&#039;s best to leave things like the control unit for last.&lt;br /&gt;
&lt;br /&gt;
=== Putting It All Together ===&lt;br /&gt;
Alright! You have all your components built, and they&#039;re all working in isolation. Pat yourself on the back.&lt;br /&gt;
&lt;br /&gt;
Now comes time to wire it all together.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t be afraid to make a mess. Remember, we haven&#039;t actually tested everything together as a whole yet. We have no idea if it will work, or if we overlooked something. Doing our fine-polishing work now if something isn&#039;t working properly will just be a waste of time and lead to frustration as we try to squeeze patches into what was once our finest masterpiece. &lt;br /&gt;
&lt;br /&gt;
This is also why we built a small portion of switch-based program memory. The smaller size means we don&#039;t invest too much time building a massive component that we just don&#039;t need right now, and making it switched based will eliminate the need to reprogram our program memory every time we want to conduct a test.&lt;br /&gt;
&lt;br /&gt;
You can even make multiple copies of your program memory and load different test programs on each one for a more thorough testing procedure.&lt;br /&gt;
&lt;br /&gt;
Lay out all your major components as best as you can. It helps to have them surround a large open area. Use buses to make the connections, and when you feel like everything is ready, load your program memory with a small test program, start the clock and see what happens.&lt;br /&gt;
&lt;br /&gt;
More than likely, things will not work as you had expected. Here&#039;s where you&#039;re going to need to slow down and troubleshoot things. Use the [[Tick|simulation controls]] to slow down, stop, and step the logic simulator. At this level, most issues you will experience are related to timing. Register inputs are not being held during the duration of a write. The ALU output is not stabilizing in time. Things like that. Though it is also possible that one of your components isn&#039;t working as it should, or its behavior needs to change in some way.&lt;br /&gt;
&lt;br /&gt;
This is why we made our components modular. If this does happen, take the defective component out, fix or rebuild it, and plug it back in.&lt;br /&gt;
&lt;br /&gt;
Be sure to run all of your test programs again after making a change. Sometimes changing one thing can fix one issue, and create another. Don&#039;t assume previous tests will pass just because they were passing before the change.&lt;br /&gt;
&lt;br /&gt;
=== Refine and Repeat ===&lt;br /&gt;
Eventually, after many cycles of testing, troubleshooting, and repairing, your rough prototype will be in working order.&lt;br /&gt;
&lt;br /&gt;
Congratulations! You just built your first computer!&lt;br /&gt;
&lt;br /&gt;
Now comes time to polish things up, if you want to.&lt;br /&gt;
&lt;br /&gt;
You can replace your test program memory modules with a full sized program memory module, if you want. Or you can begin the process of organizing your components. &lt;br /&gt;
&lt;br /&gt;
Compress them down, rearrange them, stack them in a neat package. Just be sure to do it one step at a time, and test after each change.&lt;br /&gt;
&lt;br /&gt;
When you&#039;re happy with how things look, you can call it done.&lt;br /&gt;
&lt;br /&gt;
Again, be sure to replace your test program memory modules with a full sized module, and for easy programming/using of your computer, consider adding a programmers interface where you can punch in programs and read the state of your registers. &lt;br /&gt;
&lt;br /&gt;
Whatever you do, make it yours.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=783</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=783"/>
		<updated>2025-10-17T21:36:51Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Minor update to phrasing and formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code, and each number is called an instruction or opcode. The computer will step through this list one instruction at a time, grabbing each instruction, interpreting it, and performing an action corresponding to that instruction. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
[[File:A schematic view of a very basic control unit.png|thumb|A lookup table takes in as its inputs the content of a step counter and an instruction register, and produces as its outputs various read, write, and function signals. On the clocks rising edge, the step counter is incremented. The lookup table immediately updates its outputs, reading from various components and sending function signals. The write signals do not get sent out though until the falling edge of the clock. As this diagram suggests, the lookup table is in control of its own instruction register, and has the ability to reset the step counter. The instruction register is updated at the beginning of every instruction sequence, and the step counter is reset at the end of every instruction sequence.]]&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the instruction fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and to a pulse for the write signals through the use of a [[Edge Detection|falling edge detector]], while the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory, and the first instruction in that section is primed to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a condition is met, like two numbers being equal or one being greater than the other. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation is key&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how programs will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Operands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
{{Todo|Flesh this section out more}}&lt;br /&gt;
Start by building your major components first. Build your program memory, working memory, ALU, registers, and control unit all on their own circuit board.&lt;br /&gt;
&lt;br /&gt;
This will make rearranging things easier.&lt;br /&gt;
&lt;br /&gt;
Use sockets to create interfaces. This will make changing and swapping out a component easier.&lt;br /&gt;
&lt;br /&gt;
It helps to build everything except the control unit first, then to build the control unit interface so you know what inputs and outputs your control unit needs to have.&lt;br /&gt;
&lt;br /&gt;
Test as you go, and be prepared to do some troubleshooting. Nothing ever works perfectly the first time.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=774</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=774"/>
		<updated>2025-10-12T15:13:56Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: /* Instruction Set */ spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code, and each number is called an instruction or opcode. The computer will step through this list one instruction at a time, grabbing each instruction, interpreting it, and performing an action corresponding to that instruction. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
[[File:A schematic view of a very basic control unit.png|thumb|A lookup table takes in as its inputs the content of a step counter and an instruction register, and produces as its outputs various read, write, and function signals. On the clocks rising edge, the step counter is incremented. The lookup table immediately updates its outputs, reading from various components and sending function signals. The write signals do not get sent out though until the falling edge of the clock. As this diagram suggests, the lookup table is in control of its own instruction register, and has the ability to reset the step counter. The instruction register is updated at the beginning of every instruction sequence, and the step counter is reset at the end of every instruction sequence.]]&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the instruction fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and produce a [[Edge Detection|rising edge]] for the write signals, and the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory, and the first instruction in that section is primed to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a condition is met, like two numbers being equal or one being greater than the other. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation&#039;&#039;&#039; is key.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how programs will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Operands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
{{Todo|Flesh this section out more}}&lt;br /&gt;
Start by building your major components first. Build your program memory, working memory, ALU, registers, and control unit all on their own circuit board.&lt;br /&gt;
&lt;br /&gt;
This will make rearranging things easier.&lt;br /&gt;
&lt;br /&gt;
Use sockets to create interfaces. This will make changing and swapping out a component easier.&lt;br /&gt;
&lt;br /&gt;
It helps to build everything except the control unit first, then to build the control unit interface so you know what inputs and outputs your control unit needs to have.&lt;br /&gt;
&lt;br /&gt;
Test as you go, and be prepared to do some troubleshooting. Nothing ever works perfectly the first time.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=773</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=773"/>
		<updated>2025-10-12T15:03:31Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: /* Hardware Theory */ Added a schematic diagram for a very basic control unit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code, and each number is called an instruction or opcode. The computer will step through this list one instruction at a time, grabbing each instruction, interpreting it, and performing an action corresponding to that instruction. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
[[File:A schematic view of a very basic control unit.png|thumb|A lookup table takes in as its inputs the content of a step counter and an instruction register, and produces as its outputs various read, write, and function signals. On the clocks rising edge, the step counter is incremented. The lookup table immediately updates its outputs, reading from various components and sending function signals. The write signals do not get sent out though until the falling edge of the clock. As this diagram suggests, the lookup table is in control of its own instruction register, and has the ability to reset the step counter. The instruction register is updated at the beginning of every instruction sequence, and the step counter is reset at the end of every instruction sequence.]]&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the instruction fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and produce a [[Edge Detection|rising edge]] for the write signals, and the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory, and the first instruction in that section is primed to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a condition is met, like two numbers being equal or one being greater than the other. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation&#039;&#039;&#039; is key.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how programs will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Opperands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
{{Todo|Flesh this section out more}}&lt;br /&gt;
Start by building your major components first. Build your program memory, working memory, ALU, registers, and control unit all on their own circuit board.&lt;br /&gt;
&lt;br /&gt;
This will make rearranging things easier.&lt;br /&gt;
&lt;br /&gt;
Use sockets to create interfaces. This will make changing and swapping out a component easier.&lt;br /&gt;
&lt;br /&gt;
It helps to build everything except the control unit first, then to build the control unit interface so you know what inputs and outputs your control unit needs to have.&lt;br /&gt;
&lt;br /&gt;
Test as you go, and be prepared to do some troubleshooting. Nothing ever works perfectly the first time.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=File:A_schematic_view_of_a_very_basic_control_unit.png&amp;diff=772</id>
		<title>File:A schematic view of a very basic control unit.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=File:A_schematic_view_of_a_very_basic_control_unit.png&amp;diff=772"/>
		<updated>2025-10-12T15:00:40Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A lookup table takes in as its inputs the content of a step counter and an instruction register, and produces as its outputs various read, write, and function signals. On the clocks rising edge, the step counter is incremented. The lookup table immediately updates its outputs, reading from various components and sending function signals. The write signals do not get sent out though until the falling edge of the clock.&lt;br /&gt;
&lt;br /&gt;
As this diagram suggests, the lookup table is in control of its own instruction register, and has the ability to reset the step counter. The instruction register is updated at the beginning of every instruction sequence, and the step counter is reset at the end of every instruction sequence.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=771</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=771"/>
		<updated>2025-10-12T14:27:41Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Updated the terminology used when talking about instructions. Referring to them as instructions or opcodes rather than just binary integers.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code, and each number is called an instruction or opcode. The computer will step through this list one instruction at a time, grabbing each instruction, interpreting it, and performing an action corresponding to that instruction. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the instruction fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and produce a [[Edge Detection|rising edge]] for the write signals, and the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory, and the first instruction in that section is primed to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a condition is met, like two numbers being equal or one being greater than the other. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation&#039;&#039;&#039; is key.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how programs will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Opperands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
{{Todo|Flesh this section out more}}&lt;br /&gt;
Start by building your major components first. Build your program memory, working memory, ALU, registers, and control unit all on their own circuit board.&lt;br /&gt;
&lt;br /&gt;
This will make rearranging things easier.&lt;br /&gt;
&lt;br /&gt;
Use sockets to create interfaces. This will make changing and swapping out a component easier.&lt;br /&gt;
&lt;br /&gt;
It helps to build everything except the control unit first, then to build the control unit interface so you know what inputs and outputs your control unit needs to have.&lt;br /&gt;
&lt;br /&gt;
Test as you go, and be prepared to do some troubleshooting. Nothing ever works perfectly the first time.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=770</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=770"/>
		<updated>2025-10-12T06:25:55Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: /* Instruction Set */ clearing up an ambiguous &amp;quot;it&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code. The computer will step through this list one number at a time, grabbing each number, interpreting it, and performing an action corresponding to that number. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the binary integer fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction integer and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and produce a [[Edge Detection|rising edge]] for the write signals, and the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a number comparison comes up not equal. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation&#039;&#039;&#039; is key.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how programs will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Opperands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
{{Todo|Flesh this section out more}}&lt;br /&gt;
Start by building your major components first. Build your program memory, working memory, ALU, registers, and control unit all on their own circuit board.&lt;br /&gt;
&lt;br /&gt;
This will make rearranging things easier.&lt;br /&gt;
&lt;br /&gt;
Use sockets to create interfaces. This will make changing and swapping out a component easier.&lt;br /&gt;
&lt;br /&gt;
It helps to build everything except the control unit first, then to build the control unit interface so you know what inputs and outputs your control unit needs to have.&lt;br /&gt;
&lt;br /&gt;
Test as you go, and be prepared to do some troubleshooting. Nothing ever works perfectly the first time.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=769</id>
		<title>Your First Computer</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Your_First_Computer&amp;diff=769"/>
		<updated>2025-10-12T06:20:58Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Major rewrite to focus more on teaching the reader what it takes to design and build your own computer, as well as teaching the reader a little more theory. With the build guide serving more as an example than instructions to follow.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This guide is for anyone who is interested in learning how computers work, and wants to learn by building a computer for themselves, but doesn&#039;t know where to start.&lt;br /&gt;
&lt;br /&gt;
This guide assumes the reader has a basic understanding of Logic Worlds [[Building mechanic|building mechanics]], and has some experience building some of the more intermediate components, such as [[Full Adder|adders]], [[Random-access memory|memory]], and [[decoder|decoders]]. As well as at least some understanding of the [[wikipedia:Binary_number|binary numbers system]].&lt;br /&gt;
&lt;br /&gt;
The first part of this guide will go over the hardware of a very basic computer system. This guide will not be covering things like text and image processing, internet browsing, operating systems, file systems, windows and graphical user interfaces and other systems generally associated with personal computers. These systems are all built using software, and covering them, as well as software in general, is an entire subject unto itself. This guide will only be focusing on creating hardware that can execute software. Furthermore, this guide will only be focusing on &#039;&#039;core&#039;&#039; hardware, the bare minimum required to run software. This guide will not be covering peripheral hardware such as screens, graphics processor units, storage devices, co-processors, or multi-core setups. Nor will this guide be covering the topic of source code compilation. These are all topics that require their own study and as such are outside the scope of this guide.&lt;br /&gt;
&lt;br /&gt;
The second part of this guide will be covering the process of designing your computer. It will bring up key details you should consider when planning your computer build, as well as providing a basic layout that you can use if you don&#039;t want to design everything from scratch yourself.&lt;br /&gt;
&lt;br /&gt;
The third part will of this guide will cover building your computer.&lt;br /&gt;
&lt;br /&gt;
== Hardware Theory ==&lt;br /&gt;
All computers, regardless of complexity, need at least these 4 components. Program memory typically made using [[ROM|read-only memory]], an [[Arithmetic logic unit|ALU]], working memory typically made using individual [[Register|registers]] and [[random-access memory]], and a [[Control Unit|control unit]].&lt;br /&gt;
[[File:Computer_Structure_diagram.png|right|thumb|300x300px|The structure of the computer in this article]]&lt;br /&gt;
Program memory is where the program to be executed is stored. It takes the form of a list of binary numbers called machine code. The computer will step through this list one number at a time, grabbing each number, interpreting it, and performing an action corresponding to that number. This process is referred to as the fetch-decode-execute cycle.&lt;br /&gt;
&lt;br /&gt;
Actions that a computer can perform can vary greatly, but two of the most common actions are moving data around, and performing operations using data.&lt;br /&gt;
&lt;br /&gt;
The ALU is what allows a computer to perform these operations, and working memory is where the data being operated on is stored.&lt;br /&gt;
&lt;br /&gt;
Moving data around may seem pointless at first, but often ALU&#039;s don&#039;t have direct access to working memory, but instead must use whatever is stored in more local registers. Data must therefore be juggled between working memory and registers in order to give the ALU access to the entire dataset. It&#039;s also useful for organizing data into larger data structures. &lt;br /&gt;
&lt;br /&gt;
While it might be hard to wrap your head around this at first, everything that computers do can mostly be reduced to these two operations: moving data around, and operating on data. How these two operations can be structured to do things like browse the internet or play games requires a study of software, and is thus outside the scope of this article. But under the hood, millions of these operations are happening at a rate of billions a second, and it&#039;s this size and speed that allows computers to perform much more complicated tasks.&lt;br /&gt;
&lt;br /&gt;
Coordinating these instruction fetches, data moves, and ALU operations is the control unit. It&#039;s job is to decode the binary integer fetched from program memory and decide what control signals to send out and when. &lt;br /&gt;
&lt;br /&gt;
While this module can get very complicated, the simplest control unit consists of a [[Lookup Table|lookup table]] that takes the current instruction integer and the value of a [[counter]] as a combined input, and produces all the read, write, and function signals the computer needs as an output. A clock is used to increment the counter, and produce a [[Edge Detection|rising edge]] for the write signals, and the table is configured to read from program memory and write to an instruction register when the counter is 0, then increment an instruction pointer register when the counter is 1. From there, the table can be configured to do different things depending on the value of the instruction register. The counter register is reset when the instruction is complete, and the fetch-decode-execute cycle repeats.&lt;br /&gt;
&lt;br /&gt;
On top of being able to move data around and perform operations, there is a third common type of action a computer can perform called a control flow instruction. These consist of instructions like jumping, conditional branching, calling and returning, and software interrupts. Though we&#039;ll only be focusing on jumping and conditional branching here. These all have one thing in common, and that is to break the linear sequence of the program. &lt;br /&gt;
&lt;br /&gt;
Normally, as part of the fetch-decode-execute cycle, the instruction pointer used to index the program memory is incremented after each instruction fetch. Setting up the next instruction in the list to be executed when the current instruction is complete. By writing a new value to the instruction pointer, we queue up a different section of the program memory to be executed next.&lt;br /&gt;
&lt;br /&gt;
This is often used to create infinite loops in your program, or finite loops if you use a conditional branch that resumes a normal execution sequence if a number comparison comes up not equal. &lt;br /&gt;
&lt;br /&gt;
These three action types are the minimum required to create a [[wikipedia:Turing completeness|turing complete]] computer - a computer that can calculate anything.&lt;br /&gt;
&lt;br /&gt;
== Planning A Computer ==&lt;br /&gt;
While you might be inclined to jump head-first into building, computers are complicated things, as the previous section shows. A little bit of forethought is required before you start building in order to help guide your building decisions. Otherwise you will end up with a computer that&#039;s too messy to modify, and if it ends up malfunctioning, it&#039;ll be too messy to troubleshoot as well. &#039;&#039;&#039;Documentation&#039;&#039;&#039; is key.&lt;br /&gt;
&lt;br /&gt;
Before you begin, think about what you want this computer to do. What ALU functions do you want it to have? What special instructions or special hardware? You&#039;ll also want to consider key details such as the width of your ALU, the width of your working memory and program memory, as well as the size of these memory modules, as this will determine the width of your address bus and indexing registers. &lt;br /&gt;
&lt;br /&gt;
=== Example Computer ===&lt;br /&gt;
Since you&#039;ll likely not know what to add, this section will provide for you a very basic plan for you to follow.&lt;br /&gt;
&lt;br /&gt;
==== Component Sizing ====&lt;br /&gt;
Our computer will be very basic. We&#039;ll be using an 8 bit ALU and 8 bit working memory. We can do a lot with 8 bits without needing to make the hardware too big.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll also have 256 addresses in our program memory, so an 8 bit address bus and 8 bit indexing register is in order, since 2^8 is 256. The width of the program memory is determined by our computers instruction set.&lt;br /&gt;
&lt;br /&gt;
==== Instruction Set ====&lt;br /&gt;
This is the most influential part of planning. This will not only dictate what your computer does, but also how it will be stored in program memory.&lt;br /&gt;
&lt;br /&gt;
You can design your own instruction set from scratch if you want something more complex. But for our instruction set, we will be adding 4 types of instructions: load immediate, operate, move, and jumping/branching. These will be organized with the prefixes &amp;lt;code&amp;gt;00&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;01&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;11&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
We will be squeezing our instructions into 8 bits, making our program memory 8 bits wide. With 2 of those bits being used as a prefix, that leaves 6 bits to be used as instruction arguments.&lt;br /&gt;
&lt;br /&gt;
Below is the instruction set we will be using:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
!Name&lt;br /&gt;
!Opcode (8 bits)&lt;br /&gt;
!Opperands&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|Immediate&lt;br /&gt;
|00 xxx xxx&lt;br /&gt;
|x: The immediate value.&lt;br /&gt;
|Puts a value given by x into register 0.&lt;br /&gt;
|-&lt;br /&gt;
|Add&lt;br /&gt;
|01 000___&lt;br /&gt;
|&lt;br /&gt;
|Adds the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Subtract&lt;br /&gt;
|01 001___&lt;br /&gt;
|&lt;br /&gt;
|Subtracts the value in register 1 from register 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|And&lt;br /&gt;
|01 010___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ANDs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Or&lt;br /&gt;
|01 011___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise ORs the values in register 1 and 2, and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|XOR&lt;br /&gt;
|01 100___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise XORs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Not&lt;br /&gt;
|01 101___&lt;br /&gt;
|&lt;br /&gt;
|Bit-wise NOTs the values in register 1 and 2 and puts the result in register 3.&lt;br /&gt;
|-&lt;br /&gt;
|Move&lt;br /&gt;
|10 xxx yyy&lt;br /&gt;
|x: The register to move data from. y: The register to move data to.&lt;br /&gt;
|Moves the data from register x into register y.&lt;br /&gt;
|-&lt;br /&gt;
|Test&lt;br /&gt;
|11 000___&lt;br /&gt;
|&lt;br /&gt;
|Tests the values in register 4 and 5 against each other, putting the result into the flags register.&lt;br /&gt;
|-&lt;br /&gt;
|Jump zero&lt;br /&gt;
|11 001___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the zero flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump carry &lt;br /&gt;
|11 010___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the carry flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump negative&lt;br /&gt;
|11 011___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the negative flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump equal&lt;br /&gt;
|11 100___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, if the equal flag is {{On}}.&lt;br /&gt;
|-&lt;br /&gt;
|Jump&lt;br /&gt;
|11 101___&lt;br /&gt;
|&lt;br /&gt;
|Jumps to the instruction in register 6, regardless of an flags.&lt;br /&gt;
|}&lt;br /&gt;
Notice that most instructions only use 3 of the 6 argument bits. Move immediate uses all 6, allowing the user to load an immediate value of 0-63, and move also uses all 6 to index 2 registers.&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
Since we have 3 bits available to index registers with, our computer will include 8 all-purpose registers. &lt;br /&gt;
&lt;br /&gt;
If you design your own computer, you will need to consider what registers to include, and what will they be used for.&lt;br /&gt;
&lt;br /&gt;
In our case, while all of our registers will be general purpose, meaning you can use them for whatever purpose you like, most of them will be used in a specific way for specific instructions. The registers and their purposes are as follows:&lt;br /&gt;
&lt;br /&gt;
* Register 0 - destination for immediate values&lt;br /&gt;
* Register 1 - source of one argument of an operation&lt;br /&gt;
* Register 2 - source of the other argument of an operation&lt;br /&gt;
* Register 3 - destination of the result of an operation&lt;br /&gt;
* Register 4 - source of one argument for a comparison&lt;br /&gt;
* Register 5 - source of the other argument for a comparison&lt;br /&gt;
* Register 6 - target address for a jump&lt;br /&gt;
* Register 7 - general purpose&lt;br /&gt;
&lt;br /&gt;
Note that the instruction pointer and instruction register are separate to these all-purpose registers, so our program will not be able to &#039;&#039;directly&#039;&#039; edit the values in these registers.&lt;br /&gt;
&lt;br /&gt;
Editing of these registers is done by the control unit either during the fetch-decode-execute cycle, or through the use of a jump instruction.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
If you decide to include conditional branching in your instruction set, you will need to decide what conditions (called flags) you want to check for and how you&#039;re going to check them.&lt;br /&gt;
&lt;br /&gt;
In our case, we will have the following 4 flags in our computer:&lt;br /&gt;
* Zero flag -  This flag will be {{On}} only if the first value from the last test instruction was equal to 0.&lt;br /&gt;
* Carry flag - This flag will be {{On}} only if that last add (or subtract) instruction carried/overflowed.&lt;br /&gt;
* Negative flag - This flag will be {{On}} only if the first value from the last test instruction was negative (had its most significant bit {{On}}).&lt;br /&gt;
* Equal flag - This flag will be {{On}} only if the values from the last test instruction were equal to each other.&lt;br /&gt;
We will also be storing the states of these flags in another register called a flag register. Allowing us to capture the state of these flags with one instruction (test) and use the state of these flags in another instruction (jump).&lt;br /&gt;
&lt;br /&gt;
You do not need to store the state of these flags in a register, or perform a test and branch in two separate instructions. You can perform your comparison and use the results immediately, if you want. Doing so will just require a more complex execution sequence, and possibly bigger instructions. &lt;br /&gt;
&lt;br /&gt;
==== Example Program ====&lt;br /&gt;
Putting everything together, we can use our instruction set to write a Fibonacci program:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;asm&amp;quot;&amp;gt;&lt;br /&gt;
; Initialise registers&lt;br /&gt;
Immediate 0 ; 00 000000&lt;br /&gt;
Move 2, 0   ; 10 000 010&lt;br /&gt;
Immediate 1 ; 00 000001&lt;br /&gt;
Move 1, 0   ; 10 000 001&lt;br /&gt;
;&lt;br /&gt;
; Main loop&lt;br /&gt;
Add         ; 01 000 ___&lt;br /&gt;
Move 2, 1   ; 10 001 010&lt;br /&gt;
Move 1, 3   ; 10 011 001&lt;br /&gt;
Immediate 4 ; 00 000100&lt;br /&gt;
Move 6, 0   ; 10 000 110&lt;br /&gt;
Jump        ; 11 101 ___&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Visualizing the process, we can imagine the first instruction being copied into the instruction register, the instruction pointer being incremented, then the value being copied from the instruction register to register 0.&lt;br /&gt;
&lt;br /&gt;
Then the step counter resets, and we begin again, fetching the instruction, incrementing the instruction counter, and moving the content of register 0 to register 2. Reset the step counter and on and on it goes.&lt;br /&gt;
&lt;br /&gt;
This is what our computer &#039;&#039;should&#039;&#039; do when it&#039;s complete.&lt;br /&gt;
&lt;br /&gt;
With the planning done, it&#039;s now time to move on to building.&lt;br /&gt;
&lt;br /&gt;
==Building the Computer==&lt;br /&gt;
{{Todo|Flesh this section out more}}&lt;br /&gt;
Start by building your major components first. Build your program memory, working memory, ALU, registers, and control unit all on their own circuit board.&lt;br /&gt;
&lt;br /&gt;
This will make rearranging things easier.&lt;br /&gt;
&lt;br /&gt;
Use sockets to create interfaces. This will make changing and swapping out a component easier.&lt;br /&gt;
&lt;br /&gt;
It helps to build everything except the control unit first, then to build the control unit interface so you know what inputs and outputs your control unit needs to have.&lt;br /&gt;
&lt;br /&gt;
Test as you go, and be prepared to do some troubleshooting. Nothing ever works perfectly the first time.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Talk:Edge_Detection&amp;diff=768</id>
		<title>Talk:Edge Detection</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Talk:Edge_Detection&amp;diff=768"/>
		<updated>2025-10-12T03:15:43Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: /* Edge detection circuit diagram output is not delayed */ Reply&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Edge detection circuit diagram output is not delayed ==&lt;br /&gt;
&lt;br /&gt;
@[[User:N00basaurus|N00basaurus]], in the circuit diagram you show (not lw), the output immediately becomes 1 as soon as the input becomes 1, whereas in logicworld the behaviour would be a bit different, in that the output would be delayed by one tick. I&#039;d propose delaying the output by 1 tick in the diagram to not &#039;bait&#039; people into thinking they could build such a circuit even though they cannot. [[User:GHXX|GHXX]] ([[User talk:GHXX|talk]]) 18:54, 7 October 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
:@[[User:GHXX|GHXX]] btw i made that diagram. I thought about it, but the article is about rising edge. The LW behavior is shown on the last screenshot.&lt;br /&gt;
:Maybe we can leave the screenshot alone for demonstration. And instead of the diagram make a drawing that just highlights the rising edge without considering ticks [[User:DjSapsan|DjSapsan]] ([[User talk:DjSapsan|talk]]) 15:54, 8 October 2025 (UTC)&lt;br /&gt;
::I added a small note explaining the diagram is simplified, and that there would be latency in a real circuit.&lt;br /&gt;
::Hopefully that&#039;ll act as a nice middle ground. [[User:N00basaurus|N00basaurus]] ([[User talk:N00basaurus|talk]]) 03:15, 12 October 2025 (UTC)&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Edge_Detection&amp;diff=767</id>
		<title>Edge Detection</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Edge_Detection&amp;diff=767"/>
		<updated>2025-10-12T03:14:34Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Added a note below the example signal diagram explaining the lack of a delay on the output.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Edge detection&#039;&#039;&#039; is the process of sending a signal at the moment a signal transitions.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;rising edge&#039;&#039;&#039; refers to the instant when a signal changes from &#039;&#039;off&#039;&#039; to &#039;&#039;on&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;falling edge&#039;&#039;&#039; refers to the instant when a signal changes from &#039;&#039;on&#039;&#039; to &#039;&#039;off&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Construction ==&lt;br /&gt;
[[File:Raising-edge-detector.png|thumb|right|alt=Raising edge detector|Raising edge detector]]&lt;br /&gt;
You can detect a rising edge by checking whether the input signal was &#039;&#039;off&#039;&#039; some number of [[Tick|ticks]] ago but is now &#039;&#039;on&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This can be done using an [[AND Gate]] and an [[Inverter]].  &lt;br /&gt;
Connect one input of the AND gate directly to your signal, and connect the other input through the inverter.&lt;br /&gt;
&lt;br /&gt;
When the input signal turns on, the direct input to the AND gate is immediately on. The inverter output, however, is delayed by 1 tick, so it remains &#039;&#039;on&#039;&#039; for one more tick.  &lt;br /&gt;
Since both inputs of the AND gate are &#039;&#039;on&#039;&#039;, it becomes marked for activation in the next tick.&lt;br /&gt;
&lt;br /&gt;
On the next tick, the AND gate turns &#039;&#039;on&#039;&#039; while the inverter output turns &#039;&#039;off&#039;&#039;. At this point, not all AND gate inputs are &#039;&#039;on&#039;&#039;, so it will be marked to turn &#039;&#039;off&#039;&#039; on the following tick.&lt;br /&gt;
&lt;br /&gt;
The pulse length is determined by the delay between the direct and inverted inputs of the AND gate.  &lt;br /&gt;
You can extend the pulse to 2 ticks using a [[Buffer]], or make it 2 ticks or longer with a [[Delayer]].&lt;br /&gt;
&lt;br /&gt;
== Example Signal Diagram ==&lt;br /&gt;
Below is an example timing diagram showing how a rising edge detector behaves:&lt;br /&gt;
* &#039;&#039;&#039;Input&#039;&#039;&#039; shows the original signal toggling between off and on.&lt;br /&gt;
* &#039;&#039;&#039;Output&#039;&#039;&#039; is the short pulse generated on each rising edge of the input signal.&lt;br /&gt;
&lt;br /&gt;
{{Binary signal&lt;br /&gt;
| signals=Input, Output&lt;br /&gt;
| signal1=000011110000111&lt;br /&gt;
| signal2=000010000000100&lt;br /&gt;
}}{{Note|NOTE: This diagram is simplified for education purposes. While this diagram suggests that the output turns on immediately when the input turns on, in reality, logic gates create a delay, and the output signal will lag the input signal by at least one tick.}}&lt;br /&gt;
&lt;br /&gt;
How it looks in the Logic World:&lt;br /&gt;
[[File:edge-oscillator.png|frame|center|alt=oscilloscope|Raising Edge on oscilloscope ]]&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=User:N00basaurus&amp;diff=754</id>
		<title>User:N00basaurus</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=User:N00basaurus&amp;diff=754"/>
		<updated>2025-10-06T06:46:33Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: I made a me&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I&#039;d prefer to format it as n00b_asaurus, but MediaWiki doesn&#039;t like that ¯\_(ツ)_/¯&lt;br /&gt;
&lt;br /&gt;
Anyway, hello, I&#039;m n00b_asaurus - tinkerer, home-brew computer enthusiast, YouTuber... sorta.. &lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/@n00b_asaurus My YouTube Channel].&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve been captivated by the idea of building your own CPU from scratch, I&#039;ve got a playlist on my channel that might help out.&lt;br /&gt;
&lt;br /&gt;
Yes, it was technically made to help guide you through making a &#039;&#039;redstone&#039;&#039; computer, but the videos discussing topics are, for the most part, implementation-agnostic. So just skip the stuff involving redstone and it&#039;ll work all the same :P&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Programmable_Logic_Array&amp;diff=753</id>
		<title>Programmable Logic Array</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Programmable_Logic_Array&amp;diff=753"/>
		<updated>2025-10-06T06:32:42Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Created a rough outline for a Programmable Logic Array page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A Programmable Logic Array, or PLA, is a combination logic component that allows you to encode any boolean expression into a simple, repeating circuit, provided the boolean expression is rearranged as a [[wikipedia:Disjunctive_normal_form|sum-of-products]] form. &lt;br /&gt;
&lt;br /&gt;
{{Todo|Add a basic PLA example, explain what it&#039;s doing}}&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Finite_State_Machine&amp;diff=752</id>
		<title>Finite State Machine</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Finite_State_Machine&amp;diff=752"/>
		<updated>2025-10-06T06:24:21Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Created a rough outline of a Finite State Machine page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
{{Todo|The whole page}}&lt;br /&gt;
&lt;br /&gt;
A Finite State Machine is a circuit that will produce a sequence of states and output signals depending on input conditions and a state graph.&lt;br /&gt;
&lt;br /&gt;
It&#039;s constructed using either a [[ROM]], or a [[Programmable Logic Array]], by taking some or all of the components outputs and connecting them to some or all of its inputs through a [[Register]].&lt;br /&gt;
&lt;br /&gt;
The component can then be used to create mappings of one list of states to another.&lt;br /&gt;
&lt;br /&gt;
For example, you could map the states &amp;lt;code&amp;gt;1 to 2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;2 to 3&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;3 to 5&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;5 to 8&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;8 to 13&amp;lt;/code&amp;gt;, and as you pulse the register, you will see the sequence &amp;lt;code&amp;gt;1, 2, 3, 5, 8, 13&amp;lt;/code&amp;gt; appear. &lt;br /&gt;
&lt;br /&gt;
Where state machines become really powerful though is when you map &amp;lt;code&amp;gt;13 to 1&amp;lt;/code&amp;gt; , doing so creates a loop in the graph, and allows the sequence to repeat indefinitely.&lt;br /&gt;
&lt;br /&gt;
You can have extra inputs to act as flags to check, allowing you to create conditional branches.&lt;br /&gt;
&lt;br /&gt;
For example, you could map &amp;lt;code&amp;gt;3 to 5&amp;lt;/code&amp;gt; if the input &amp;lt;code&amp;gt;fib&amp;lt;/code&amp;gt; was on, and you could map &amp;lt;code&amp;gt;3 to 4&amp;lt;/code&amp;gt; if the &amp;lt;code&amp;gt;fib&amp;lt;/code&amp;gt; input was off. &lt;br /&gt;
&lt;br /&gt;
{{Todo|Add details for how this condition check is actually implemented}}{{Todo|Describe how multiple condition checks in the same state are handled}}&lt;br /&gt;
&lt;br /&gt;
In cases where an input is not checked, but is actually ignored, you&#039;ll need to implement the same state mapping twice, once for if the condition is on, and again for if the condition is off, in order for the transition from state to state to happen regardless of the conditions state.&lt;br /&gt;
&lt;br /&gt;
This is only true if you&#039;re using a [[ROM]] to represent your state graph. If you are using a [[Programmable Logic Array]], you can just not connect the input.&lt;br /&gt;
&lt;br /&gt;
A state machine can also produce extra outputs in each state.&lt;br /&gt;
&lt;br /&gt;
This can be done by connecting a [[Lookup Table]] to the output of the state register, and mapping each valid state to a combination of outputs. This setup is referred to as a [[wikipedia:Moore_machine|Moore machine]].&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can give the state machine more outputs and synchronize them with another register. This allows the state machine to pick the next combination of outputs at the transition. This setup is referred to as a [[wikipedia:Mealy_machine|Mealy machine]].  &lt;br /&gt;
&lt;br /&gt;
{{Todo|Describe the advantages each machine has}}&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Edge_Detection&amp;diff=751</id>
		<title>Edge Detection</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Edge_Detection&amp;diff=751"/>
		<updated>2025-10-06T05:59:51Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Added Edge Detection page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Edge detection is the action of sending a signal at the edge of a signals transition.&lt;br /&gt;
&lt;br /&gt;
Rising edge refers to the instance in time when a signal &#039;&#039;rises&#039;&#039; from off to on.&lt;br /&gt;
&lt;br /&gt;
Falling edge refers to the instance in time when a signal &#039;&#039;falls&#039;&#039; from on to off.&lt;br /&gt;
&lt;br /&gt;
== Circuit Implementation ==&lt;br /&gt;
{{Todo|Add pictures}}&lt;br /&gt;
You can detect a rising edge by looking for an instance in time when the input signal was off some number of [[Tick|ticks]] ago, but is now on.&lt;br /&gt;
&lt;br /&gt;
You can do this with an [[AND Gate]] and an [[Inverter]]. &lt;br /&gt;
&lt;br /&gt;
Connecting one input of the AND gate to your input signal, and another input to your input signal through an inverter.&lt;br /&gt;
&lt;br /&gt;
When you turn the input signal on, the AND gates input will turn on instantly. Since the inverter has a 1 tick delay before its output is updated, its output is still on, and so is the other input of the AND gate, marking the AND gate to be updated in the next tick.&lt;br /&gt;
&lt;br /&gt;
On the next tick, the AND gate turns on, and the inverter turns off. The AND gates inputs are no longer all on, and the AND gate is marked to be turned off in the next tick.&lt;br /&gt;
&lt;br /&gt;
The length of this pulse is determined by the delay between the input signal and the inverted input of the AND gate. You can make the pulse length 2 ticks long by introducing a [[Buffer]], or you can make it 2 ticks or more using a [[Delayer]].&lt;br /&gt;
{{Todo|Add timing diagram}}&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Control_Unit&amp;diff=750</id>
		<title>Control Unit</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Control_Unit&amp;diff=750"/>
		<updated>2025-10-06T05:47:33Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Created a rough outline for a Control Unit page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The whole page}}&lt;br /&gt;
&lt;br /&gt;
A control unit is a composite component built for the express purpose of controlling another circuit. &lt;br /&gt;
&lt;br /&gt;
In general, a control unit can do 2 things:&lt;br /&gt;
&lt;br /&gt;
# provide a secured interface that prevents illegal control signal combinations from being generated.&lt;br /&gt;
# produce a sequence of control signal combinations over time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the context of computers, a control unit focuses more on this second behavior.&lt;br /&gt;
&lt;br /&gt;
== Computer Control Units Abstract ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All computers, no matter how complicated, are built on a single action: transfer state from one place to another. Sequence different forms of this action in different ways and in different combinations, and you can perform any computation.&lt;br /&gt;
&lt;br /&gt;
All transfers require 1 read signal and 1 write signal. If you want to transfer the state of one [[Register]] to another, you would need to produce a signal that first enabled the read signal on one register, then enabled the write signal on the other.&lt;br /&gt;
&lt;br /&gt;
A control unit is what would produce those signals in that order.&lt;br /&gt;
&lt;br /&gt;
Likewise, if you wish to perform more state transfers, modify the state at some point, and use it to do something like activate a [[Display]], a control unit would be used to produce those signals in that order too.&lt;br /&gt;
&lt;br /&gt;
Computer control units can often also produce different sequences of control signals depending on its inputs.&lt;br /&gt;
&lt;br /&gt;
These inputs are usually connected to various parts of the computer such as the [[Instruction Register]], [[Status Register]], or other flag signals around the system.&lt;br /&gt;
&lt;br /&gt;
This set up allows the control unit to &amp;quot;execute an instruction&amp;quot; by looking at the instruction register and modifying the sequence of control signals accordingly.&lt;br /&gt;
&lt;br /&gt;
A control unit can also modify the state of an instruction register by bringing a new state in from somewhere else. A sequence often referred to as an instruction fetch.&lt;br /&gt;
&lt;br /&gt;
In computers, every control unit will include in its sequences of operations a special sequence that first performs an instruction fetch, then queries the instruction register to determine what sequence it should produce next.&lt;br /&gt;
&lt;br /&gt;
This process is referred to as the fetch, decode, execute cycle.&lt;br /&gt;
&lt;br /&gt;
Typically, timing is regulated through the use of a [[Clock]].&lt;br /&gt;
&lt;br /&gt;
== Computer Control Units Implementation ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For [[Pipeline Computers]], the sequence of control signals are produced with a chain of shift registers. Each one passing its state to the next one at the [[Edge Detection|rising edge]] of the clock.&lt;br /&gt;
&lt;br /&gt;
Each register represents one stage in the pipeline, and each stage produces its control signals by passing the stages state into a [[Decoder]], [[Lookup Table]], [[Programmable Logic Array]], or [[ROM]].&lt;br /&gt;
&lt;br /&gt;
As new states are shifted into the stage, the control signals for that stage will change accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For all other computers, a more complex solution is often in order. &lt;br /&gt;
&lt;br /&gt;
While you can get away with using a [[Counter]] and a [[ROM]], more complex sequences involving looping sequences and conditional checks is more often achieved with the use of a [[Finite State Machine]].&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Decoder&amp;diff=749</id>
		<title>Decoder</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Decoder&amp;diff=749"/>
		<updated>2025-10-06T05:09:19Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Changed the control unit link from CU to Control Unit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;; &#039;&#039;&#039;Decoder&#039;&#039;&#039;&lt;br /&gt;
: In &#039;&#039;Logic World&#039;&#039;, a &#039;&#039;&#039;Decoder&#039;&#039;&#039; is a circuit that takes a binary input and activates one specific output bit corresponding to that input.&lt;br /&gt;
: It is commonly used to select one element out of many, for example a cell in memory.&lt;br /&gt;
: The Decoder always outputs a single bit.&lt;br /&gt;
: Effectively it&#039;s translating a binary value into a [[wikipedia:Unary_numeral_system|unary]] value.&lt;br /&gt;
: [[File:4bit-decoder.png|alt=4-bit decoder. Input on the left is 1110. The 14th output bit on the right is activated.|thumb|4-bit decoder. Input on the left is 1110. The 14th output bit on the right is activated.]]&lt;br /&gt;
&lt;br /&gt;
== Construction ==&lt;br /&gt;
&lt;br /&gt;
A Decoder is one of the simplest circuits to build.  &lt;br /&gt;
First, determine how many bits you need.  &lt;br /&gt;
The number of output bits from input bits is given by:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;o = 2^i&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And vice versa:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = \log_2(o)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, if you want 256 outputs, you will need a decoder with 8 input bits.  &lt;br /&gt;
Each output has a specific pattern of {{on}} and {{off}} bits coming from the input. The circuit is basically a number of [[AND Gate|AND]] gates for each possible combination.&lt;br /&gt;
&lt;br /&gt;
Here are the steps to build it:&lt;br /&gt;
&lt;br /&gt;
* Place a row of input items.  &lt;br /&gt;
* Connect each input bit to both a [[Inverter|NOT]] gate and a [[Buffer]].The NOT gate is required to have the inverted value and the Buffer is required to match the delay with the NOT gate.  &lt;br /&gt;
* Place a row of NOT gates to serve as the outputs.  &lt;br /&gt;
* Go through each output NOT gate and connect them to the corresponding inputs (normal or inverted) to match its binary value. For example, the output corresponding to number 12 (binary 1100) should receive the following binary values:&lt;br /&gt;
** 1st bit – normal  &lt;br /&gt;
** 2nd bit – normal  &lt;br /&gt;
** 3rd bit – inverted  &lt;br /&gt;
** 4th bit – inverted  &lt;br /&gt;
:and so on for each value.&lt;br /&gt;
&lt;br /&gt;
You can design a decoder in different ways. If you are building one for the first time, you may want to explicitly place each wire and gate to match the real electronic analog or to be visually understandable.&lt;br /&gt;
&lt;br /&gt;
When you become more experienced, you can skip unnecessary details and make it as simple as the screenshot above demonstrates. This design, optimized for speed and size, uses the trick of connecting wires from &#039;&#039;&#039;output&#039;&#039;&#039; pins directly to the required items, avoiding additional buffers and wire routing. On the screenshot below you can see the side view and how it allows it to make it compact.  &lt;br /&gt;
&lt;br /&gt;
[[File:Decoder-side.png|thumb|center|alt=Side view of the decoder|Side view of the decoder]]&lt;br /&gt;
&lt;br /&gt;
== Speed ==&lt;br /&gt;
&lt;br /&gt;
The compact design above computes the output in 2 ticks.&lt;br /&gt;
&lt;br /&gt;
== Part of ==&lt;br /&gt;
&lt;br /&gt;
Decoders are used primarily as part of the following circuits:&lt;br /&gt;
&lt;br /&gt;
[[RAM]], [[ROM]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[Control Unit]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[Multiplexer]], [[Demultiplexer]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[Lookup_Table]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Encoder]]&lt;br /&gt;
* [[Lookup Table]]&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Tick&amp;diff=748</id>
		<title>Tick</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Tick&amp;diff=748"/>
		<updated>2025-10-06T05:00:56Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Updated the summary to go into detail about wires transmitting signals in the same tick&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;tick&#039;&#039;&#039; refers to one step of the game&#039;s logic simulation.&lt;br /&gt;
&lt;br /&gt;
Most [[component|components]] take one tick to update the state of their output after their input changes state. Thus, on some ticks, the state of a component&#039;s outputs will be &amp;quot;wrong&amp;quot; compared to the state of its inputs.&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to note that only components introduce a tick delay. Signals traveling through [[Wiring]] are instant, no matter how long the wire is.&lt;br /&gt;
&lt;br /&gt;
This is also true even if the wire sends its signal through a [[Peg]] or a [[Socket]]. &lt;br /&gt;
&lt;br /&gt;
If the state of a components output is updated, the connected inputs of other components will be updated in the same tick.&lt;br /&gt;
[[File:And gate activation delay.png|thumb|A demonstration of two AND gates being activated. The top AND gate has both its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom AND gate has had both its inputs active for at least 1 tick, and its output is therefore active.]]&lt;br /&gt;
&lt;br /&gt;
[[File:XOR gate activation delay.png|thumb|A demonstration of two XOR gates being activated. The top XOR gate has one of its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom XOR gate has had one of its inputs active for at least 1 tick, and its output is therefore active.]]&lt;br /&gt;
&lt;br /&gt;
== Simulation Speed ==&lt;br /&gt;
While every components state is calculated and updated at each tick, the number of ticks that occur in a second can be adjusted from as low as 1 tick per second (tps) all the way up to 10,000 tps.&lt;br /&gt;
&lt;br /&gt;
Adjustments can be made by opening up the simulation controls menu. By default, this is the {{keys|F9}} button.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the simulation can be paused entirely, and stepped 1 tick at a time from the control menu. Useful for debugging circuits that don&#039;t behave like you&#039;d expect.&lt;br /&gt;
&lt;br /&gt;
You can also pause/resume the simulation or step the simulation using hotkeys on your keyboard.&lt;br /&gt;
&lt;br /&gt;
By default, this is {{keys|F10}} to pause/resume the simulation, and {{keys|shift+F10}} to step the simulation when paused.&lt;br /&gt;
{{Todo|Add screenshots of the simulation controls menu}}&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Tick&amp;diff=657</id>
		<title>Tick</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Tick&amp;diff=657"/>
		<updated>2025-09-10T20:16:55Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Added a paragraph on controlling the simulation speed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;tick&#039;&#039;&#039; refers to one step of the game&#039;s logic simulation.&lt;br /&gt;
&lt;br /&gt;
Most [[component|components]] take one tick to update the state of their output after their input changes state. Thus, on some ticks, the state of a component&#039;s outputs will be &amp;quot;wrong&amp;quot; compared to the state of its inputs.&lt;br /&gt;
{{Todo|Add more general information about timing}}[[File:And gate activation delay.png|thumb|A demonstration of two AND gates being activated. The top AND gate has both its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom AND gate has had both its inputs active for at least 1 tick, and its output is therefore active.]]&lt;br /&gt;
&lt;br /&gt;
[[File:XOR gate activation delay.png|thumb|A demonstration of two XOR gates being activated. The top XOR gate has one of its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom XOR gate has had one of its inputs active for at least 1 tick, and its output is therefore active.]]&lt;br /&gt;
&lt;br /&gt;
== Simulation Speed ==&lt;br /&gt;
While every components state is calculated and updated at each tick, the number of ticks that occur in a second can be adjusted from as low as 1 tick per second (tps) all the way up to 10,000 tps.&lt;br /&gt;
&lt;br /&gt;
Adjustments can be made by opening up the simulation controls menu. By default, this is the &amp;lt;code&amp;gt;f9&amp;lt;/code&amp;gt; button.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, the simulation can be paused entirely, and stepped 1 tick at a time from the control menu. Useful for debugging circuits that don&#039;t behave like you&#039;d expect.&lt;br /&gt;
&lt;br /&gt;
You can also pause/resume the simulation or step the simulation using hotkeys on your keyboard.&lt;br /&gt;
&lt;br /&gt;
By default, this is &amp;lt;code&amp;gt;f10&amp;lt;/code&amp;gt; to pause/resume the simulation, and &amp;lt;code&amp;gt;shift+f10&amp;lt;/code&amp;gt; to step the simulation when paused.&lt;br /&gt;
{{Todo|Add screenshots of the simulation controls menu}}&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=Optimization&amp;diff=656</id>
		<title>Optimization</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=Optimization&amp;diff=656"/>
		<updated>2025-09-10T20:06:35Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Linked the speed section to the tick article&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Optimization ==&lt;br /&gt;
&lt;br /&gt;
There are countless ways to build any given circuit. Different designs will have different characteristics.&lt;br /&gt;
This article will help you design circuits optimized for specific purposes.&lt;br /&gt;
You can mix and match different techniques to achieve the results you want.&lt;br /&gt;
&lt;br /&gt;
So, when designing a circuit you need to decide what you want to optimize for. Let&#039;s break down each optimization one by one.&lt;br /&gt;
&lt;br /&gt;
Please note that, while you may be familiar with real electronics or programming, in &#039;&#039;Logic World&#039;&#039; there are certain features that are not obvious at first.&lt;br /&gt;
These features can be used to your advantage when optimizing circuits.&lt;br /&gt;
&lt;br /&gt;
== Speed ==&lt;br /&gt;
Speed is the time it takes for a signal to propagate through a circuit.&lt;br /&gt;
In Logic World, most gates have a delay of 1 [[tick]]. The more sequential gates you have, the slower the circuit will be.&lt;br /&gt;
When you have cycles or feedback in your circuit, speed becomes even more critical.&lt;br /&gt;
In complex circuits, you can measure the speed by counting ticks from the first activation of the input to the &#039;&#039;final&#039;&#039; state on the output.&lt;br /&gt;
&lt;br /&gt;
There are three major ways to cut the delays:&lt;br /&gt;
&lt;br /&gt;
*Remove unnecessary gates&lt;br /&gt;
*Use fast gates, such as [[Relay|Relays]] or [[Fast Buffer|Fast Buffers]]&lt;br /&gt;
*Mods&lt;br /&gt;
&lt;br /&gt;
Let&#039;s break it down further.&lt;br /&gt;
&lt;br /&gt;
==== Remove unnecessary gates ====&lt;br /&gt;
To start, the most newbie-friendly way to optimize gates is to just remove repetitions.&lt;br /&gt;
For example, if you have a NOT gate followed by another NOT gate, you can just remove both of them! The same applies to other gates. Instead of placing many AND gates following one after another, make a single big AND gate with multiple inputs.&lt;br /&gt;
&lt;br /&gt;
Now moving on to a more complex topic.&lt;br /&gt;
The first big distinction of &#039;&#039;Logic World&#039;&#039; from real life is that there are no OR gates! Instead, wires are just connected together.&lt;br /&gt;
This game design already removes some gates.&lt;br /&gt;
But the OR operation is still a necessary part of logic, even if implicitly. We still need to connect wires together.&lt;br /&gt;
The problem is that the wrong way may either introduce delays or lead to backpropagation.&lt;br /&gt;
{{Backpropagation}}&lt;br /&gt;
A solution to this by using fast gates will be discussed later. Here I will show a hacky way: connecting multiple wires together from &#039;&#039;&#039;output&#039;&#039;&#039; pins.&lt;br /&gt;
You may notice that in the screenshot on the right, the &#039;&#039;&#039;output&#039;&#039;&#039; pin from the button is connected to a lamp and then the lamp is connected to another gate.&lt;br /&gt;
In general, if a wire is connected between normal pins, it will allow the signal to travel everywhere. The exception is the &#039;&#039;&#039;output&#039;&#039;&#039; pin.&lt;br /&gt;
Wires &#039;&#039;coming&#039;&#039; out of &#039;&#039;&#039;output&#039;&#039;&#039; pins do not conduct signals backward. To use it, you need to connect all the affected items to all the related &#039;&#039;&#039;output&#039;&#039;&#039; pins individually. You can always find the output pin by its big fat size. The next screenshot below shows the correct way.&lt;br /&gt;
[[File:Fix-backprop.png|thumb|right|alt=Everything is connected from output pins|Everything is connected from output pins]]&lt;br /&gt;
If you do it correctly, you won&#039;t need additional gates to stop backpropagation.&lt;br /&gt;
The drawback is that it requires a direct path from all the inputs to the outputs.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Also, in complex circuits it becomes hard to see individual wires.&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
Expand to see an example&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Toomanywires.png|center|frameless|alt=toomanywires|toomanywires]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Moving on to other techniques to remove unnecessary gates.&lt;br /&gt;
This part will require some logic understanding. In many cases, you can improve the circuit by just using a different formula than the one you initially thought of.&lt;br /&gt;
And remember the lack of OR gates, some circuit variations are simply simpler.&lt;br /&gt;
For example, you need &amp;lt;math&amp;gt;(B \land A) \lor (B \land C)&amp;lt;/math&amp;gt;, this will require 2 explicit AND gates. But you can rewrite it as &amp;lt;math&amp;gt;B \land (A \lor C)&amp;lt;/math&amp;gt;.&lt;br /&gt;
Notice in the screenshot that a different formulation leads to a smaller circuit.&lt;br /&gt;
[[File:ABC-circuit.png|thumb|On the left - two explicit gates. On the right - a simple refactoring removes one gate]]&lt;br /&gt;
Although this simple example doesn&#039;t improve speed (because it&#039;s not sequential), this lesson still shows that you can remove unnecessary gates.&lt;br /&gt;
&lt;br /&gt;
The most useful thing to know here is [[wikipedia:De Morgan&#039;s laws|De Morgan&#039;s laws]]. They allow you to rewrite common formulas from one form to another.&lt;br /&gt;
There could be other examples, but just remember, this part will become easier with experience and overall logic understanding.&lt;br /&gt;
&lt;br /&gt;
A bit more complex technique is to use negations. This often requires a complete rethinking of the design.&lt;br /&gt;
But when done correctly, it can lead to a significant reduction in the number of gates, especially in very big circuits.&lt;br /&gt;
You need to stop thinking in terms of {{On}}/{{Off}} to enable/disable something.&lt;br /&gt;
For example, you can use {{Off}} to indicate the &#039;&#039;&#039;enabled&#039;&#039;&#039; state in some part. This will already remove a NOT gate from the design.&lt;br /&gt;
{{todo|add specific examples with negated logic}}&lt;br /&gt;
&lt;br /&gt;
==== Use fast gates ====&lt;br /&gt;
In &#039;&#039;Logic World&#039;&#039; there are so-called fast gates, such as [[Relay|relays]] or [[Fast Buffer|fast buffers]].&lt;br /&gt;
These gates don&#039;t have a delay to propagate the signal. This is far from real life, but if you learn to use them correctly, they can significantly speed up your circuits.&lt;br /&gt;
Let&#039;s break them down.&lt;br /&gt;
*[[Fast Buffer]] is a simple gate that just propagates the signal from input to output without any delay. The main purpose is to avoid backpropagation. It&#039;s also useful to route wires neatly.&lt;br /&gt;
:The drawback is that it&#039;s very bulky, increasing the circuit size significantly.&lt;br /&gt;
*[[Relay]] is a gate that also propagates the signal without delay, but only if enabled. It&#039;s different from Fast Buffers in two major ways:&lt;br /&gt;
** It propagates signals both ways, so it can&#039;t be used to avoid backpropagation.&lt;br /&gt;
**Enabling it takes 1 tick, but after it&#039;s enabled, it will propagate the signal without delay.&lt;br /&gt;
While fast gates increase the overall number of gates, they remove delays.&lt;br /&gt;
So you can use Fast Buffer to replace regular [[Buffer|buffers]] and&lt;br /&gt;
Relays to replace [[AND Gate|AND gates]].&lt;br /&gt;
But remember, sometimes you still need regular Buffers to synchronize signals. Otherwise, signals coming from fast gates may not match with signals from other gates.&lt;br /&gt;
Please note, that extensive usage of fast gates may lead to slower performance, as all connected gates updated all at once each tick.&lt;br /&gt;
&lt;br /&gt;
A notable example of a circuit with fast gates is an [[ICA|Instant Carry Adder (&#039;&#039;&#039;ICA&#039;&#039;&#039;)]].&lt;br /&gt;
&lt;br /&gt;
==== Mods ====&lt;br /&gt;
There are many mods that add complex circuits as single black boxes, and they usually take 1 tick to perform the function.&lt;br /&gt;
Examples: CPUs, RAMs, Displays, Keyboards, Network devices, Decoders, Buffers, etc.&lt;br /&gt;
&lt;br /&gt;
== Performance ==&lt;br /&gt;
Even if you design a very fast circuit, it may be too big for the game to handle, especially on high tickrates, leading to lags or slower execution overall.&lt;br /&gt;
You may want to trade off some circuit speed for better simulation performance.&lt;br /&gt;
Usually it may be done by splitting the circuit into smaller parts that are activated only when needed.&lt;br /&gt;
The heaviest parts are usually decoders (by themselves or with RAM), HDDs, LUTs.&lt;br /&gt;
Let&#039;s say you have a huge decoder with 1024 outputs. In a naive design, it will activate all the gates at once, leading to a big lag spike.&lt;br /&gt;
How do you optimize it?&lt;br /&gt;
You can do it by iteratively converging on the output, using the divide and conquer approach.&lt;br /&gt;
For example, split the computation into two iterations:&lt;br /&gt;
&lt;br /&gt;
#First iteration: a 3-bit decoder, effectively multiplexing the input between 8x parts.&lt;br /&gt;
#Second iteration: only one active 7-bit decoder among 8 parts, with 128 outputs.&lt;br /&gt;
&lt;br /&gt;
You can divide it however you want, the main idea is to reduce the number of gates activated at once.&lt;br /&gt;
&lt;br /&gt;
Next advice is especially important on servers with multiple people. Make sure all your circuits can halt. Even if it&#039;s small timer - add a switch. If you are not using a circuit, turn it off.&lt;br /&gt;
&lt;br /&gt;
{{todo|expand on the topic}}&lt;br /&gt;
&lt;br /&gt;
== Size ==&lt;br /&gt;
If you focus only on speed or performance, you may end up with a huge circuit that is hard to build and manage.&lt;br /&gt;
Sometimes you need to optimize purely for size.&lt;br /&gt;
Minimizing the size will make you avoid bulky fast gates, introduce cycles, remove parallelism, etc., often leading to slower circuits. But for some designs it may still be worth it.&lt;br /&gt;
We will not be focusing on designing a logic with a smaller footprint. Instead, here are &#039;&#039;structural&#039;&#039; tips that some people find useful:&lt;br /&gt;
&lt;br /&gt;
*Use &amp;quot;round&amp;quot; or &amp;quot;hollow&amp;quot; designs.&lt;br /&gt;
*Use 1-tile stackable parts.&lt;br /&gt;
These &amp;quot;round&amp;quot; or &amp;quot;hollow&amp;quot; designs are made by placing supporting structures at the edges or against each other and putting logic and wiring in the middle of it. Always remember, &#039;&#039;Logic world&#039;&#039; is 3D!&lt;br /&gt;
This approach is extremely useful for wiring, as it allows you connect &#039;&#039;&#039;everything to everything&#039;&#039;&#039;.&lt;br /&gt;
Examples:&lt;br /&gt;
[[File:Compact-design1.png|frame|center|alt=Logic gates are only in 4 corners, all wires are inside |Logic gates are only in 4 corners, all wires are inside]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Compact-design2.png|frame|center|alt=Logic gates are against each other|Logic gates are against each other]]&lt;br /&gt;
&lt;br /&gt;
{{todo|expand on the topic}}&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=AND_Gate&amp;diff=90</id>
		<title>AND Gate</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=AND_Gate&amp;diff=90"/>
		<updated>2025-09-06T22:55:05Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Updated sections to follow component standards&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MHG.AndGate 512x512.png|thumb|A single AND gate]]&lt;br /&gt;
The &#039;&#039;&#039;AND gate&#039;&#039;&#039; is a basic digital logic component who&#039;s output will be active if &#039;&#039;&#039;all&#039;&#039;&#039; its inputs are active.&lt;br /&gt;
&lt;br /&gt;
For a 2 input AND gate, it is 1 tile wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.&lt;br /&gt;
&lt;br /&gt;
An AND gate with 2 inputs will demonstrate the following behavior:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+AND Gate Truth Table&lt;br /&gt;
!INPUT A&lt;br /&gt;
!INPUT B&lt;br /&gt;
!OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
|LOW&lt;br /&gt;
|LOW&lt;br /&gt;
|LOW&lt;br /&gt;
|-&lt;br /&gt;
|LOW&lt;br /&gt;
|HIGH&lt;br /&gt;
|LOW&lt;br /&gt;
|-&lt;br /&gt;
|HIGH&lt;br /&gt;
|LOW&lt;br /&gt;
|LOW&lt;br /&gt;
|-&lt;br /&gt;
|HIGH&lt;br /&gt;
|HIGH&lt;br /&gt;
|HIGH&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Timing ==&lt;br /&gt;
The AND gate&#039;s output will only be active if all of its inputs are active. This is true no matter how many inputs the AND gate has.&lt;br /&gt;
[[File:And gate activation delay.png|thumb|A demonstration of two AND gates being activated. The top AND gate has both its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom AND gate has had both its inputs active for at least 1 tick, and its output is therefore active.]]&lt;br /&gt;
The AND gate has a latency of 1 tick, so in the instance when all inputs are active, the output will become active 1 tick later. As demonstrated in the example on the right.&lt;br /&gt;
&lt;br /&gt;
== Configurability ==&lt;br /&gt;
Pressing the edit button on an AND gate allows you to change the number of inputs it has. You can select 2, 3, or 4 inputs. &lt;br /&gt;
&lt;br /&gt;
Changing the number of inputs on an AND gate does not change its latency, but it does make the components bigger, with their width changing from 1 tile wide with 2 inputs to a little less than 2 tiles wide with 3 inputs, to 2 tiles wide with 4 inputs.&lt;br /&gt;
&lt;br /&gt;
Note that when an AND gate has 3 inputs, while its width is less than 2 tiles, the component is centered on a tile, causing it to require 3 tiles of width.&lt;br /&gt;
&lt;br /&gt;
Smaller components such as pegs and other 3 input AND gates can still occupy the adjacent tile. But other components that take up a full tile will need to be moved over.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=AND_Gate&amp;diff=80</id>
		<title>AND Gate</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=AND_Gate&amp;diff=80"/>
		<updated>2025-09-06T22:30:53Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: Created a basic page describing the AND gate&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MHG.AndGate 512x512.png|thumb|A single AND gate]]&lt;br /&gt;
The &#039;&#039;&#039;AND gate&#039;&#039;&#039; is a basic digital logic component who&#039;s output will be active if &#039;&#039;&#039;all&#039;&#039;&#039; its inputs are active.&lt;br /&gt;
&lt;br /&gt;
For a 2 input AND gate, it is 1 tile wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.&lt;br /&gt;
&lt;br /&gt;
An AND gate with 2 inputs will demonstrate the following behavior:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+AND Gate Truth Table&lt;br /&gt;
!INPUT A&lt;br /&gt;
!INPUT B&lt;br /&gt;
!OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
|LOW&lt;br /&gt;
|LOW&lt;br /&gt;
|LOW&lt;br /&gt;
|-&lt;br /&gt;
|LOW&lt;br /&gt;
|HIGH&lt;br /&gt;
|LOW&lt;br /&gt;
|-&lt;br /&gt;
|HIGH&lt;br /&gt;
|LOW&lt;br /&gt;
|LOW&lt;br /&gt;
|-&lt;br /&gt;
|HIGH&lt;br /&gt;
|HIGH&lt;br /&gt;
|HIGH&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Activation Latency ==&lt;br /&gt;
The AND gate&#039;s output will only be active if all of its inputs are active. This is true no matter how many inputs the AND gate has.&lt;br /&gt;
[[File:And gate activation delay.png|thumb|A demonstration of two AND gates being activated. The top AND gate has both its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom AND gate has had both its inputs active for at least 1 tick, and its output is therefore active.]]&lt;br /&gt;
The AND gate has a latency of 1 tick, so in the instance when all inputs are active, the output will become active 1 tick later. As demonstrated in the example on the right.&lt;br /&gt;
&lt;br /&gt;
== AND Gates with More Inputs ==&lt;br /&gt;
Pressing the edit button on an AND gate allows you to change the number of inputs it has. You can select 2, 3, or 4 inputs. &lt;br /&gt;
&lt;br /&gt;
Changing the number of inputs on an AND gate does not change its latency, but it does make the components bigger, with their width changing from 1 tile wide with 2 inputs to a little less than 2 tiles wide with 3 inputs, to 2 tiles wide with 4 inputs.&lt;br /&gt;
&lt;br /&gt;
Note that when an AND gate has 3 inputs, while its width is less than 2 tiles, the component is centered on a tile, causing it to require 3 tiles of width.&lt;br /&gt;
&lt;br /&gt;
Smaller components such as pegs and other 3 input AND gates can still occupy the adjacent tile. But other components that take up a full tile will need to be moved over.&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=File:MHG.AndGate_thumbnail_render.png&amp;diff=75</id>
		<title>File:MHG.AndGate thumbnail render.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=File:MHG.AndGate_thumbnail_render.png&amp;diff=75"/>
		<updated>2025-09-06T22:12:22Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A render of an AND gate&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=File:And_gate_activation_delay.png&amp;diff=74</id>
		<title>File:And gate activation delay.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=File:And_gate_activation_delay.png&amp;diff=74"/>
		<updated>2025-09-06T21:58:44Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A demonstration of how an AND gate takes 1 tick to activate&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=File:And_gate_top-down.png&amp;diff=72</id>
		<title>File:And gate top-down.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=File:And_gate_top-down.png&amp;diff=72"/>
		<updated>2025-09-06T21:45:58Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An AND gate as viewed from above&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
	<entry>
		<id>https://wiki.logic.world/index.php?title=File:And_gate_side_profile.png&amp;diff=70</id>
		<title>File:And gate side profile.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.logic.world/index.php?title=File:And_gate_side_profile.png&amp;diff=70"/>
		<updated>2025-09-06T21:45:01Z</updated>

		<summary type="html">&lt;p&gt;N00basaurus: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An AND gate from the side&lt;/div&gt;</summary>
		<author><name>N00basaurus</name></author>
	</entry>
</feed>