Heat Transfer

The transfer of heat and energy has been the focus of scientific discovery and engineering for a large portion of human history as the understanding of heat and energy and the mechanisms by which it is transferred allows for meaningful work to be performed. In this post, I will be discussing what heat is and some mechanisms by which it is transferred between systems.

What is Heat

Heat is energy that can be transferred between bodies and objects. This transfer of heat happens spontaneously between hot and cold systems, with heat transferring from the hot system to the cold system. “Hot” and “cold” refer to the thermodynamic temperature (absolute temperature) which is a measure of the energy arising from the relative motion of atoms and molecules within a substance. Thermodynamic temperature is an absolute measure of temperature in that at 0 degrees on an absolute temperature scale (Kelvin or Rankine) refers to a state where there is no molecular motion present. Absolute zero is impossible to achieve, however, temperatures only 1 billionth of a degree kelvin above absolute zero have been. The mechanisms by which heat is transferred between systems are conduction, convection, and radiation. The three mechanisms by which heat transfer listed all occur spontaneously between hot and cold systems. However, the exact way and rate at which heat is transferred is the main differentiator between the mechanisms.

Mechanisms of Heat Transfer

Illustrations of the flow of heat by the heat transfer mechanisms discussed

In the case of conductive heat transfer, heat is transferred between two materials of differing temperature in direct contact with each other. This transfer of energy arises from the direct interaction of higher energy, faster moving particles in the hot system colliding with the more slowly moving particles within the cold system, transferring some of their kinetic energy. Convective heat transfer is like conduction except with the addition of fluid flow to transfer mass along with heat. An example of convection would be the case of a convection oven. As the air is heated via conduction by the oven walls, motion is induced by density differences in the air creating drafts and currents. These drafts and currents move the hot air that then can conduct its heat to the food in the oven. Gases and liquids are typically very poor conductors of heat, however, due to the additional mass transfer by convective currents, convection is a very effective mechanism of heat transfer. Thermal radiation is different from the previous two discussed mechanisms in that it occurs between systems that can be vast distances apart and don’t require a medium in-between to be heated. An example of radiative heat transfer would be the sun which heats the Earth through millions of miles of vacuous space. This mechanism occurs by way of electromagnetic energy released by objects depending on the heat of that object. Hotter objects release more energy than cooler objects and that energy can interact with the atoms and molecules of the cooler object to increase their heat.

Please like and share if you learned something new!

Building an 8-bit computer, Part 3: Memory Management Unit

This post is a further continuation of my previous posts, starting with Building an 8-bit computer, Part 1: The elements of the computer, where I am documenting the design and build process of an 8-bit computer using logic gates. In this post, I cover the design of the Memory Management Unit (MMU). I would recommend reading my post Basics of Binary if you don’t know binary number representation as I will be using that a bit in this post.

The purpose of the MMU

As discussed in my first post in the series, the MMU controls and manages the ROM and RAM memories using inputs from the control unit and the address bus. The address bus allows for specific bytes of memory to be selected and either written to (only in RAM) or read from (RAM or ROM). I have planned to have 64k of memory (65536 bytes) where the first 8k are dedicated to ROM to allow room for me to write programs and the remaining 56k for RAM for use by those programs. Initially, I had planned to incorporate circuitry to handle receiving addresses from the 8-bit data bus directly in the MMU, however, this turned out to be much more suited to the control unit, which will be covered in a future post.

Parts of the MMU

For my purposes, the circuitry of the MMU is relatively simple when compared to the other elements of the computer like the ALU or Control Unit. Building the RAM and ROM out of individual logic gates would be infeasible as the number of gates required would be on the order of tens of thousands so I plan to use readily available integrated circuits. The MMU has 5 inputs and 1 output, those are: 3 inputs from the control unit consisting of the clock signal, a signal to enable output to the data bus, and a signal to enable input from the data bus; 1 input from the address bus to set which memory address is pointed to; 1 input from the data bus to load data from; and 1 output to the data bus to allow writing to the bus. As for individual elements, the MMU consists of a circuit to select between ROM and RAM based upon the current memory address (first 8k are ROM, next 56k are RAM), an 8k ROM chip, and a 64k RAM chip. The selection circuit works by disable the RAM when the top 3 address bits are anything but 0 and disabling ROM when any of the top 3 are 1. The selection circuit is to prevent bus contention between the ROM and RAM. Below is a diagram of the basic design of the MMU.

MMU Diagram

Please follow my blog if you’d like to follow along with this project!

Chemical Bonds

In order to go from the atoms and elements I covered in my posts The Atom: The building blocks of everything and The Periodic Table: An index of everything to make up more complex chemical compounds ranging from table salt to DNA, those individual atoms must interact with each other by way of chemical bonding. Chemical bonds are formed by the interactions of electrons with electric charges of other atoms, be they from the positive nucleus or the negative charge of other electrons. In this post, I will be discussing ionic bonds, covalent bonds, metallic bonds, and hydrogen bonds.

