Showing posts with label FPGA. Show all posts
Showing posts with label FPGA. Show all posts

Friday, August 4, 2017

HDL-FPGA Coding Style Guide

Based on all my years of professional and educational experience I'd like to introduce a document detailing general guidelines for VHDL coding style as well as some related to FPGA architecture. 
Even though I've tried to summarize the most important points, it results in a lengthy documentbut it still is useful when starting a new project, or as a reference for coding in HDL (VHDL or Verilog) / FPGA.

Link to the document is as follows. ..... ;) ......

Suggestions are welcome in case any of you have a 'guide/point' that I've missed in the doc.

Have a GrAt DaY ! 

Monday, March 7, 2016

Assembly Code from the Zynq 'C' Code

Introduction


For those who made the first steps in microprocessor's programming using assembly language, still today is nice to see what is assembly code generated from the 'C' code. On the other hand, sometimes it's necessary to write a specific very high speed routine using assembly language. 
The SDK tool in the Vivado (Xilinx) development suite, has a command line that execute a utility that generates the assembly code from the written 'C' code. 

Use of the Xilinx Microprocessor Debugger (XMD) Engine


The XMD is a tool that facilitates debugging programs and verifying systems using the Dual ARM Cortex-A9 (as well as the MicroBlaze and Power PC).
The SDK provides what is called an XMD console, where it is posible to type an XMD command using a Tool Command Language (Tcl) kind of language. 
The XMD console can be open in two different ways: 
  1. When the Debug perspective is activated, the XMD console is automatically open. 
  2. In the C/C++ perspective, do Xilinx Tool -> XMD Console.
An screenshot of the XMD console (in the Debug perspective)  is shows below. 


The XMD console is an standard Tcl console, where it is possible to run any available Tcl commands. The command should be typed following the XMD% prompt. 
Note: there is a more complete (and newer) tool that replaces XMD in some aspects: the Xilinx System Debugger Command-line Interface (XSDB). SDK also provides an XSDB console (this will be explained in a short future). However, there are some commands that are exclusively executed in the XMD console, such as the command we will see next. 

So, getting back to the point of this post, to be able to see the assembly language (and even the machine code) generated from the 'C' code, the XMD command line to type the following: 

arm-xilinx-eabi-objdump -S <complete_path_of_my_project_name>.elf

Here is the complete XMD command typed in the XMD console, no executed yet (note the doble back slash symbol):


The result of this XMD command it shows below, along with titles explaining each part of the file: 


If you browse the resultant file, you will see that is a huge file. But, it's easy to follow if you have some experience in assembly language. 

So, I hope you like this post, moreover, I hope it's somehow useful ! ...

Tuesday, February 16, 2016

Filtering Warning/Info Messages in ISE

Introduction 

After executing some of the available processes in the ISE environment, various and numerous messages are generated. These messages let the designer know the “health” of the project. In some cases, you may want to suppress a particular message from appearing in the “Errors and Warnings Report”. For example, you may get a Warning message about unconnected pins that you intend to be unconnected. ISE allows you to suppress, actually filter, a particular message from subsequent runs of the software. The tool you can use for this purpose is the “Message Filters”.

Messages That Can Be Filtered

Not all the message generated by the different processes can be filtered. You can filter messages that begin with "WARNING" or "INFO" and are followed by a library name and message number. For example, the following message can be filtered:


In this Warning message, Xst is the library name, and 2677 is the warning message number.
Note: ERROR messages cannot be filtered. Likewise, messages for some processes cannot be filtered (for example, messages generated by third-party software, such as the Synopsys software). Anyway, if you try to filter a message that cannot be filtered, a dialog box will come up stating that the message cannot be filtered.

