Home    Bloggers    Messages    Webinars    Resources   
Tw  |  Fb  |  In  |  Rss
Mike Field

Failure Is an Option, Part 2

Mike Field
Page 1 / 4   >   >>
Adam Taylor
Adam Taylor
11/17/2012 6:18:59 AM
User Rank
Blogger
Re: Unexpected code!
Brian good points I did blog about handling metastability in gate level simulations a few months ago like you say it needs careful thought and handling.

 

http://www.programmableplanet.com/author.asp?section_id=2142&doc_id=246999

50%
50%
Brian Davis
Brian Davis
11/16/2012 9:01:35 PM
User Rank
Clever Clogs
Re: Unexpected code!
@Hamster,

"when a flip-flop goes metastable. I don't think simulators allow STD_LOGIC to have a "metastable, so flip a coin" state :-)"

In a timing simulation of the post-implementation design exported by the tools, that sort of thing can be simulated by replacing the vendor FF primitive model with one of your own nefarious design.

If you are using the Xilinx tools, look up "ASYNC_REG" in the constraints guide,
 which turns off the normal "X" propagation timing checks for setup/hold violations.

Also have a look at the X_FDD model in:

%XILINX%\vhdl\src\simprims\simprim_VITAL.vhd

- Brian

50%
50%
Myplanet
Myplanet
11/12/2012 2:01:51 AM
User Rank
Guru
Re: Failure in Design
Hamster, I understood and appreciating your eagerness and enthusiasm to prove some of the old unwritten theorems are not sufficient/correct. I know in certain cases, in combined logic circuits FF's exhibit some unexpected behaviors without any direct impact.

100%
0%
JezmoSSL
JezmoSSL
11/10/2012 7:25:48 AM
User Rank
Blogger
Re: Failure in Design
@hamster

I am working on a blog which talks a bit about testbench techniques because debugging FPGAs is actually pretty hard unless you know all your modules work as you expect. here is a very simple example I wrote for a LFSR clock divider, they can get very complex and are often more complex than the design they are checking, you could develop this one to add setup and hold time checking on all the signals for example, or check that the division ratio is correct.~\Desktop\lfsr.vhd.html
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity lfsr_counter is
  port (
     rst, clk : in std_logic;
    clk_out : out std_logic);
end lfsr_counter;

architecture imp_lfsr_counter of lfsr_counter is
  signal lfsr: std_logic_vector (13 downto 0);
  signal d0, clk_i: std_logic;
  constant countmax: integer:=2685;
begin

  d0 <= lfsr(13) xnor lfsr(4) xnor lfsr(2) xnor lfsr(0) ;

  process(clk,clk_i,lfsr,rst) begin

          if rising_edge(clk) then
                   if rst='1' then
                          clk_i<='0';
                          lfsr <= (others=>'0');
         else     
lfsr <= lfsr(12 downto 0) & d0; if lfsr = std_logic_vector((TO_UNSIGNED(countmax,14))) then clk_i<=not(clk_i); lfsr<=(others=>'0'); end if; end if; clk_out<=clk_i; end if; end process; end architecture imp_lfsr_counter;



 1 library ieee;
 2 use ieee.std_logic_1164.all;
 3 use ieee.numeric_std.all;
 4 
 5 entity test_bench is
 6 ---there are no ports to delare so the entity is empty
 7 end test_bench;
 8 
 9 architecture behavioural of test_bench is
10 --call the device under test from the standard 'work' library
11         component lfsr_counter
12                 port  (
13                          rst, clk : in std_logic;
14                         clk_out : out std_logic);
15         end component;
16 --declare inputs and initialise them
17 signal clock_in : std_logic :='0';
18 signal reset    : std_logic :='0';
19 --declare outputs and intiialise them
20 signal clock_out : std_logic:='0';
21 --clock period definition
22 constant clk_period : time :=10 ns;
23 
24 begin
25 
26         --instantiate the unit under test
27 uut: lfsr_counter port map (
28                         rst     =>       reset,
29                         clk     =>       clock_in,
30                         clk_out =>   clock_out);
31 
32        --generate the clock with 50% duty cycle
33        -- this runs for ever it has no sensitivity list
34 clk_process : process
35 begin
36         clock_in <='0';
37         wait for clk_period/2;
38         clock_in <='1';
39         wait for clk_period/2;
40 end process;
41 --generate the stimulus for the unit under test
42 
43 stim_process :process
44 begin
45         wait for 100 ns;
46         reset<='1';
47         wait for clk_period * 2;
48         reset <='0';
49         wait;
50 
51 end process;
52 
55 
56 
57 end architecture behavioural;
58 
59 
60 
61 


