<?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>Embedded Bridge</title>
	<atom:link href="http://embeddedgurus.com/embedded-bridge/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedgurus.com/embedded-bridge</link>
	<description>A Blog by Gary Stringham</description>
	<lastBuildDate>Sat, 04 Jun 2011 01:32:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Abiding by Industry Standards</title>
		<link>http://embeddedgurus.com/embedded-bridge/2011/06/abiding-by-industry-standards/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2011/06/abiding-by-industry-standards/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 01:32:03 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[industry standards]]></category>
		<category><![CDATA[PCI Express]]></category>
		<category><![CDATA[RS-232]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=57</guid>
		<description><![CDATA[A printer ASIC was designed to be just a PCI Express endpoint so some of the configuration registers were hard-coded as such and it was used in a printer model. Sometime later, for a new printer model, the engineers wanted to use the ASIC as a root complex to bridge to other PCI Express devices [...]]]></description>
			<content:encoded><![CDATA[<p>A printer ASIC was designed to be just a PCI Express endpoint so some of the configuration registers were hard-coded as such and it was used in a printer model. Sometime later, for a new printer model, the engineers wanted to use the ASIC as a root complex to bridge to other PCI Express devices on a different bus. However, since the PCI Express configuration registers in the ASIC were hard-coded as an endpoint, the standard discovery process would not search for another bus connected to that ASIC. Fixing the ASIC to make it configurable as a root complex would have required a respin.</p>
<p>Because the ASIC had not been implemented per the standard, other components had to deviate from the standard to interface with it. In this case, the engineers had to hack up the firmware discovery process to say, “If the device being queried is an endpoint and the vendor and device id matches this particular chip, then treat it as a root complex and search for another bus and its devices.”</p>
<p>Designing a block in strict compliance to a standard has several benefits:</p>
<ul>
<li>The compliant block will work, without changes, with compliant off-the-shelf components (e.g. blocks, chips, device drivers, test suites, debuggers, analyzers, development platforms).</li>
<li>Well-defined specifications already exist for verifying and testing compliant blocks.</li>
<li>Expertise in standards exists and is available.</li>
</ul>
<blockquote><p><strong>Best Practice:</strong> Design the chip or block exactly to the specifications of the standard, even down to the details of the characteristics of the registers.</p></blockquote>
<p>Some standards have standard subsets. For example, the RS-232 serial interface has transmit and receive lines and hardware handshaking lines. The hardware handshaking lines are optional. Hardware and drivers should be designed such that, if they are fully implemented, they will work with other components that do not have the optional part implemented.</p>
<p>A non-standard subset of a standard will create problems. Implementing a transmit-only RS-232 interface can cause compatibility problems with associated compliant components, such as RS-232 drivers, other RS-232 interfaces connected to it, and test suites trying to verify functionality. These interfacing components would all have to be customized, increasing the time and cost of development, and the risk of introducing bugs.</p>
<blockquote><p><strong>Best Practice:</strong> When implementing a subset of a standard, implement a standard subset, not a custom-designed standard.</p></blockquote>
<p>Remember, there is no such thing as a customized standard. Either it is customized or it is a standard – not both.</p>
<p>Until the next standard issue…</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2011/06/abiding-by-industry-standards/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The (not so) Exciting World of Documentation</title>
		<link>http://embeddedgurus.com/embedded-bridge/2011/02/the-not-so-exciting-world-of-documentation/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2011/02/the-not-so-exciting-world-of-documentation/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 23:51:27 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[collaboration]]></category>
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=52</guid>
		<description><![CDATA[In a survey I conducted of several firmware engineers, lack of good documentation of hardware was the number one complaint. It is because firmware engineers so heavily rely on the hardware documentation to correctly do their job. Some of the engineers said that wrong documentation is worse than no documentation because of the wasted time [...]]]></description>
			<content:encoded><![CDATA[<p>In a survey I conducted of several firmware engineers, lack of good documentation of hardware was the number one complaint. It is because firmware engineers so heavily rely on the hardware documentation to correctly do their job. Some of the engineers said that wrong documentation is worse than no documentation because of the wasted time producing incorrect code.</p>
<p>It is a problem because one group (hardware engineers in this case) has to produce documentation for a different group (firmware engineers). They generally are in different physical locations, come from different engineering backgrounds, have different terminology, and have different perspectives on the end products. To overcome these differences, hardware and firmware engineers need to collaborate with each other.</p>
<p>Writing documentation is difficult. When I write, I understand perfectly well what I meant to say. I know and understand unwritten details and nuances that are second nature to me without realizing that my reader might not. I’m reminded of that when I have someone else review my writing and they bring up missing and incomplete sections.</p>
<p>While both hardware and firmware engineers should be actively involved in the collaboration, it is primarily the hardware engineers who do the majority of the work with documentation and design. When ready for review, they should give the documentation to firmware engineers for review. Firmware engineers should, in a timely fashion, review the documentation and provide hardware engineers with comments on incomplete, unclear, and incorrect sections and any issues that they might discover. Firmware review of hardware documentation should be part of the checklist for milestone completions.</p>
<blockquote><p><strong>Best Practice:</strong> Give hardware documentation to firmware engineers to review and respond with comments and issues.</p></blockquote>
<p>Before firmware engineers can understand the specifics of how the block works, they need to have an overall picture of the purpose and operations of the block. If they focus too much on details, specific registers, and bits, it is hard to see what the overall operation should be. Not having a high-level description can be compared to seeing a box full of nuts, bolts, springs, levers, and other parts and not being able to recognize that it is supposed to be a toaster. But by first stepping back and looking at a high-level description of the toaster as a whole and understanding how it toasts bread, then it is easier to understand how to assemble the components to make a functional toaster.</p>
<p>The same concept applies to a block on the chip. Firmware engineers need to see and understand the big picture of how that block should operate, within itself and in conjunction with other parts of the system, before they can understand the detailed registers and bits.</p>
<blockquote><p><strong>Best Practice:</strong> Produce and have reviewed a high-level description of the block that describes its theory of operation, its function in the system, and its parts.</p></blockquote>
<p>In addition to the high-level documentation, a detailed documentation is needed and should contain both a reference section and a tutorial section. A reference section has a list of all registers in the block, typically in address order. It gives details for each register and the bits and/or bit fields in that register. The tutorial section describes when, how, and in what order to use those registers and bits to carry out a task.</p>
<p>An example of reference documentations are the UNIX man pages (and Linux and other variants) which contains all commands and functions in alphabetical order, each one describing their respective options in order. On the other hand, the well-known book by Kernighan and Ritchie, “The C Programming Language,” is written in tutorial style, explaining how to do various tasks, using necessary C constructs to accomplish the tasks.</p>
<blockquote><p><strong>Best Practice:</strong> Provide both a reference section and a tutorial section in the detailed documentation of a block.</p></blockquote>
<p>Until the next writing…</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2011/02/the-not-so-exciting-world-of-documentation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Designing a Chip for Unplanned Products</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/12/designing-a-chip-for-unplanned-products/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/12/designing-a-chip-for-unplanned-products/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 03:15:56 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[extra features]]></category>
		<category><![CDATA[performance margins]]></category>
		<category><![CDATA[plan ahead]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=45</guid>
		<description><![CDATA[One of the rules of the Extreme Programming design philosophy for software is Never Add Functionality Early. This means that when coding for one product, do not add features or functionality needed for a future product. While this rule does have some merit for software development, it should be applied more judiciously to hardware development. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the rules of the Extreme Programming design philosophy for software is Never Add Functionality Early. This means that when coding for one product, do not add features or functionality needed for a future product. While this rule does have some merit for software development, it should be applied more judiciously to hardware development.</p>
<p>One of the reasons programmers can get away with that type of thinking is because they can and are able to change software rapidly by simply recompiling and re-executing. Hardware engineers do not have that luxury. It takes months and millions of dollars to produce a different version of the chip. Future costs can be reduced if the chip is designed with the future in mind, with the possibility that it might be used in future products that are currently unplanned.</p>
<p>There is also an aspect of planning for the future where you prepare by building a framework but not putting in the features. That makes it easier to implement the new features in the future but still requires putting out a new version of the chip. But that will be the subject for another issue. For this issue, I am talking about what can be done to make this version of the chip more likely to be used in the future.</p>
<p>Not all known future functionality should be put into the design; time, effort, space and cost will not permit it. But some of it has little risk in terms of complexity, implementation and verification. If a three-bit number might need four bits in the future, making it a four-bit number now has little risk to the program. Adding a couple of extra GPIO lines is also low-risk (assuming there are pins for it.) Adding a block that is new, big and complex could add a lot of risk to the program and needs to be weighed against the potential gain if it were needed.</p>
<p>Extreme Programming says that “only 10% of that extra stuff will ever get used.” But if you put 10 “extra” features in the chip and only one gets used, you could save your company months and millions of dollars.</p>
<blockquote><p><strong>Best Practice:</strong> Include low-risk features in the design of the chip that might be used in future products.</p></blockquote>
<p>Aside from features that might be needed in the future, faster speed is characteristic of future products. Chips are designed with a performance and speed budget. Planning for the future would mean that you also look at the speed of the chip. I have seen cases where existing chips were limited in their usefulness because they were not fast enough and we had to spend lots of time and money to produce a new version just to get the speeds we needed.</p>
<blockquote><p><strong>Best Practice:</strong> Increase the performance margins in the design to allow the chip to be used in faster products in the future.</p></blockquote>
<p>Always looking toward the future…</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/12/designing-a-chip-for-unplanned-products/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Built-in Debugging Support</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/10/built-in-debugging-support/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/10/built-in-debugging-support/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 23:24:29 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[debug hooks]]></category>
		<category><![CDATA[event counters]]></category>
		<category><![CDATA[I/O signals]]></category>
		<category><![CDATA[state machine]]></category>
		<category><![CDATA[uart]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=41</guid>
		<description><![CDATA[After a presentation I gave at a conference, one of the attendees came up and told me about his ASIC design team that consisted of young engineers. They had completed their design and told him that they were done. He then asked the question, “Six months from now when you get the silicon back and [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>After a presentation I gave at a conference, one of the attendees came up and told me about his ASIC design team that consisted of young engineers. They had completed their design and told him that they were done. He then asked the question, “Six months from now when you get the silicon back and it does not work, what are you going to need to diagnose and solve the problems?” They went back to their desks and worked some more.</p>
<p>He taught them a very important principle: Think about what could go wrong and what would be needed to figure that out. Too often, hardware designs assume that nothing will go wrong. It is akin to a software function that does not check the validity of parameters being passed in, or a hardware module that does not synchronize an incoming signal to its clock.</p>
<p>Hardware engineers are good at troubleshooting chips by mounting them to test fixtures and attaching probes. However, when the chip is mounted inside a prototype device, it is often at the expense of not being able to attach the test fixtures. Unfortunately, some problems will not reveal themselves until the chip is inside the actual device running the actual firmware. For situations like this, it’s important for hardware to be designed to assist troubleshooting.</p>
<p>A technique that I have successfully employed is to build firmware-accessible debugging resources into the chip. It is like having a built-in logic analyzer. Here are three types of debugging resources I’ve found particularly useful.</p>
<p>Some devices use a specific number of signal pulses to control certain features. For example, a laser printer generates a horizontal sync pulse to set the size of the paper to be printed. When the printer is operating properly, you probably do not need to know how many pulses occurred. But if something is wrong, you might want to know how many pulses were generated. Maybe only enough pulses for a Letter-size sheet of paper was generated when you are trying to print on a Legal-size sheet. In this case, having a pulse counter on the signal that firmware can read and reset would help solve that problem.</p>
<blockquote><p><strong>Best Practice:</strong> Provide firmware-readable and resettable event counters to track the occurrences of key events in the hardware.</p></blockquote>
<p>Well-designed UARTs allow firmware to read the current levels of the handshaking signals. That helps troubleshoot the RS-232 communications. The same technique can be used for any other I/O signals where knowing the current levels of those signals could help troubleshoot problems.</p>
<blockquote><p><strong>Best Practice:</strong> Provide read access to view the current state of key input and output signal pins.</p></blockquote>
<p>As a general rule, firmware does not need to know the current state of a state machine in hardware. However when there are problems, knowing the state can prove useful. A co-worker was trying to get a new chip going and it would not work. He read the current state of the state machine and discovered that it was stuck in a state waiting for an external signal. He looked at the prototype board and discovered that a resister was missing on that signal line. He solved that problem in a matter of minutes whereas it probably would have taken him hours if that state register had not been there.</p>
<blockquote><p><strong>Best Practice:</strong> Provide a register that shows the current state of each state machine.</p></blockquote>
<p>Until the next bug…</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/10/built-in-debugging-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accommodating Product Changes</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/09/accommodating-product-changes/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/09/accommodating-product-changes/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 16:06:33 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[extra logic]]></category>
		<category><![CDATA[late changes]]></category>
		<category><![CDATA[plan ahead]]></category>
		<category><![CDATA[superblock]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=37</guid>
		<description><![CDATA[Late in the development of a new printer, a third-party print engine that interfaced with a block on the ASIC changed its interface behavior. The print engine would quit sending pulses before the block was done with its job, causing the block to hang waiting for more pulses. This behavior existed in other printer models; [...]]]></description>
			<content:encoded><![CDATA[<p>Late in the development of a new printer, a third-party print engine that interfaced with a block on the ASIC changed its interface behavior. The print engine would quit sending pulses before the block was done with its job, causing the block to hang waiting for more pulses. This behavior existed in other printer models; their associated blocks had support to detect early pulse termination. Because this new printer’s block did not have that support, I had to create a firmware workaround for it.</p>
<p>I tried three different algorithms over a three-week period and finally settled on one, even though under rare circumstances, it had a severe performance penalty. Unfortunately, one particular customer bought several of these printers for a specific application and experienced this rare circumstance that cut print speed in half for every page. Obviously the customer was dissatisfied and threatened to return the printers and cancel the large order, which included other printer models. I spent another two weeks to come up with a fourth algorithm that avoided the penalty. We upgraded the customer’s printers and they were happy.</p>
<p>Had this particular block had the early termination support (at a low cost of a few hundred gates), we could have accommodated this late product change with a one-hour firmware change. Instead, beyond nearly costing us a major contract, it also cost five weeks of engineering effort, thousands of warranty dollars and some damage to our reputation.</p>
<p>In contrast, we had an ASIC that was designed for portrait-format printers that was being investigated for use in landscape-format printers. The ASIC was based off previous ASICs that did support landscape-format printers. The engineers did not remove the landscape-format support even though the ASIC was not targeted for landscape-format printers. ASICs for landscape-format printers require more onboard memory in several places in the pipeline to accommodate longer scan lines. Reducing the memory requirement would have reduced their gate count, but they decided not to do that when they made this ASIC.</p>
<p>After verifying that landscape-format support was still in the ASIC, we used them in landscape-format printers. This saved us millions of dollars and several months from having to develop and produce a new ASIC.</p>
<p>Ideally, every ASIC will support any product, whether old or new, high-end or low-end. Since that is not realistic, choices have to be made. Old functionality can be removed once you are sure that it will never be needed again, even for mid-life kicker products. Functionality with large gate-count requirements that is only needed for specific family lines of products could be removed. But where possible, leave as much functionality in an ASIC, even if not all of it is needed for the targeted products.</p>
<blockquote><p><strong>Best Practice:</strong> Implement and retain all known low-overhead functionality in a block, even if the current requirements do not call for it.</p></blockquote>
<p>Until the next shipment&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/09/accommodating-product-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic Interrupt Behavior</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/08/basic-interrupt-behavior/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/08/basic-interrupt-behavior/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 23:32:11 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[Ack]]></category>
		<category><![CDATA[Enable]]></category>
		<category><![CDATA[interrupts]]></category>
		<category><![CDATA[Mask]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=35</guid>
		<description><![CDATA[On an ASIC, my ISR had to write a 1 in one place and a 0 in another place to acknowledge (ack) the interrupt. The hardware engineer I talked to tried to explain how one was an interrupt bit so that is why it needed a 1, but the other bit is a status bit [...]]]></description>
			<content:encoded><![CDATA[<p>On an ASIC, my ISR had to write a 1 in one place and a 0 in another place to acknowledge (ack) the interrupt. The hardware engineer I talked to tried to explain how one was an interrupt bit so that is why it needed a 1, but the other bit is a status bit it needed a 0 to clear the status. It was a little confusing; my ISR had to clear both bits before it could exit. In most ASICs I had dealt with, I wrote 1s to ack. In a few others, I wrote 0s. To come across one where I had to use both a 1 and a 0 was a new one.</p>
<p>Interrupts are a fundamental part of chips, but there is no standard way of implementing them. This leads to several problems:</p>
<ul>
<li>A chip with blocks leveraged from several sources could have mixed interrupt methods.</li>
<li>Firmware drivers leveraged from one chip to another, or from one block to another, are prone to introducing defects.</li>
<li>Firmware engineers must first study the documentation to determine which method is being used.</li>
</ul>
<p>Having firmware write a 1 to ack an interrupt is the best method to use. Most chips use it so it is more commonly known by firmware engineers. When the hardware issues an interrupt causing firmware to read the value in the interrupt register, there are 1s in the appropriate positions indicating which interrupt or interrupts occurred. So it is an easy step to use that value to ack the interrupt. Otherwise, firmware has to take a 1’s compliment of the value before writing it out. And firmware engineers have to remember to take that 1’s compliment everywhere the acking is done, whether acking with the value read from the interrupt register or using a constant (such as a #define) to specify which bit to use.</p>
<blockquote><p><strong>Best Practice:</strong> Design the interrupt module so that a 1 written to the interrupt register acks the interrupt.</p></blockquote>
<p>Interrupt modules also have the ability to let firmware control whether or not a specific interrupt is allowed to propagate. I have seen this register called the “Enable” register for some chips and the “Mask” register for other chips. And I have also seen the “Mask” register in some chips use a 1 as a mask for allowing interrupts to propagate and other chips use a 0 to mask out the interrupt. Every time I come across an Interrupt “Mask” register, I have to first study the documentation to see if I should use a 0 or a 1.</p>
<p>The best term to use is “Enable” because it is clear in the reader’s mind that to “Enable” an interrupt, you write a 1.</p>
<blockquote><p><strong>Best Practice:</strong> Use “Enable” as the name of the register that controls which interrupts will propagate.</p></blockquote>
<p>These are just a couple of aspects regarding interrupts that should be set as a standard. I will discuss more in future newsletters.</p>
<p>Until the next enabled interrupt…</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/08/basic-interrupt-behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Balancing How Firmware Waits on Hardware</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/05/balancing-how-firmware-waits-on-hardware/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/05/balancing-how-firmware-waits-on-hardware/#comments</comments>
		<pubDate>Sat, 08 May 2010 04:39:50 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[balance]]></category>
		<category><![CDATA[delay]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[interrupts]]></category>
		<category><![CDATA[polling]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=32</guid>
		<description><![CDATA[A common question engineers often wrestle with is how long hardware will take to do a requested task so firmware can take the next step. Engineers implement different designs (both in hardware and firmware) depending on the length of time, and these designs have varying impacts on hardware and firmware complexity and overall system performance. [...]]]></description>
			<content:encoded><![CDATA[<p>A common question engineers often wrestle with is how long hardware will take to do a requested task so firmware can take the next step. Engineers implement different designs (both in hardware and firmware) depending on the length of time, and these designs have varying impacts on hardware and firmware complexity and overall system performance. Understanding their ramifications during the design phase helps balance the load between hardware and firmware.</p>
<p>Based on the hardware and firmware implementation required, we can group these designs into three categories:</p>
<ul>
<li><strong>No Delay</strong> – Hardware completes the task almost immediately. Firmware can assume the task is immediately completed and can safely take the next step.</li>
<li><strong>Short Delay</strong> – Hardware completes the task after a short delay. Firmware must wait momentarily for the task to complete before taking the next step.</li>
<li><strong>Long Delay</strong> – Hardware completes the task after a long delay. The wait time is long enough that firmware should do other processing while waiting for the task to complete before it can take the next step.</li>
</ul>
<p>Let’s take aborts in hardware as an example, since implementations exist in each of the three categories – no, short, and long delays. For some aborts there is no delay; it is a simple matter of returning back to the home or idle state, clearing counters and buffers, and completing other activities that can be done quickly. Such an operation is so quick that it is not necessary for hardware to add extra logic for a status or interrupt bit. In these cases, firmware can initiate the abort and simply move on to the next step, which may be to set up the hardware for the next job. The key is for hardware to complete the abort before firmware tries to access it again.</p>
<blockquote><p><strong>Best Practice:</strong> When the task in hardware is fast enough to complete before the next firmware access, hardware does not need to implement a status or interrupt bit for task completion.</p></blockquote>
<p>Some abort implementations can take several clock cycles to complete, which means that firmware must wait for completion before accessing the block again. If it is a short delay, hardware should provide a status bit that firmware could poll, looping a few times until the task is done, then move on to the next step. If there is a long delay, then hardware should provide an interrupt bit that firmware will enable. Firmware will then do other processing while waiting for the interrupt to occur. Setting up, waiting and responding to an interrupt requires several CPU cycles with task swaps, context switches and semaphore handling. Thus, for firmware, polling a status bit is preferable to managing an interrupt if the task will be done after a short delay.</p>
<p>Where that line should be between short and long delays must be determined on a case-by-case basis and depends on the hardware platform, operating system and performance requirements. The dividing line could even move dynamically depending on the current operating conditions of the product. To give engineers the flexibility of moving that dividing line, the hardware for short and long delays should be the same, implemented with both a status bit and a maskable interrupt. This flexibility allows engineers to calculate or take measurements to count how many loops the polling is taking and determine if polling is acceptable or if interrupts are needed.</p>
<blockquote><p><strong>Best Practice:</strong> Implement both a status bit and a maskable interrupt bit to indicate completion of hardware tasks that take time to complete, whether a short or a long time.</p></blockquote>
<p>For some blocks, the time the abort takes can vary from a short delay if the block is in an idle state to a long delay if the block is busy and needs to gracefully terminate. Since firmware cannot know the current state, it must always assume the worse case. If firmware wants to take advantage of the shorter aborts when they do occur, it could poll for several loops in case the task completes quickly. If not, then enable the interrupt and switch to another task.</p>
<p>To help engineers know how to implement the firmware, put in the block’s documentation the min and max abort times and the conditions in which they will occur. It could be something such as, “if the block is already idle, the abort will complete in 20ns, otherwise it will take 2-3us to complete.”</p>
<blockquote><p><strong>Best Practice:</strong> Document the min and max times that a hardware task will take, including the conditions and states that affect those times.</p></blockquote>
<p>I used aborts for these examples, but the concepts apply for any firmware-initiated hardware task that could take time to complete. Implementing both status and interrupt bits for short- and long-delay hardware tasks allows firmware to balance the system load and performance by using polling loops or interrupts as appropriate.</p>
<p>Until the next interrupt (which will not occur for at least 1,000,000,000,000us)&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/05/balancing-how-firmware-waits-on-hardware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Different Bit Types in Different Registers</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/03/different-bit-types-in-different-registers/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/03/different-bit-types-in-different-registers/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 06:52:08 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[bit types]]></category>
		<category><![CDATA[mixing bit types]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=25</guid>
		<description><![CDATA[Several years ago I came across a register that, at first glance, seemed to be a typical register with several read/write bits. Upon closer inspection, I saw that one bit behaved differently, depending on its state and whether I was writing a 1 or a 0 to it. Since firmware had to handle that one [...]]]></description>
			<content:encoded><![CDATA[<p>Several years ago I came across a register that, at first glance, seemed to be a typical register with several read/write bits. Upon closer inspection, I saw that one bit behaved differently, depending on its state and whether I was writing a 1 or a 0 to it. Since firmware had to handle that one bit differently from the other bits in that register, I saw that it would be difficult for firmware to safely handle both types in the same register. I was able to reduce the risk of mishandling that register by writing macros with generous comments. However, I could not ensure that everybody in the future would know that it was not a typical read/write register and treat it as such.</p>
<p>Although the engineer had valid reasons for designing the register that way, he or she had not anticipated the impact on firmware of mixing different types of bits in the same register. To avoid complexity and risk of firmware defects, different types of bits should be located in different registers. To see why, let’s examine how firmware manages two types of bits – read/write bits and interrupt bits.</p>
<p>With read/write bits, firmware sets and clears bits when needed. It typically first reads the register, modifies the desired bit, then writes the modified value back out. Here is a sample code fragment:</p>
<blockquote>
<pre>tmp = ReadReg (regA);  /* Get the register contents */
tmp |= 0x01;           /* Set bit 0 */
RegWrite (regA, tmp);  /* Write it back out */</pre>
</blockquote>
<p>In the case of interrupt bits, firmware often writes a value with one bit set to acknowledge the desired interrupt while leaving any other pending interrupts untouched.</p>
<blockquote>
<pre>RegWrite (regB, 0x10); /* Ack bit 4 */</pre>
</blockquote>
<p>Mixing the two types of bits in the same register could cause problems. Using the read/write code on interrupt bits causes pending interrupts to inadvertently be acknowledged. Using the interrupt code on read/write bits clears all read/write bits that used to be set. Firmware must take special care to ensure that it does not inadvertently change the wrong bits.</p>
<p>Here is a code fragment that acknowledges bit 4 while taking care not to acknowledge other pending interrupts or modify any read/write bits. In this example, read/write bits are located in positions <code>0x0f</code> and interrupt bits are located in positions <code>0x70</code>.</p>
<blockquote>
<pre>tmp = RegRead (regC);  /* Get the register contents */
tmp &amp;= 0x0f;           /* Keep R/W bits but zero any intr bits */
tmp |= 0x10;           /* Set bit 4 to ack */
RegWrite (regC, tmp);  /* Write it back out */</pre>
</blockquote>
<p>Acknowledging an interrupt changed from a one-step to a four-step operation. A similar code fragment is needed to modify desired read/write bits while leaving alone any pending interrupts.</p>
<p>While there is a way for firmware to safely handle this, it is out of the ordinary and prone to firmware defects. Combining different types of bits into the same register may save registers but it adds unnecessary burden and complexity to firmware. Looking ahead and anticipating the firmware impact can lead to a more reliable and robust solution of placing different types of bits in separate registers.</p>
<blockquote><p><strong>Best Practice:</strong> Segregate different types of bits (read/write, read-only, interrupt, etc.) into different registers.</p></blockquote>
<p>If necessary, read-only bits could be combined with any one of the other types of bits. This is acceptable because no matter how the other bits are handled, firmware writes to the register will not affect the read-only bits.</p>
<p>Until the next bit&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/03/different-bit-types-in-different-registers/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Early Hardware/Firmware Collaboration</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/03/early-hardwarefirmware-collaboration/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/03/early-hardwarefirmware-collaboration/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 19:23:33 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Hw/Fw Interface]]></category>
		<category><![CDATA[collaboration]]></category>
		<category><![CDATA[initial design]]></category>
		<category><![CDATA[signoffs]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=19</guid>
		<description><![CDATA[A few years ago, I was invited to a high-level design review of a new SoC. The proposed design contained an I/O block that needed features added. I successfully convinced them to replace that block instead with an existing block that had the needed features, had seen silicon, and had a functional driver. Months later [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago, I was invited to a high-level design review of a new SoC. The proposed design contained an I/O block that needed features added. I successfully convinced them to replace that block instead with an existing block that had the needed features, had seen silicon, and had a functional driver. Months later on real hardware, bringing up the driver for that block was painless.</p>
<p>This incident illustrates the benefits of early collaboration between hardware and firmware engineers. All too often, though, the early phases of embedded systems projects consist solely of hardware engineers working on the design of the hardware without firmware engineers involved. This practice makes it difficult to produce designs flexible and robust enough to support features that also rely on firmware. By working together, however, hardware and firmware engineers can avoid these problems.</p>
<p>Early collaboration of hardware and firmware engineers (both formally and informally) gets both groups talking to each other. Each group has a different perspective of their respective needs and of the embedded system. Here are some benefits you can expect:</p>
<ul>
<li>Reviewing the system requirements together helps reconcile differences and produce a more comprehensive view of the requirements. This helps assure the design meets the requirements.</li>
<li>Some features can be implemented in either hardware or firmware. Working together, engineers can discuss where the line should be drawn between hardware and firmware, taking into account trade-offs such as performance, flexibility and ease of implementation.</li>
<li>Collaboration ensures the design of the hardware/firmware interface leads to a smoother integration of hardware and firmware into the embedded product as a whole.</li>
</ul>
<p>Hardware and firmware engineers reap these and other benefits when they collaborate early.</p>
<blockquote><p><strong>Best Practice:</strong> Start collaboration between hardware and firmware engineers during the initial hardware high-level design phase.</p></blockquote>
<p>Formal hardware development processes typically include checkpoints with formal reviews and signoffs by key personnel, assuring successful completion of all criteria. Firmware participation in the hardware checkpoints encourages hardware and firmware engineers to review the documentation together and jointly resolve any issues they uncover.</p>
<blockquote><p><strong>Best Practice:</strong> Include firmware representation in reviews and signoffs of hardware checkpoints throughout the life cycle.</p></blockquote>
<p>Until our next collaboration&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/03/early-hardwarefirmware-collaboration/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Welcome to the Embedded Bridge Blog</title>
		<link>http://embeddedgurus.com/embedded-bridge/2010/03/welcome-to-the-embedded-bridge-blog/</link>
		<comments>http://embeddedgurus.com/embedded-bridge/2010/03/welcome-to-the-embedded-bridge-blog/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 14:47:32 +0000</pubDate>
		<dc:creator>Gary Stringham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[bridge]]></category>
		<category><![CDATA[newsletters]]></category>
		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://embeddedgurus.com/embedded-bridge/?p=14</guid>
		<description><![CDATA[Welcome to the new Embedded Bridge blog on the newly-redesigned Embedded Gurus website. So why the word, &#8220;bridge&#8221;? It is not used in the literal sense of bridges that carries human or vehicular traffic. (Although I came across this embedded bridge in Inc Magazine. Roll the mouse over numbers 1 and 4.) I used &#8220;bridge&#8221; in [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the new Embedded Bridge blog on the newly-redesigned Embedded Gurus website. So why the word, &#8220;bridge&#8221;? It is not used in the literal sense of bridges that carries human or vehicular traffic. (Although I came across this embedded bridge in <a title="Inc Magazine" href="http://www.inc.com/rollovers/bridge/index.html" target="_blank">Inc Magazine</a>. Roll the mouse over numbers 1 and 4.)</p>
<p>I used &#8220;bridge&#8221; in the conceptual sense to enable two sides to work together, bridging the gap between the two, and establishing processes, procedures, and protocols between the two. I have written much (<a title="book" href="http://garystringham.com/hwfwbook" target="_blank">book</a> and <a title="newsletters" href="http://garystringham.com/newsletter" target="_blank">newsletters</a>) about hardware and firmware (a.k.a. embedded software), both in terms of their respective engineers and in terms of the design of the interface between hardware and firmware. But I also like to discuss bridging the gap between any two other entities, such as management and engineers or the end user and their embedded systems device.</p>
<p>In addition I&#8217;ll post other musings in the embedded and engineering space. Until next time &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://embeddedgurus.com/embedded-bridge/2010/03/welcome-to-the-embedded-bridge-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