Procedures to Filter Messages in ISE

  1. Once you have your project open, enable message filtering as follows:
    • Open the Design Summary pane by doing Project -> Design Summary/Reports.
    • In the upper pane of the Design Summary, in the Design Overview, select Summary.
    • In the button pane of the Design Summary, select Enable Message Filtering.
    • Note: it is also possible to enable message filtering from the project properties options available at: Project -> Design Properties in the Project Settings pane.
  1. In the Processes pane of Project Navigator, run the process which generate the messages to be filtered. For instance execute the Synthesize-XST process.
  2. In the Design Summary pane, and in the option Errors and Warnings, select the process that generate the messages to be filtered, for instance select Synthesis Messages to filter the messages generated by the synthesis tool. Then, in the main Project Navigator window all the Warnings, Infos and Errors messages related to the synthesis tool should be displayed
  3. To select which messages should be filtered, in the pane listing all the messages highlight (left mouse click) the message to be filtered. If there are several messages of the same type, just select one. Then right-click on the message to filter, and select:
    • Filter All Instances of This Message - to filter out all messages with the same library name and message number, regardless of the message text.
    • Note: there is another options in the filtering menu:
      • Filter This Instance Only - to filter out all messages with the same library name, message number, and text. This option is for just one message in particular, for instance for a specific bit of a bus.
  4. Just to be sure the filter has been correctly setting up, do Edit -> Message Filters, a new window will come up in which the selected Warning/Info to be filtered will be detailed. 
  5. In this window you can:
    • Remove the filter: right-click the filter and select Remove, or click the Remove filter(s) button.
    • Temporarily disable a filter, right-click the filter and select Disable.
    • Activate a disabled filter, right click the Enable.
  6. Re-run the process generating the messages to be filtered. Then, from both the console as well as from the Error and Warning pane the messages should be filtered.

  7. Note: Still the filtered messages are available. Select All Implementation Messages under the Errors and Warnings option in the Design Summary pane. The filtered messages will be displayed with a Yes in the Filtered column.

Caution! 

When you suppress a message, it does not fix the issue. 
Do not filter messages for issues that must be fixed. 
Filter when you know what you are doing. Then, you can focus in warnings that you do need to fix.


Wednesday, October 28, 2015

Intel - Altera .... concern? happiness??

Much has been said about this great commercial operation: Intel acquires Altera. 

For those who work with FPGAs and even more, for those who likes Altera FPGAs, this news rise a big concern. And if we add that while I was at Intel I saw Intel acquiring and selling whole groups of IC designers as fries potates... my concern escalated to unknown levels. 

I found an interesting article about this topic. It explains very clear, as always when is written by Kevin Morris, concerns and assumptions about the future of this union. 

I leave here the link to the article: 

Altera’s Long Game 

Hope you enjoy it !

Friday, October 3, 2014

Reducing Compiling Time in Quartus II

Simple Tip to Save you Some Priceless Time !

In order to reduce compilation time use the rapid recompile option:
On Quartus settings dialog box (Assignments menu -> Settings) under Compilation Process Settings -> Incremental Compilation, turn the Rapid Recompile option ON.

With this option ON, the compiler reuse compilation results to update design for small changes. 

Another option to reduce compilation time is to configure Quartus to use all the processors available in the PC running Quartus. 

Compilation Process Settings -> Parallel Compilation -> Use All Available Processors

One last option is to use the Smart Compilation option. Smart compilation can reduce compilation time by skipping compiler stages that are not required to recompile the design. Smart compilation skips entire compiler stages (such as Analysis and Synthesis) when they are not required. This feature is different from incremental compilation, which you can use to compile parts of your design while preserving results for unchanged parts. 
Compilation Process Settings -> Smart Compilation, turn the Smart Compilation option  ON.

Note: these are simple solutions to simple designs. For complex designs there are other options that will be detailed in other blog.  

Saturday, August 4, 2012

ISE-ModelSim: How to Customize the Wave View Window

In case your simulation is executed using ModelSim, when you invoke any kind of simulation within the ISE environment, ModelSim is automatically opened. By default one of the window that comes up is the Wave View window. In this window only the top entity signals are shown, and ... no any other signal ... So if you want to see internal signals of your design, or maybe you want to change the position and/or color of a signal, maybe you want to add dividers,or utilize many other features offered by ModelSim, you can do that in the window that is automatically opened, but. . . any change in the Wave View window will be kept until ModelSim is closed. When running the same simulation again, you should start with the changes that you want once again from scratch.

I've written a kind of application note that describes the necessary steps to follow, so when you invoke ModelSim from ISE, the Wave View will open (keep) any change you have done to the initial (default) window, containing all the information you want/need for proper verification and easy debug:

C7T AN-05

Happy design!

Saturday, July 7, 2012

Combinational Loop

Introduction

Combinational loops are logical structures that contain no synchronous feedback element. This kind of loops cause stability and reliability problemas,  as we will see in this article, violating the synchronous principles by making feedback with no register in the loop.

Why? How? is generated a combinational loop? 

