vishal_sonam
Full Member level 3
- Joined
- Jan 19, 2012
- Messages
- 187
- Helped
- 14
- Reputation
- 28
- Reaction score
- 14
- Trophy points
- 1,298
- Activity points
- 2,457
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 entity COUNTER is port ( CLK : in std_logic; COUNT : buffer integer range 0 to 18); end entity COUNTER; architecture RTL of COUNTER is begin process (CLK) begin if CLK = ’1’ then if (COUNT >= 12) then COUNT <= 0; else COUNT <= COUNT + 1; end if; end if; end process; end architecture RTL;
CLK : in std_logic;
COUNT : buffer integer range 0 to 18);
end entity COUNTER;
architecture RTL of COUNTER is
begin
process ( CLK )
begin
if rising_edge ( CLK ) then -- edge sensitive instead of level sensitive
if (COUNT >= 12) then
COUNT <= 0;
else
COUNT <= COUNT + 1;
end if;
end if;
end process;
end architecture RTL;
Surprizingly, Quartus treats CLK = '1' identical to rising_edge(CLK) and infers D-FFs for the counter. But why?
Surprizingly, Quartus treats CLK = '1' identical to rising_edge(CLK) and infers D-FFs for the counter. But why?
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity lat is port( enable: in std_logic; Output: out std_logic; Input: in std_logic); end; architecture behavioral of lat is begin -- Infers a latch process (enable, input) is begin if enable = '1' then output <= input; end if; end process; end;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity lat is port( enable: in std_logic; Output: out std_logic; Input: in std_logic); end; architecture behavioral of lat is begin -- Unexpectedly infers a synchronous register process (enable) is begin if enable = '1' then output <= input; end if; end process; end;
There is nothing not compliant about what is going on here. If you have one signal in your sensitivity list and an 'if' statement that compares that signal then you will get a flip flop. In order to infer a latch there must be two signals in the list, the Enable and the Data.I must confess, I never noticed this before. In both Quartus versions, I get the below results by including or excluding the data input in the sensitivity list. I don't think that the behaviour corresponds to the VHDL LRM. I'm also not yet aware of a synthesis attribute controlling the automatic latch to dff conversion.
There is nothing not compliant about what is going on here. If you have one signal in your sensitivity list and an 'if' statement that compares that signal then you will get a flip flop. In order to infer a latch there must be two signals in the list, the Enable and the Data.
The LRM is the defining document...not sure what you mean by 'optionally generate', since a tool that conforms to the LRM will treat the posted code as something that wakes up on any transition on CLK and will only execute the code inside the 'if' statement when CLK is also 1. There are no 'options' per the LRM. From the perspective of synthesis, the only possible interpretation (per the LRM) would be that of a flip flop.From which VHDL specification do you conclude that a level sensitive behavioral description can optionally generate edge sensitive hardware?
I haven't perused 1076.6 in a long time, but the intention of that standard was to create a synthesizable subset of the LRM that synthesis tools were supposed to adhere. I certainly agree that most synthesis tools ignored the sensitivity list and created logic based on what it found in the process (i.e. equivalent to what VHDL-2008 defines as 'process(all)'), but I would find it surprising if 1076.6 allowed that since it would have violated the LRM that was in existence at that time. Such a violation would not be a 'subset' of the LRM. In any case, adherence to the LRM would override adherence to 1076.6...which by the way is no longer even an active standard, it has been withdrawn (https://standards.ieee.org/findstds/standard/1076.6-2004.html).IEEE 1076.6 (Standard for VHDL Register Transfer Level (RTL) Synthesis) e.g. requires an event expression to model edge sensitive logic.
I agreeIt's clear of course that a behavioral simulation would create edge sensitive behaviour in this case by strict evaluation of the sensitivity list. In so far, the observed behaviour results in best possible simulation match.
But that ignoring of the sensitivity list is not compliant with the LRM. Since Quartus is correctly interpreting the code per the LRM, what's the complaint?But we have learned so far that the sensitivity list is effectively ignored in synthesis, and in most cases it surely is.
I'm not actually complaining. I have no problems to describe either a latch or FF and get it synthesized correctly, because I'm used to write a complete description, including a sensitivity list. And I basically know which constructs are synthesizable and which aren't.But that ignoring of the sensitivity list is not compliant with the LRM. Since Quartus is correctly interpreting the code per the LRM, what's the complaint?
It's not a 'level sensitive condition'. If you believe it is it's because you are not considering the sensitivity list consisting of one signal and how the LRM defines the operation of the sensitivity list. I know you understand this, so I want to belabor the point any longer.One of the simple rules of synthesizable VHDL is that you have to write an edge sensitive event expression to infer a FF. And it's still necessary in most cases, I believe. Now we see that in some cases (don't mind whether it's a bug or a feature), a level sensitive condition does the trick. That's at least surprizing.
Certainly not, I was pretty sure that a latch will be inferred.I wonder if I'm the only who's surprized about register inference for the discussed code?
But that ignoring of the sensitivity list is not compliant with the LRM. Since Quartus is correctly interpreting the code per the LRM, what's the complaint?
The sensitivity list was ignored by some synthesis tools in direct violation of the LRM. Per FvM, the withdrawn standard 1076.6 seems to have legitimized this practice, but it is still in contradiction with the governing standard VHDL 1076 (aka LRM). As an aside, I don't believe that 1076.6 allows for the use of 'time' or 'real' in any context, but synthesis tools vendors have moved beyond that as well. Type 'time' and 'real' can now be used to define constants but there was a time when they did not. Tools that might still not support this usage are falling behind their competitors.The sensitivity list is (was?) not needed for synthesis, and that is one big advantage over Verilog.
Then I would suggest you use 'process(all)' instead which was introduce in VHDL-2008.I don't want the sensitivity list to have any effect on the synthesis. It doesn't help me as a designer. It is only confusing.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?