Stage 2: Design the Hardware

Following on from our first article about selecting the right FPGA, we’re now getting into the nitty-gritty of design.

The chronological progression of an electronic design is an interesting one and also not a uniform one. The process in many industries on how to make something or how to do something is usually fairly well defined.

If you take building a road for example, then the usual process is to; plan the road, design the road, conduct the earthworks needed to build the road, and then pave the road. This process is fairly linear, in that you can’t pave the road before doing the earthworks and you can’t do the earthworks before doing the planning (unless you don’t mind getting it wrong!).

In electronics design now this is not the case, and especially with FPGA designs.

Just as an example, the development of the FPGA’s constraints may have to begin before the component is connected in the schematic. This may be because the pin function is limited to certain pins. Maybe the FPGA IO has to be configured in a certain way for the part to work which is required by the firmware. Either way, this is a problem which requires swapping back and forth between developing the schematic of a board/product and developing the firmware for it.

There is an interesting nuance to this situation however. This means that you can’t finish the schematic before doing some firmware, but you can start the schematic before the firmware. Based on that, this is where we start too.

The Schematic

The schematic capture of a design usually comes when all of the required information about what the PCB is meant to do is available. This is key to the success of a design because, otherwise, you don’t know what you’re designing.

Just a quick note for those of you who are completely unaware of the PCB design process, a schematic is a drawing used to define the interconnect between the components that make up the design. In order to draw the schematic that we need, we also need some software to do it. We use KiCad in house at Circuithinking which is an excellent free software package used at CERN. We highly recommend that you go and have a look or even have a try at the tools they provide.

Some loose requirements were established in the first article and now we can begin to design a board to meet those requirements. If you choose to use Circuithinking as your design service, then we can use our extensive systems in order to provide you with great quality requirements and documentation so that you can maintain your product for years to come. The first step is to architect our design so we know what components we are using.

Design Architecture

Based on the fact that we know we’re going to use a Spartan-3A in our system, we can go ahead and make this the main centre piece of our architecture. We also mentioned that we are going to program the device in passive serial mode, meaning we need an intelligent device to do so: a microcontroller.

The device we’re going to use is the PIC32MX250F128D. This device is perfect for our purposes because we need the 128KB flash it provides in order to store our FPGA’s configuration image.

It also has a couple of SPI (serial Peripheral Interface) ports for us to program the FPGA with to make things easier. We also want a few LED’s in order to debug things along the way and a possible option to program over USB too…

Those are the two big main chunks of the design already sorted and now we just need to decide on some power. The design needs both 1.8V and 3.3V as mentioned in the previous article and they aren’t exceptionally high currents either.
The AP3407 is a switching regulator that is not only cheap but easy to implement and a small footprint, making it ideal for our circumstances. There is a case to be made for linear regulators here, but the complexity added isn’t significant enough to say no to the switchers.

Other than power and logic, all we really need now is connectors and that’s it!

A breadboard uses standard 2.54mm pin headers so using those to break out the FPGA is a must. The programming interface for the PIC microcontroller is also a must and this can use the same 2.54mm pin headers. We also determined from the last article that we want to use USB to power the board and so a USB micro connector is fitted too. And that’s it! Component selection and design architecture is completed.

Some other prerequisites for the schematic…

A schematic needs a few things to be prepared in order to be drawn to completion. The biggest of these is component symbols. Component symbols are drawings which represent the individual parts which make up the design. Some of the more traditional symbols for things like passive components and logic gates are shown below.

Schematic symbols use by circuithinking.com

Traditional Circuit Symbols

Along side these traditional symbols we also need to make symbols for the more complex integrated circuits that are present on the board. We need to do this exercise for the Spartan-3A, the PIC32MX250F128D and the AP3407 IC’s. The other components on the board use standard symbols to be represented and so that completes the symbols we need to start the schematic!

Let’s Draw…

The schematic is now ready to pull in all the constituent symbols in order to make up our design. The process usually means implementing designs made in simulations, datasheets and from the engineers own engineering intuition.

Component values are usually already calculated out by this point and so adding them to the design is a matter of just performing the exercise. After adding the symbols, drawing the connections and then adding annotations so that people understand what is drawn is when you could class the initial draft as being completed.

The latter part of the exercise mentioned is usually a forgotten art and all too often drawings are presented without any context of what is going on. When that happens, it means that anyone else is left hypothetically trying to unravel a ball of string! At the end of the process you end up with something like the drawing below.

PCB Design Schematic (PDF version here)

Because of the complexity of this design this is a single sheet schematic. Having everything drawn on a single sheet is helpful in this circumstance just from a navigation point of view. Larger designs may split up into multiple sheets with hierarchical blocks in order to make large scale designs more readable.

Connectivity is defined by the nets and net names, meaning that any net with the same name is connected.

This is extremely handy when the symbols are as large as they are and when clarity is needed as to what the net actually does. It’s at this stage that the constraints for the nets are also added.

This means that when it comes to the next stage of the process, there are limitations put onto the design that means it will work with the conditions intended. This could be things like trace width constraints, impedance control or specifying which nets are part of differential pairs.

One of the final tasks to complete is to do a formal annotation of the schematic.

Unlike just adding comments for clarity, annotation assigns reference designators to all components in the design.

This is a unique label which makes it easy to reference individual components later on in the process of design and manufacture. A finished schematic like this needs to go through checks for errors and legibility too. There is usually a second set of eyes involved here and maybe a checklist or process that needs to be followed before it’s sent out of the next stage of the process…