Ionic Bonds

Ionic bond between sodium and chlorine. Chlorine gains an electron (blue) that sodium loses.

Ionic bonds are formed in the case when an atom gains an electron from another atom losing that electron. As in the case illustrated with a sodium and chlorine atoms, the chlorine strips the electron from the sodium atom leaving a positively charged sodium ion and a negatively charged chlorine ion. These bonds are typically very strong and contribute to the very high melting and boiling points of ionic compounds. As with most chemical bonds, these bonds occur when the transfer of electrons allows the individual atoms to attain a more stable/lower energy electron configuration. Typically this occurs, as with the state of Na and Cl when the atoms can be left with 8 valence electrons for main group elements, following the rule of thumb known as the Octet rule.

Covalent Bonds

Covalent bond between oxygen and carbon. A triple bond is formed that allow for 6 electrons (blue) to be shared between the atoms, leaving each atom with an octet.

Covalent bonds are formed when electrons are shared between two atoms, in contrast to ionic bonds where electrons are lost or gained. These kinds of bonds are not as strong as ionic bonds but follow similar rules in that they occur when the sharing of electrons can create a stable electron configuration for both atoms in the bond. These bonds dominate the chemistry of life on Earth in that carbon atoms readily bond with themselves and other elements to create organic compounds. Typically, these bonds result in the sharing of two (single bond), four (double bond), or six (triple bond) electrons between the bonded atoms but can, in certain cases, result in the sharing of eight electrons (quadruple bond).

Metallic Bonds

Metallic bonds, as the name implies, are the bonds formed between atoms of metals. Many of they physical properties of metals are a result of the metallic bonds that keep the atoms together. In a metallic bond, electrons are able to move freely within the bonds and it is typically described as a sea of electrons able to flow around positively charged metal ions. This free flow of electrons accounts for the high electrical conductivity of metals.

Hydrogen Bonds

Hydrogen bond between two water molecules

Hydrogen bonds are special in that they are not bonds in the sense that the previously described bonds are as they are formed between separate molecules as opposed to atoms within a molecule (intermolecular versus intramolecular). The bonds occur when hydrogen is covalently bound to a small, highly electronegative atom, like oxygen, where a majority of the electron density surrounds the other atom. This disparity in electron density forms a slight positive charge on the hydrogen and a slight negative on the bound atom. Differing electrical charges on each side of the molecule crest what is called a dipole and allows for an electrostatic force between molecules to act similarly to a bond.

Please like and share if you learned something new!

Properties of Gases

Gas particle motion in a container

In my previous post, States of Matter, I discussed how gases have no definite shape or volume, will expand to fill a container, and exert a pressure on the container’s walls. Gases are incredibly useful in engineering and technology in things ranging from pneumatic systems that use pressurized gas to perform mechanical work or in certain refrigeration systems where they are used to remove heat and lower the temperature of an area. Due to the importance and usefulness of gases, understanding the properties of gases and how they relate to each other was a focus of scientific research. In most cases, gases can be considered “ideal” and the properties discussed are pressure, temperature, volume, and quantity of particles.

What’s and Ideal Gas

An ideal gas is a conceptual model for the behavior of gases in the real world. Gases are composed of particles that are able to freely move within little to no interaction. In an Idea gas, those particles that compose the gas are considered to be infinitely small and have no interaction with each other at all. In reality, those particles have a real volume (although on the atomic scale) and will interact with each other by way of collision, attraction, or repulsion. Despite this, these assumptions are very reasonable and they hold up for gases under normal conditions outside of extremely low temperatures and very high pressures.

Pressure

Pressure of a gas is the force that enacted upon the walls of its containers as a result of particles colliding with that container. Boyle’s law states that pressure is inversely proportional to volume (doubling pressure halves volume) and Gay-Lussac’s law states that pressure is directly proportional to volume (doubling pressure doubles temperature).

Temperature

When discussing the properties of gases, the temperature refers to the absolute temperature. The absolute temperature is the temperature above absolute zero (approximately -273C and -460F). Charles’s law states that temperature is directly proportional to the volume of a gas (doubling volume doubles temperature) and Gay-Lussac’s laws states that temperature is directly proportional to pressure (doubling volume doubles pressure).

Volume

The volume of a gas is the 3-dimensional space occupied by that gas. This is determined by the container volume as a gas will expand to fill any container. Boyle’s law states that volume is inversely proportional to pressure and Charles’s law states that volume is directly proportional to absolute temperature. This means that doubling the volume of a gas halves the temperature if all else is held constant and doubling the volume of the gas doubles the absolute temperature.

