embeddedlover
Full Member level 5
- Joined
- Aug 10, 2007
- Messages
- 277
- Helped
- 46
- Reputation
- 92
- Reaction score
- 38
- Trophy points
- 1,308
- Activity points
- 3,155
No latches will be created, a mux is described. All of the 8 possible synthesizable cases of A1, A2, A3 are covered in the large else branch. All synthesizable cases of CTRL1, CTRL2 and EN are covered in the outermost 'if' statement.Actually you can do that fine. It will just create a load of latches because this code doesnt really describe a single mux. If you want to avoid the latches, then yes, you should use if/elsif/else or a case statement.
Actually you can do that fine. It will just create a load of latches because this code doesnt really describe a single mux. If you want to avoid the latches, then yes, you should use if/elsif/else or a case statement.
A process can create only one driver for any signal. Functionally there is nothing wrong with the OP's use of multiple if/endif statements or the mux that is intended.I thought that code would create a bunch of drivers driving a single signal? Regardless, not the way to make a mux.
process(A,CTRL1,CTRL2,EN)
begin
O <= (others => '0');
if not((CTRL1 = '1') or (CTRL2 = '1') or (EN = '0'))then
O(to_integer(A)) <= '1';
end if;
end process;
No latches will be created, a mux is described. All of the 8 possible synthesizable cases of A1, A2, A3 are covered in the large else branch. All synthesizable cases of CTRL1, CTRL2 and EN are covered in the outermost 'if' statement.
Kevin Jennings
I thought that, then compiled it with quartus. I got latches.
If you think about the code, you actually have a load of latches connected to a priority encoder.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
entity dec1to2 is
Port (
A1 : in STD_LOGIC;
X : in STD_LOGIC;
O1 : out STD_LOGIC;
O2 : out STD_LOGIC;
Z : out STD_LOGIC);
end dec1to2;
architecture Behavioral of dec1to2 is
begin
process(A1,X)
begin
if A1 = '0' then
O1 <= '1';O2 <= '0';
end if;
if A1 = '1' then
O1 <= '0';O2 <= '1';
end if;
Z <= NOT X;
end process;
end Behavioral;
An output from a combinatorial circuit only depends on the current state of the inputs. The output from a latch depends on what has happened before. A latch is not combinatorial. There exist some feedback where some signal is used to generate itself.Just a basic question.. How to link my code with architecture.. You guys based on experience are able to say it creates latches, mux, etc.. Can someone explain..
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 process(A1,A2,A3,CTRL1,CTRL2,EN) begin O1 <= '0'; O2 <= '0'; O3 <= '0'; O4 <= '0'; O5 <= '0'; O6 <= '0'; O7 <= '0'; O8 <= '0'; if ((CTRL1 = '1') or (CTRL2 = '1') or (EN = '0'))then null; else if((A1 = '0') and (A2 = '0') and (A3 = '0')) then O1 <= '1'; end if; if((A1 = '1') and (A2 = '0') and (A3 = '0')) then O2 <= '1'; end if; if((A1 = '0') and (A2 = '1') and (A3 = '0')) then O3 <= '1'; end if; if((A1 = '1') and (A2 = '1') and (A3 = '0')) then O4 <= '1'; end if; if((A1 = '0') and (A2 = '0') and (A3 = '1')) then O5 <= '1'; end if; if((A1 = '1') and (A2 = '0') and (A3 = '1')) then O6 <= '1'; end if; if((A1 = '0') and (A2 = '1') and (A3 = '1')) then O7 <= '1'; end if; if((A1 = '1') and (A2 = '1') and (A3 = '1')) then O8 <= '1'; end if; end if; end process;
Yes it does. As shown in above posts, this is also the case for the code in your original post.I mean to ask, if i write a logic with if-else-then and SWITCH case, does both transition into a same RTL schematic after synthesis?
process(A,CTRL1,CTRL2,EN)
begin
O <= (others => '0');
if not((CTRL1 = '1') or (CTRL2 = '1') or (EN = '0'))then
O(to_integer(A)) <= '1';
end if;
end process;
Maybe you're not clearly describing what you mean, but if you have written nothing in the architecture, then nothing will be synthesized. No latch, no flip flop, no gates, nothing at all.Let us assume i haven't written any code in the architecture section (process).. that means no logic.. and just inputs and outputs are declared in entity.. In this case as far as i understand, there must be simple latches in the output RTL schematic to hold the output value..
I don't think so.Hope i am correct in understanding..
Again, you're probably not saying what you mean. You can't assign to any inputs. Only outputs can be assigned.Then assume another case, in which i will be assigning initial values for inputs..
Not sure, but maybe you're meaning to say 'output' rather than 'input' and that you have a process that only assigns default values which would mean something like this...and this intialization i do in a process... Here, all inputs are covered and assigned default values.. In this case also, we will have latches in the RTL schematic because there is no other logic implemented in the process.. So, here what i mean to ask is.. if we don't have a unassigned input-output combination which results in latches in RTL schematic, is that an error?
process(Gazinta)
begin
Gazouta <= '0'; -- Default value
-- But nothing else
end process;
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?