Basically, a combinational loop es implemented in hardware (gates) when in the written VHDL code describing combinational logic a signal that is in the left side of an assignment statement (that is, to the left of the <= symbol) it also is on the expression at the right side of the signal assignment statement (right of <=). For example the following lines of code generate a combinational loop, as long as they are written in a combinational process or in a concurrent signal assignment statement.

1 acc <= acc + data;
2
3 Z <= Z nand B;
4
5 cnt <= cnt + 1;


However, it's important to point out that if these same statements are written in a clocked process, each of them will generate the respective sequential logic. This is due to the fact that the signal assignment statement in clocked process will generate a register for the assigned signal, therefore the loop will be registered in this case, therefore no combinational loop is generated.

Hardware

The following figure shows a diagram of a combinational loop. 



As it is shown in the figure, the combinational logic output is fedbacked to the same combinational logic without any register in the loop. The logic between the first input an the last output can be made up of one or several levels of combinational logic. It can also have different signals coming in and coming out of that piece of logic, but at least one of the signal is going back (feedback) to the first logic level, as it can be seen in the following figure.


This kind of logic circuit usually is not desired, no wanted to be implemented. Hence, when the synthesis tool finds out about this combinational loop generates a warning message. 
Here is an example of VHDL code that generate a combinational loop when is implemented.

 1 library ieee;
 2 use ieee.std_logic_1164.all;
 3
 4 entity lazo_comb is
 5   port(
 6     a: in  std_logic;
 7     z: out std_logic);
 8 end lazo_comb;
 9
10 architecture beh of lazo_comb is
11
12  signal y: std_logic;

 
13
14 begin
15     z <= y;
16
17 process(a,y)
18  begin
19     y <= y nand a;
20 end process;
21
22 end beh;


The synthesis tool, Synplify in this case, generates the following warning regarding the combinational loop. 



The warning message "found combinational loop at 'y'" means that the signal 'y' is feed-backed to the input of the combinational logic without any register in the loop. This loop can be easily found when seeing the RTL view of the synthesized system, as it can be seen in the following figure. 


Simulation

The simulation of the system (very simple system) is shown in the following figure. 



The ModelSim windows details a lot of information that deserve a detailed analysis. First of all, the top window plots the waveforms of the signals from the described system, whose main expression is in the line 24 of the middle window. The bottom window, Transcript window, generates an error message, saying that the limit of iterations has been reached at 50ns and no stable value has been gotten. In other words, this mean that the system has began to oscillated and remained oscillating. The maximum number of iterations is configurable in ModelSim (Simulate->Runtime Options); as it's in most simulators. By default this value is set to 5000. Another important piece of information can be found in the bottom of the waveform window. There you can read that the number of Delta reached 5000, which is exactly the number maximum of iterations set in the runtime options, and even after that amount of deltas the system is not stable.
Why this simple logic is oscillating? Well, analyzing the true table of the nand gate, while one of the input is stuck at '0', the output will be always '1'. That is happening in the simulation shown above. Whereas, when the input (signal a in the simulation) tries to change to '1', due to the fact the other input is still at '1' the output change to '0', then since the feedback input is '0', the output should go to '1', then that '1' is going back with the other input at '1', the output will go to '0' again, and so on...This is what is called an "unstable combinational loop". This kind of loop should NEVER be used in a real design.
Other point to bring out on this example is the importance of simulating a system. Assuming that we configured the FPGA without any simulation, based on the fact that the synthesis tool just gave us a 'warning'), we'd see an no stable output, spending some time (maybe a lot of time) trying to find out why the output is not stable. Conversely, by doing the simulation the problem would appear at first shot. 

 Code Style

In designs with a large, very large, amount of code lines it is very easy to make mistakes and generate a combinational loop with no intention (as it can be seen in the example above). So, follow certain order when writting the code, trying to maintain a certain flow of data. Also, take a close look at the warnings generated by the synthesis tool. 
In case you deliberately want to implement a combinational loop, write a detailed description of the reason for doing that, and also write a comment in the constraint file. The reason for this last point is due to the fact that the Static Timing Analysis tool (STA) usually increase the minimum period of the system when it founds a combinational loop. Therefore, in this case you should tell to the STA tool to 'ignore' that particular path. The syntax for ignoring a path is 'set_false_path' for the Quartus (Altera) software, and for the ISE (Xilinx) you should use TIG with its resepctivs syntax in both cases.