Quantity of particles

The quantity of particles in a gas is measured in moles, where 1 mole is equivalent to 6.02*10^23 particles. Avogadro’s gas law states that the number of moles of a gas is directly proportional to the volume. Due to this, a doubling of the quantity of particles in a gas results in the doubling of its occupied volume with all else held constant

Ideal Gas Law

By combining the relations between the above discussed properties. A gas law that describes the relationship between all the properties can be developed. That equation (where P is pressure, V is volume, n is moles of gas, T is absolute temperature, and R is the gas constant) is as follows:

This implies that for any system of an ideal gas, the ratio of pressure times volume over moles time temperature is always equal to a constant.

Please follow my blog if you enjoy reading my posts!

The States of Matter

Matter not only surrounds us and makes up the world we live in it also makes up us. Composed of atoms (which I talk about in my post The Atom: The building blocks of everything) and molecules consisting of the elements found in the periodic table (covered in another of my posts – The Periodic Table: An index of everything), matter is everywhere. Matter comes in four fundamental states that are delineated by the density and energy of the matter itself and visible in everyday life. These fundamental states are solid, liquid, gas, and plasma

Solid

Solid matter is composed of dense, closely packed particles (atoms or molecules). These particles are not free to move throughout the solid but can vibrate (giving rise to temperature). Since the particles are bound, a solid has a definite volume and shape. Providing the proper conditions (pressure and temperature) a solid can either melt into a liquid or sublimate into a gas. Some everyday examples of solids are ice (a crystalline solid) and wood (an amorphous solid).

Liquids

Liquid matter is composed of particles that are less densely packed than in a solid however they are still close enough to each other to interact. Due to the lower density of particles, they can move relative to their neighbors. This relative movement of particles is what makes liquids fluid in that the overall structure is mobile and has a definite volume (incompressible) but no definite shape. A liquid can vaporize into a gas or freeze into a solid. Everyday examples of liquids are water and olive oil.

Gas

Gaseous matter is even less dense than a liquid, so much so that there is little or no direct interaction between individual particles. The spacing between the particles of a gas allows it to be compressed meaning that gasses neither have a definite shape or definite volume and will expand to fill their container. Gasses within a container have a pressure, that is a force exerted on the container walls, caused by the collision of gas particles with the container walls. This pressure is dependent upon volume, mass, and temperature. Gasses can ionize into a plasma, condense into a liquid, or deposit into a solid. Examples of gasses are air and steam.

Plasma

Plasma is a lesser known state of matter and is very similar to gasses in that it has no definite volume or shape. The key difference between gasses and plasmas is that due to the high temperature/energy of the plasma, the electrons have been stripped from the nucleus of the atoms. These electrons are freely able to move throughout the plasma as they are no longer bound to the nuclei. The mobility of these electrons allows plasmas to conduct electricity much like how metals do. A plasma can de-ionize into a gas. Examples of plasma are lightning and fire.

Be sure to like and share this post if you enjoyed reading!

Building an 8-bit computer, Part 2: Designing the ALU

This post is the continuation of my previous on the topic of designing an 8-bit computer. The previous post can be found here: Building an 8-bit computer, Part 1: The elements of the computer. In this post I will be discussing the core design process for the ALU (arithmetic logic unit) and covering the concept of flags.

Instruction Decoding

The first step in designing the ALU is to design the circuit that allows the rest of the computer to tell the ALU what operation to perform on its inputs. In order to accomplish this, the operations need to be assigned a number, called an opcode, that can be sent to the ALU to select a specific operation. A table of the operations and their opcodes (which are assigned arbitrarily) follows:

Operation Description Opcode
NOP No Operation (do nothing) 0b000
ADD Add data from registers A and B 0b001
SHR Shift data in register A right 0b010
SHL Shift data in register A left 0b011
AND AND data from registers A and B 0b100
OR OR data from registers A and B 0b101
XOR XOR data from registers A and B 0b110
NOT NOT data from register A 0b111

In my posts Some more digital logic, I introduce buffers and the demultiplexer. Using a demultiplexer to select the operation and turn on a specific buffer, we can control which parts of the ALU are able to write to the output lines, thus decoding the instruction.

Operation Circuits

Circuitry to perform each of the operations must also be designed. The operations themselves are rather simple and are, for the most part, only expanded versions of the 1-bit operations and 3 of them (NOP, SHR, and SHL) require no gates at all. The operations AND, OR, XOR, and NOT were covered in my previous post Digital Logic and ADD was covered in my other post Some more digital logic. I’ll further explain how the NOP, SHR, and SHL operations work as I have yet to cover those.

NOP

The NOP operation is essentially just a placeholder in order to prevent the ALU from writing data erroneously to its output. This is since when the opcode is 0, the ALU is shut off from being able to write anything. It’s probably not necessary to include this operation since the control unit should also prevent this but with 7 other operations requiring 3 select bits, there was an unused operation slot.