50%
50%
geekyasa
geekyasa
11/9/2012 10:44:29 PM
User Rank
Beginner
Re: Failure in Design
I dont think failiure is an good option to have around. True you cannot get through all the time but failing to achive many times is something which should not be tolerated.

50%
50%
jandecaluwe
jandecaluwe
11/8/2012 5:10:13 AM
User Rank
Blogger
Re: Failure in Design
"In this case, all I wanted to do was to do was create a design where I can prove to myself that metastability exists"

@hamster I think the goal was very clear and I especially like the attitude of not taking anything for granted.  If @Myplanet reads your posts more closely, I'm sure he will understand why he should really congratulate you with your failure :-)

50%
50%
hamster
hamster
11/8/2012 4:05:45 AM
User Rank
Blogger
Re: Failure in Design
In this case, all I wanted to do was to do was create a design where I can prove to myself that metastability exists, and a single flip-flop on an input isn't enough to protect my designs from the errors that metastability can induce.

Even with the silly stuff-up I did when tinkering with the error counter I've done it - I can put my hand on my heart honestly say that metastability induced errors exists, I've seen it in one of my very own designs, and I now have an better understand what is really going on.

For example, when somebody says "sometimes my reset push-button doesn't work correctly - it is due to a metastability" I know they are most likely mistaken.

I also have a lot more understanding of the issues about releasing async resets, have a working frequency counter design that uses GPS for a timebase, learnt how to do manual placement of flip-flops, and a lot more about routing delays within a design.

I'm happy with that.

 

 

50%
50%
jandecaluwe
jandecaluwe
11/8/2012 3:25:31 AM
User Rank
Blogger
Re: Unexpected code!
"Maybe somebody who knows the ISE toolset could help us out with how to better manage errors and warnings?"

@hamster To avoid misunderstandings, let me point out that I wasn't targetting any synthesis tool in particular. Actually, all synthesis tools that I know have the same flaw of letting incomplete sensitivity lists pass with a warning.

There is a lot that can be said about warnings, but let it be clear that this particular case is different from most other ones. In this case, it is impossible for a synthesis tool to generate an implementation whose behavior matches that of the model.

The equivalence with gcc would be a situation where it compiles to object code that is guaranteed to be incorrect, and then warns you about it. 

50%
50%
Myplanet
Myplanet
11/8/2012 2:51:21 AM
User Rank
Guru
Failure in Design
"Well, it's taken a lot of work, but I have achieved failure and am so happy!"

Mike, normally developers are happy, when there are no failures or errors in their design/code. But here you become so happy, when trace some errors in your own design. What is the relevance in finding error in your own design, which means that you had a poor design.

100%
0%
rfindley
rfindley
11/7/2012 5:12:29 PM
User Rank
Blogger
Re: Unexpected code!
@Hamster,

I do the same as you with gcc, and even go one step further.  I use -Werror, which makes warnings into errors.  This forces my programming team to pay attention to all warnings, and helps us all improve our coding... even though it initially causes some groaning when people aren't used to it yet.

50%
50%
Page 1 / 4   >   >>
More Blogs from Mike Field
Over the past few days I have managed to create quite a few designs using the Xilinx Memory Interface Generator (MIG) and they all seem to work.
If I were an evil genius working on a plan for world domination (with regard to enterprise-level data storage solutions) I would be seriously considering building my design around a Zynq All Programmable SoC.
I would like to present to fellow readers of All Programmable Planet a new technique that I have invented to serialize data within the FPGA's main fabric at 1.5Gb/s.
It's time to look at the receiver portion of the link. After a few false starts, Mike Field has found what looks to be a workable design.
As with most things, my feeling is that there is no better way to understand high-speed serial links than to implement one from the ground up, so that is what I've set out to do.
flash poll
follow us on twitter
follow Xilinx on twitter
like us on facebook
like Xilinx on facebook
All Programmable Planet     About Us     Contact Us     Help     Register     Twitter     Facebook     RSS