<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Authoritative Opinion &#187; Hardware</title>
	<atom:link href="http://authoritativeopinion.com/blog/category/hardware/feed/" rel="self" type="application/rss+xml" />
	<link>http://authoritativeopinion.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 19 Jul 2010 00:04:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Analog Multiplexer (Update&#8211;9/25/09)</title>
		<link>http://authoritativeopinion.com/blog/2009/08/10/analog-multiplexer/</link>
		<comments>http://authoritativeopinion.com/blog/2009/08/10/analog-multiplexer/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 02:23:24 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://authoritativeopinion.com/blog/2009/08/10/analog-multiplexer/">greg</span></dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://authoritativeopinion.com/blog/?p=145</guid>
		<description><![CDATA[After posting about digital multiplexers and decoders, I started thinking about analog multiplexers, which I have not used before, but which can be quite useful, for instance in bypassing an effects pedal on a guitar. In principle, because a CMOS transistor can function as a connected/disconnected switch for digital circuits, I figured that it would [...]]]></description>
			<content:encoded><![CDATA[<p>After posting about digital multiplexers and decoders, I started thinking about analog multiplexers, which I have not used before, but which can be quite useful, for instance in bypassing an effects pedal on a guitar. In principle, because a CMOS transistor can function as a connected/disconnected switch for digital circuits, I figured that it would work similarly for analog circuits, and threw together this 2:1 analog multiplexer:</p>
<p><a href="http://authoritativeopinion.com/blog/wp-content/uploads/2009/08/analog-2-to-1-mux.png" target="_BLANK"><img src="http://authoritativeopinion.com/blog/wp-content/uploads/2009/08/analog-2-to-1-mux-300x182.png" alt="Analog 2:1 Multiplexer Circuit" /></a></p>
<p>V1 and V2 combine to form a single 0-5 V supply, I simply broke the two apart to demonstrate how the signal biasing could work. V3 and V6 represent  the output pins on a microcontroller that are used to select between inputs—they must be able to source a few mA when driven high (this shouldn&#8217;t be a problem for practically all microcontrollers, on real I/O pins). A simple logic circuit (i.e. decoder) could be used to take an encoded representation of the desired signal and drive these inputs appropriately. V4 and V5 are the input signals, referenced to any other signal, and they are properly biased (a good practice, even if they are supposedly referenced correctly) to ensure they are within the operating region of the rest of the circuit.</p>
<p>I chose 0-5 V rails to make the mux usable on any board that already had similar supplies for, say, a PIC microcontroller. Not using a -5 V rail simplifies the power requirements for simple circuits, but it does require that the signal be biased properly, in order to avoid clipping as it passes through the output buffer. The resistors and capacitors on the biasing circuit were selected to provide a cutoff frequency of ~0.3 Hz on the implicit high-pass filter, in order to avoid attenuating the low frequencies in audio applications and attempt to provide a relatively flat passband in the entire bandwidth of the NMOS transistors, which was approximately 1 MHz in the SPICE simulation I used. For higher frequency usage only, the values of both can be adjusted in order to make the circuit components easier to find, but care must be taken to limit the current that the input will be required to source/sink. If a piezoelectric transducer is used, its current capabilities are rather limited, so high resistances are preferable, as well as low capacitances (1 uF is large in this case, I think). A buffer stage could be introduced on the front end, but it would again require proper biasing to ensure that the signal is not clipped, which is highly likely using only a single +5 V supply.</p>
<p>This circuit is provided for academic/hobbyist purposes. If you really need to use an analog multiplexer, I suggest you <a href="http://www.analog.com/en/switchesmultiplexers/multiplexers-muxes/products/index.html">sample or purchase one from Analog Devices</a> because it will be more robust and have fewer caveats than this circuit does (for instance, if you drive both inputs high on this circuit, it will gladly add the two signals together, which might be useful instead of using a summing amplifier). Comments and other feedback are welcome, as I&#8217;m by no means good at analog design, and I only did SPICE simulations for this circuit—I haven&#8217;t had a chance to build it and try it in the real world yet.</p>
<p>[UPDATE]<br />
I was planning on building this circuit recently, both for a separate project and to test it out, when some shopping on Digi-Key led me to find that it is very difficult to purchase MOSFETs with substrate connections. MOSFETS are four terminal devices, but most common applications do not use them this way. Digi-Key has over 16,000 differently listed MOSFETS and no easy way to search for a four-terminal one (many come in larger packages with multiple pins connected to the drain and source) so I abandoned it and spent some time working on an alternative circuit. A combination of MOSFETs and BJTs should be sufficient to emulate the four-terminal device, but it imposes additional restrictions on the signals that can be passed through for a given power supply. The threshold voltages of BJTs gates require that there be a (device specific) gap between the maximum value of the signal and the power rails, but most operational amplifiers have similar restrictions (although not as large in magnitude). To that end, this is the modified circuit that gives the same results in simulation. I&#8217;ve also added a pull-down resistor (which can be tied to any of your negative rail 0V, the positive rail +5V, or a constant voltage available) to deal with the input/offset current of the op amp. This resistor should ideally be as big as possible (5 MOhm like the others is fine), but it will, in theory, attenuate all frequencies equally, which means that something as low as 10 or 100 kOhm is acceptable, depending on how wide the voltage margins your op amp requires are and how much current your signal transducers can source.</p>
<p><a href="http://authoritativeopinion.com/blog/wp-content/uploads/2009/08/analog-2-to-1-mux-realistic.png"><img src="http://authoritativeopinion.com/blog/wp-content/uploads/2009/08/analog-2-to-1-mux-realistic-300x187.png" alt="2:1 Analog Multiplexer" title="2:1 Analog Multiplexer" width="300" height="187" class="alignnone size-medium wp-image-195" /></a></p>
<div class='wp_likes' id='wp_likes_post-145'><a class='like' href="javascript:wp_likes.like(145);" title='' ><img src="http://authoritativeopinion.com/blog/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(145);">Unlike</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://authoritativeopinion.com/blog/2009/08/10/analog-multiplexer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TMP: Master Plan</title>
		<link>http://authoritativeopinion.com/blog/2009/06/19/tmp-master-plan/</link>
		<comments>http://authoritativeopinion.com/blog/2009/06/19/tmp-master-plan/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 18:07:54 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://authoritativeopinion.com/blog/2009/06/19/tmp-master-plan/">greg</span></dc:creator>
				<category><![CDATA[The Microprocessor Project]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://authoritativeopinion.com/blog/?p=98</guid>
		<description><![CDATA[I spent a lot of time debating which ISA to base this on. MIPS has the advantages of being easy to explain, being a good example of RISC, and I&#8217;ve implemented large sections of it before for class. However, that last bit makes me wary, because it means that more students in a similar situation [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a lot of time debating which ISA to base this on. MIPS has the advantages of being easy to explain, being a good example of RISC, and I&#8217;ve implemented large sections of it before for class. However, that last bit makes me wary, because it means that more students in a similar situation will need to implement a MIPS-like processor. I don&#8217;t want to just give away final projects here, so anything resembling MIPS enough to allow people to literally copy large sections of the code I release is undesirable. The other option that comes to mind is something based on ARM&#8217;s ISA. ARM is well-established and is a very common platform for embedded systems, but at the same time. So I&#8217;ll use a handful of the really interesting features available in ARM&#8217;s ISA, such as conditional execution of instructions. Finally, it&#8217;s never fun to blindly implement someone else&#8217;s ISA, it&#8217;s much more interesting to create your own design, so ultimately I will draw on both MIPS and ARM, as well as my own intuition, and create something that incorporates what I think are important features from both, while at the same time lending itself well to explanation of key features.</p>
<p>The Master Plan, then, loosely resembles the following, with many stages happening in parallel:</p>
<ul>
<li>Design Instruction Set Architecture (ISA)
<ul>
<li>Should be Load-Store and adhere to basic RISC principles.</li>
<li>Should make it easy to explain and demonstrate basic design principles, while allowing for powerful features and extensibility.</li>
</ul>
</li>
<li>Create a Simulator
<ul>
<li>Written in C</li>
<li>Will require an additional, simple assembler to convert instruction mnemonics to a binary execution image</li>
<li>Initially command line based (or ncurses frontend), with the possibility of adding a GUI if it seems worthwhile</li>
</ul>
</li>
<li>Design ALU
<ul>
<li>This part, and everything leading up to the actual processor implementation connecting everything together, can happen in parallel with simulator programming</li>
</ul>
</li>
<li>Create Register File</li>
<li>Miscellaneous Processor Structures
<ul>
<li>Memory interface (initially, an ideal memory, so this will just decode/translate requests)</li>
<li>Forwarding/Hazard Detection and Handling</li>
<li>Pipeline Registers</li>
</ul>
</li>
<li>Assemble the Microprocessor
<ul>
<li>This includes pipelining</li>
</li>
<li>Support for multiply and divide instructions
<ul>
<li>Requires significant pipeline extensions and an additional parallel processing unit</li>
</ul>
</li>
<li>Support for interrupts
<ul>
<li>This is necessary for implementing any reasonable, albeit basic, operating system</li>
<li>Also necessary for I/O, which is quite reasonable for anyone using integrated FPGA development boards (which often have a lot of I/O and the necessary support circuitry already implemented)</li>
<li>Not covered/explained often in microprocessor courses, yet integral to the functionality of all modern computers (interrupts are used to make system calls in both Windows and Linux).</li>
</ul>
</li>
<li>A basic OS
<ul>
<li>Flat memory model, without memory protection (dangerous, but simple)</li>
<li>Cooperative Multithreading (because it&#8217;s easy to implement)</li>
<li>Implements basic system calls to provide common sets of functionality for user programs</li>
</ul>
</li>
</ul>
<p>With this list of central goals complete, a few additional features seem quite reasonable and would serve to be important in understanding the functionality of a much more advanced processor. Therefore, these are secondary targets, to be completed once the basic design is done:</p>
<ul>
<li>Instruction and Data Cache</li>
<li>Branch Predictor</li>
</ul>
<p>I&#8217;ve even got some genuinely crazy ideas, but I&#8217;ll keep them to myself for now (most fall into the realm of &#8220;not existent on 99% of available commercial microprocessors/microcontrollers&#8221;). If this can be established as a platform on which I can test less mainstream concepts and designs, then this will be a success for me.</p>
<p>All that said, I may have missed a few features that won&#8217;t be apparent until the time comes, but I think this is a good starting point. Next time, the ISA will be unveiled (hopefully a week), or at least the first revision of it. Design flaws will always become apparent through actually working with it (something a lot of software library designers haven&#8217;t realized, but I digress), and so things will be amended as time goes on.</p>
<div class='wp_likes' id='wp_likes_post-98'><a class='like' href="javascript:wp_likes.like(98);" title='' ><img src="http://authoritativeopinion.com/blog/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(98);">Unlike</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://authoritativeopinion.com/blog/2009/06/19/tmp-master-plan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Microprocessor Project: Overview</title>
		<link>http://authoritativeopinion.com/blog/2009/06/12/the-microprocessor-project-overview/</link>
		<comments>http://authoritativeopinion.com/blog/2009/06/12/the-microprocessor-project-overview/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 19:45:02 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://authoritativeopinion.com/blog/2009/06/12/the-microprocessor-project-overview/">greg</span></dc:creator>
				<category><![CDATA[The Microprocessor Project]]></category>

		<guid isPermaLink="false">http://authoritativeopinion.com/blog/?p=79</guid>
		<description><![CDATA[This summer, I need something to do. I&#8217;ve got a few ideas, but in particular, one desire I&#8217;ve had since I was a young teenager was to design my own computer, which I&#8217;ve now learned enough to understand means &#8220;to design my own microprocessor.&#8221; Software for it can come later, if I still like the [...]]]></description>
			<content:encoded><![CDATA[<p>This summer, I need something to do. I&#8217;ve got a few ideas, but in particular, one desire I&#8217;ve had since I was a young teenager was to design my own computer, which I&#8217;ve now learned enough to understand means &#8220;to design my own microprocessor.&#8221; Software for it can come later, if I still like the idea after designing the hardware (or, if I&#8217;m really clever, I can try to port Linux to it, and not have to write my own software at all). However, I see now that the reason I didn&#8217;t do this sooner, and my new reason for doing this project, is that there are virtually no in-depth, beginner-level resources available on the Internet (if anyone wants to try to look at <a href="http://www.opensparc.net/">OpenSPARC</a> and without any understanding of what it&#8217;s based on, deduce how to build a basic microprocessor, please, be my guest). To that end, today I begin my next big project: designing, simulating, testing, and maybe putting on an FPGA a real, functional, 32-bit microprocessor. Then, explaining it in detail, putting my results on the Internet, and releasing it under the GNU GPL, so that there exists a simple platform for people to play around with microprocessors, extending it with additional features or modules as they see fit. I don&#8217;t intend to create something remotely commercially viable, because I will, initialy, purposely not include features found even in the early 90s on Intel chips, in order to simplify the design process, and help explain the basic concepts. If I like what I&#8217;ve done, when the time comes, maybe I&#8217;ll add more realistic features, such as multiple pipelines (superscalar) and out-of-order execution, or I&#8217;ll design support for more esoteric features (like <a href="http://en.wikipedia.org/wiki/Barrel_processor">barrel processing</a>), to see how readily (if at all) they are implemented and to provide some context about where microprocessors can go from the basic 5-stage pipeline.</p>
<p>The real goal here is educational in nature. Microprocessors are incredibly complicated devices, and so most online descriptions are terse at best. Despite that, I think people should be able to learn, for free, exactly how a microprocessor works. However, I can&#8217;t explain how an x86 chip works, for a number of reasons. First, I don&#8217;t actually know. I have a pretty good understanding of the elements from which it is built, but I&#8217;ve spent almost no time studying the ISA or reading papers on how Intel has actually implemented things. Second, I&#8217;d hate to speculate and be totally wrong, and then have people read it and think that was how it works. In contrast, I do understand the principles upon which RISC microprocessors (like MIPS and ARM) are based, so I can readily make up an instruction set that it is similar to MIPS, implement it, and then talk at great length about how it works. Hopefully, then, a younger version of me can find this online, look through it, and then be able to answer all those questions I had until college about how computers actually do things. If software and programming can be well documented and available for free to learn from, then hardware should be too.</p>
<p>If you would like to contribute descriptions, Verilog, or simulation code (which will mostly be written in C), please let me know by posting in the comments.</p>
<p>Coming soon: The Master Plan. I&#8217;ll lay out precisely what the objectives are and give an overview of how the project will progress as a whole.</p>
<div class='wp_likes' id='wp_likes_post-79'><a class='like' href="javascript:wp_likes.like(79);" title='' ><img src="http://authoritativeopinion.com/blog/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(79);">Unlike</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://authoritativeopinion.com/blog/2009/06/12/the-microprocessor-project-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiplexers and Decoders</title>
		<link>http://authoritativeopinion.com/blog/2009/05/25/multiplexers-and-decoders/</link>
		<comments>http://authoritativeopinion.com/blog/2009/05/25/multiplexers-and-decoders/#comments</comments>
		<pubDate>Mon, 25 May 2009 22:05:22 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://authoritativeopinion.com/blog/2009/05/25/multiplexers-and-decoders/">greg</span></dc:creator>
				<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://authoritativeopinion.com/blog/?p=73</guid>
		<description><![CDATA[Here&#8217;s something that wasn&#8217;t emphasized in my digital design courses, which every amateur digital designer should be aware of: decoders and three-state buffers use fewer logic gates than large multiplexers. Obviously when one uses commercial devices with an output enable, the decoder functionality is implicit, but whenever it comes to incorporating selection logic into our [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s something that wasn&#8217;t emphasized in my digital design courses, which every amateur digital designer should be aware of: decoders and three-state buffers use fewer logic gates than large multiplexers. Obviously when one uses commercial devices with an output enable, the decoder functionality is implicit, but whenever it comes to incorporating selection logic into our own designs acting on our own data, the more natural choice is a conventional multiplexer. Both approaches have benefits and drawbacks, but which is &#8220;better?&#8221; First, a quick look at the differences between the two: a multiplexer uses a combination of AND and OR gates to select between a number of inputs and always drives the output accordingly. A decoder/three-state selection device (which is really also called a multiplexer, but I&#8217;ll try to avoid some confusion) uses only AND gates and single transistors to drive the output with just one of the inputs when it is selected. The key aspect here is that there is not always an output of 0 or 1—a third option, high impedance (or Hi-Z), is available, corresponding to &#8220;no value.&#8221; This happens because each of the combination of select pins controls whether each input drives the output or not, rather than all inputs driving something regardless of utility. The differences between the two can be seen by implementing generic multiplexer functionality for a 1-bit, 8:1 multiplexer. Without three-stated buses, this requires 24 two-input AND gates and 7 two-input OR gates. The schematic shows that there are six logic gates between the input and the output of the multiplexer:</p>
<div id="attachment_74" class="wp-caption alignnone" style="width: 310px"><a href="http://authoritativeopinion.com/blog/wp-content/uploads/2009/06/8-to-1-mux.png"><img src="http://authoritativeopinion.com/blog/wp-content/uploads/2009/06/8-to-1-mux-300x172.png" alt="8 to 1 mux" title="8 to 1 mux" width="300" height="172" class="size-medium wp-image-74" /></a><p class="wp-caption-text">8 to 1 mux</p></div>
<p>By comparison, the same functionality can be realized using only 16 two-input AND gates and 8 three-state output buffer elements. The schematic is also much simpler:</p>
<div id="attachment_75" class="wp-caption alignnone" style="width: 310px"><a href="http://authoritativeopinion.com/blog/wp-content/uploads/2009/06/8-to-1-decoder.png"><img src="http://authoritativeopinion.com/blog/wp-content/uploads/2009/06/8-to-1-decoder-300x257.png" alt="8 to 1 decoder" title="8 to 1 decoder" width="300" height="257" class="size-medium wp-image-75" /></a><p class="wp-caption-text">8 to 1 decoder</p></div>
<p>This reduces the gate delay between input and output to two gates plus a transistor. This would make it seem like three-state buffers and decoders are the obvious choice for every situation, because they have a shorter gate delay and use fewer transistors, which has many benefits. However, there are hidden problems associated with this design, making it unsuitable for some situations.</p>
<p>First, if the design is being developed for an FPGA, the AND/OR approach is more versatile. Why? Because FPGAs do not implement traditional combinational circuits. Often, combinational blocks are instead broken into units that can be implemented by 4-input Look-Up Tables (LUTs), which means that any function that can be described by such a lookup table has the same speed cost, regardless of the number of gates that would be required to implement it otherwise. Next, three-state elements are not readily available within most of the logic blocks (although an FPGA could be built to not have this restriction), meaning that more interconnect must be used to route signals through three-state elements, although it is more common for the compiler to simply recognize the situations and convert it into a multiplexer that can be implemented easily with the LUTs.</p>
<p>Second, when working with CMOS, each transistor has an capacitive property. Therefore, as more transistors are tied to the same bus, even in a Hi-Z mode, the capacitance will cause the rise and fall times to increase, in a manner similar to having an increased fanout. This can create problems with setup time in very high speed situations, whereas the rise and fall time of an AND/OR multiplexer output will not vary with the number of inputs (although the total propagation delay will—the two must be balanced, so it is possible that the longer rise time is shorter than the longer propagation delay).</p>
<p>Third, although this isn&#8217;t really a big problem, is that during transients when switching, it&#8217;s possible for two three-state elements to have their enables asserted at the same time, potentially causing the bus to be driven both low and high at the same time. This is going to happen for an extremely short period of time, as the switching time is usually less than the delay of a single inverter, so I think the additional power dissipation caused by this situation is negligible compared to the sum of leakage current and normal switching power consumption</p>
<p>But, these three considerations aside, if you&#8217;re designing an ASIC or wiring together something with discrete components (a rarity in itself), it&#8217;s possible that replacing AND/OR multiplexers with decoders and a three-state buffer could increase the throughput of the digital circuit you&#8217;re designing, or just make it easier for you to wire, with fewer things to keep track of. It&#8217;s hard to say which approach is better, but it&#8217;s certainly important to understand how to use both effectively, because many situations will call for one or the other for optimal performance.</p>
<p>Finally, a quick Verilog reference (because the Internet is thoroughly lacking in this department), I find the easiest way to implement a three-state bus is with structural Verilog, defining a module to handle the three-state output (although sometimes it can be incorporated into a larger module). In this case, the module has a parameterized width, and it is used to build a mux of parameterized width as well:</p>
<pre class="verilog" name="code">
// sel = 0: A => C
// sel = 1: B => C
module mux2x1(A, B, C, sel);
	parameter width = 32;

	input [width-1:0] A;
	input [width-1:0] B;
	input sel;

	output [width-1:0] C;

	en_buffer #(.width(width)) selected (.A(B), .C(C), .EN(sel));
	en_buffer #(.width(width)) not_selected (.A(A), .C(C), .EN(~sel));

endmodule

module en_buffer(A, C, EN);
	parameter width = 32;

	input [width-1:0] A;
	input EN;

	output [width-1:0] C;

	assign C = (EN ? A : {(width){1'bz}});

endmodule
</pre>
]]></content:encoded>
			<wfw:commentRss>http://authoritativeopinion.com/blog/2009/05/25/multiplexers-and-decoders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