SHR and SHL

These operations both “move” the data either a bit to the left or to the right. The can be accomplished with nothing more than a bit of clever wiring since no actual logic is being performed. A diagram showing the wiring for each operation is shown below as it provides a far better description than I could with words.

Flags

Flags are data bits that are used as indicators that some event, chosen by the designer, has occurred between the input and output of the ALU. The flags that I have incorporate into the ALU are: Overflow (V), which is set to 1 if the sign of the output is different than the sign of the two inputs (this can be used to indicate that the sum of two numbers is too large to be represented in 8-bits); Carry (C), which is set to 1 if a bit is carried out of the operation (either it is dropped by shifting or carried out of the highest full-adder); Negative (N), which is set to 1 if the output of the ALU is negative; and Zero (Z), which is set to 1 if the output of the ALU is equal to zero. These are extremely helpful when it comes to the point of programming the computer. One example is that they allow for comparison tests (<, >, =, etc.) to be implemented very easily.

Bringing it all together

Putting all the parts together leaves me with the logic design for the ALU of the computer. Below is a labeled diagram for the complete ALU design. Please follow my blog if you’d like to see future posts of mine on this or other topics. Also, please comment if I was unclear or with any questions and I’ll be glad to answer!

Operating on random data

Building an 8-bit computer, Part 1: The elements of the computer

This blog post is the first in a series where I plan to document where I plan to document the design and eventual build process for an 8-bit computer using logic chips (ie. no microprocessor). I have made several posts on my blog that cover concepts I’ll be referring to and using in this series and will link to them in each post as these topics come up. This post will be going into detail about the individual parts of a CPU and adds more depth to the topics discussed in my first post: What’s a Computer and what’s it thinking?. I would recommend reading that and another one of my posts, Basics of Binary, to be able to follow along.

The computer I will be designing will be based upon Von Neumann architecture which will consist of registers, an arithmetic logic unit, a system bus, memory and a memory management unit, a control unit, and a means for basic input/output. The goal of this post is to break down each of these parts and explain what they will do before I dive into the design process in future posts.

Registers

                Registers act as memory for a single unit of data that can be readily accessed by the computer without the need to load from memory. In the case of my computer design, these will store a single byte (8 bits) of data that can be used by the other parts of the computer as they are needed.

Arithmetic Logic Unit

                The arithmetic logic unit (ALU) is the piece of the computer that will be able to perform mathematical operations on data that is sent to it. I plan to design my ALU to operate using two input registers, Register A and B, and a single output register, Register C. It will be designed such that it can perform the following operations: Add (ADD), which adds registers A and B; Shift Right (SHR), which shifts register A one bit to the right (dividing by two); Shift Left (SHL), which shifts register A left one bit (multiplying by two); Logical And (AND), which takes the AND of registers A and B; Logical Or (OR), which takes the OR of registers A and B; Logical Exclusive Or (XOR), which takes the XOR of registers A and B; and Logical Not (NOT), which takes the NOT of register A. I will not need to implement circuitry to perform subtraction as by using these operations I can subtract two numbers albeit with multiple steps. This concept is covered in my previous post How computers represent negative (integer) numbers.

System Bus

Visualization of a shared system bus
Source: W. Nowicki

The system bus is the network of wires that information is shared between the individual elements of the computer. The system bus will further be broken down into a 16-bit address bus (this is to allow me to address 64k of memory), an 8-bit data bus, and a control bus (the size will be determined later in the design process).

Memory and Memory Management Unit

The memory of the CPU will consist of 64k of addressable memory. I plan on reserving the first 8k for ROM and having the remaining 56k available for RAM and I/O devices. The memory management unit controls the memory and is capable of reading memory to and from the data bus at the location provided to it via the address bus.

Control Unit

The control unit is perhaps the most complicated part of the whole system. It is what controls the timing and operation of all other elements in the computer. This is done by keeping track of where the computer is within a program via the Program Counter and executing a mini-program for each instruction that activates and deactivates the other elements in concert to perform an operation. By way of the control bus, this unit is what allows all element to share common data and address buses without trying to write/read different information simultaneously (Bus contention). I will cover this in far more detail in a future post as it is likely where most of the time spent designing the computer will be focused.

Input/Output

My goal is to make the input/output as generalized as possible so it is simple for me to attach virtually any device without too much added circuitry. Currently, I would like to have some sort of keyboard/text input and a display device. The details of this will be covered further in a future post.

The Next Steps

I plan to break down the design and build process into the individual elements I have described here and document the progress with regular posts. My next post on this topic will cover the design of the ALU. Please follow my blog if you’d like to be updated when I post and follow this project!