hawking1122
Newbie level 2
2 questions about VHDL
Hi, I'm trying to write code for a D type flip flop. Then, there are 2 questions coming up in my mind. Let's first have a look at the code:
library ieee;
use ieee.std_logic_1164.all;
entity dff is
port
(
d,clk,rst: in std_logic;
q: out std_logic
);
end dff;
architecture behavior of dff is
begin
process(clk)
begin
if(rst='1') then
q <= '0';
elsif (clk'event and clk='1') then
q <= d;
end if;
end process;
end behavior;
My 1st question is: The code above works well. But if I replace the code line: elsif (clk'event and clk='1') then with this line:[/b] elsif (clk='1') then[/b], the result will be different. In my opinion, it is apparent that process code block will be executed every time [/b] clk[/b] is changed so we don't need to add [/b]clk'event[/b] inside that code block. Can you explain it for me?
My 2nd question is: What does a variable represent in real electronic circuit. Or more clearly, what would happen with my hardware if I state a new variable? What is the benefit I have if I use a signal instead of a variable?
Your help would be great to me!
Hi, I'm trying to write code for a D type flip flop. Then, there are 2 questions coming up in my mind. Let's first have a look at the code:
library ieee;
use ieee.std_logic_1164.all;
entity dff is
port
(
d,clk,rst: in std_logic;
q: out std_logic
);
end dff;
architecture behavior of dff is
begin
process(clk)
begin
if(rst='1') then
q <= '0';
elsif (clk'event and clk='1') then
q <= d;
end if;
end process;
end behavior;
My 1st question is: The code above works well. But if I replace the code line: elsif (clk'event and clk='1') then with this line:[/b] elsif (clk='1') then[/b], the result will be different. In my opinion, it is apparent that process code block will be executed every time [/b] clk[/b] is changed so we don't need to add [/b]clk'event[/b] inside that code block. Can you explain it for me?
My 2nd question is: What does a variable represent in real electronic circuit. Or more clearly, what would happen with my hardware if I state a new variable? What is the benefit I have if I use a signal instead of a variable?
Your help would be great to me!