The PCB Layout…

So far we’ve produced drawings that describe what the circuit does and how it all connects, but this isn’t something you can just hand over to a PCB manufacturer and expect them to make.

The next step is to make something that is a manufacturable drawing which is our PCB layout. This drawing describes how the components are laid out on a PCB and how they’re connected together physically with copper. There are usually dedicated members of staff that do this sort of job because, especially for large designs, this is a time consuming process.

It’s also an art form to be able to come up with an elegant solution that works with all the constraints set by the engineer. The amount of creative thinking needed in order to route the most difficult designs is tremendous and the web holds some great examples.

The first step is to define a board perimeter. PCB design is usually mechanically constrained in some shape or form. Whether it’s to conform to a case size for a standard form factor, the mechanical dimensions are key to getting things right.

Our design just has to ensure that the standard 2.54mm breadboards can be connected and also be under 100mm x 100mm for cost purposes. Apart from that, everything else is open to interpretation. The next step is to read the ‘Netlist’ produced by the schematic entry program. This populates our screen with all of the components we need to place for the design.

Connectors are usually the first things to place as they are also constrained mechanically most of the time like the board perimeter.

Now that the mechanically constrained bits are done, we need to enter our ‘Stackup’ characteristics into our PCB design tool. PCB’Stackup’ is one of the biggest factors when it comes down to cost. The’Stackup’ defines how many layers there are of copper in the design and also how thick the copper/insulator is that makes these layers up.

Naturally, the more layers you useĀ and the more exotic the materials you choose, the more expensive the design becomes. Below is the’Stackup’ used by the majority of large scale cheap PCB manufacturers in China. It’s a standard 2 layer ‘Stackup’ that uses 1 ounce copper. Defining this along with making sure that the correct constraints have been imported, we can now move onto getting the design routed.

A Standard 2 Layer PCB Stackup

Routing Traces and Going Places

Routing traces and placing components on a PCB can be a very iterative task. Designs usually contain many of the same components (passives mostly) and also have pairs of components that have many traces running between them. Even with that in mind, achieving consistency and an overall good looking design is a challenge to even the most experienced PCB layout engineers.

With this design being fairly small in component count and not using any hard to route components, the layout becomes easier.

The biggest challenge is the 100 pin VQFP package of the Spartan-3A, where 82 individual connections need to be made to the device. On top of that, 40 of these signals are differential pairs meaning that extra routing constraints are put onto the routing of those specific signals. There are a fair few ways to approach a task like this, but we personally believe it’s best to start with the most contentious stuff first. If you have a BGA package, get all the necessary components needed for it to function routed and then break it out. If you have a power supply that needs specific layout instructions applying, then get that done first too.

For this design, the differential pairs are the most contentious so that’s where we started.

After completing the harder to route bits, a lot of the rest of the design is just connecting the dots. Even though the harder to route bits have been done first, fitting things into remaining space is also a fairly hard task to complete. It’s also to easy to get things wrong, especially if the remaining signals being routed have any form of fast data rate on them.

One of the usual mistakes to see at this point is a trace with high frequency content being routed like spaghetti all the way around the board just to get it to fit. It’s always important to remember to constrain your design properly. By doing so you can avoid a lot of these mistakes. This particular design took about an hour or so to complete, and below is the finished layout in KiCad and a generated 3D representation of the finished design.

Finished PCB Layout

3D Model of Finished Layout

Let’s get one made

It’s usually at this point that designs get sent off to the manufacturers (once checked over of course!).

All CAD tools aimed at PCB design have the ability for you to export your design as a set of Gerber files. These files contain the information needed by manufacturers to make the board using their production lines and consist of all the layers you have designed in your tool and a set of drill files for where the manufacturer should drill holes into your board.

Most of the large PCB manufacturers in China now allow you to upload these files in a .zip file, and have them automatically audited which makes the process of ordering your own really simple. I used JLCPCB in this particular instance because the order cost me $2 for 10 boards. This is a perfect example of how ludicrously cheap manufacture of electronics has become and enables us here at Circuithinking to provide you with a great service because of it.

Below is a picture of the boards fully populated after a quick in-house assembly run.

Fully Assembled PCB

Please don’t blow up….

So now we want to test this thing and see if it works. One of the best things to do when you’ve completed your assembly is to buzz out all the power rails just to make sure there is no magic smoke waiting for you when you power it on.

There is nothing quite like going to all the effort of assembling some fine pitch components and then having them blow up in front of you! This particular instance turned out fine and I applied USB power to the board.

It was all good news when power came up which is always a relief! I could see my rails and I could also connect to the PIC32 using a PICKIT3 programmer which was a great sign!

And with that we’ve reached the end of making the hardware. Just as a summary for the steps involved we:

  • Selected the components we wanted based upon the requirements we needed
  • Created symbols for the new components we identified
  • Created the schematic for the design
  • Laid out a PCB in line with what we needed
  • Had the PCB manufactured for us
  • Assembled the device by soldering it all together
  • Did a quick test to see if anything was immediately wrong

This is a very typical breakdown of what a design entails, but at Circuithinking we add more stages into our process to ensure that you always have transparency of what is going on and also can be comfortable in the knowledge that the design has been checked thoroughly.

To learn more about this you can see our systems or contact us. You can also see our specialist FPGA Design Services and PCB Design Services.

In the next article we’re going to start to write some embedded software for the microcontroller on our design. If you’re interested in more PCB design stuff then make sure you visit KiCad and Reddit for some really interesting pointers.

Read the next article in the series here