process (u_clk, rst)
begin
if rst = '1' then
temp <= (others => '0')
elsif rising_edge (u_clk) then
temp <= temp + 1;
end if;
end process;
Usually, don't use more than one process in one entity.
Below is for your reference.
That's completely false!!
several processes can be described in one entity. You're making the same error as OP in the process description.
if (reset...) then
if (clk'event ...) then
This means that you're waiting for a clock event while you have a reset condition (all registers are tied to their reset condition).
Just take a good book to learn the basics of VHDL, and you'll understand that what you wrote is not going to work.
process (reset,u_clk)
begin
if (reset='0') then
if (u_clk'event and u_clk='1') then
if(t_in=temp) then
out1 <= '0';
else
out1<= 'Z';
temp <= temp + 1;
end if;
end if;
end if;
end process;
But you changed the functionality. In the original code, out1 will be low for one clock cycle.My intention is only to make the entity work as top guy describe.
But you changed the functionality. In the original code, out1 will be low for one clock cycle.
I just noticed another weirdness of the original post. It assumes a clock of 500 MHz, so the design will possibly fail in a timing simulation depending on the used FPGA family.
---------- Post added at 09:29 ---------- Previous post was at 09:26 ----------
P.S.: Here's the waveform generated by the original design (Quartus timing simulation with Cyclone III):
But you changed the functionality. In the original code, out1 will be low for one clock cycle.
I just noticed another weirdness of the original post. It assumes a clock of 500 MHz, so the design will possibly fail in a timing simulation depending on the used FPGA family.
---------- Post added at 09:29 ---------- Previous post was at 09:26 ----------
P.S.: Here's the waveform generated by the original design (Quartus timing simulation with Cyclone III):
It's the same as an empty reset condition. It synthesizes as a clock enable in this case. But I already explained why I would refer to the standard synchronous design structure.What happens when reset=1? Is this an unintended latch?
In simulation, temp is required by VHDL rules to have an initial value of 0 respectively temp'low. The behaviour of uninitialized signals in a synthesized design depends on synthesis settings. An explicite initial condition achieves correspondense of simulation and synthesis with most tools.Also, there may be simulation problems because the initial state of temp is undefined so temp+1=??
signal temp: integer range 0 to 255 := 0;
Yes, that's the subtile difference. You see, why it's meaningless for synthesized VHDL.the difference is that rising_edge requires the previous value of clk to be '0'; clk'event does not
In simulation, temp is required by VHDL rules to have an initial value of 0
My simulator (ActiveHDL) does not assign any initial values, I don't know about others; I'm not aware of any VHDL 'rule' about this. I usually use a construct like the following which explicitly assigns an initial value for simulation:
signal temp:std_logic:='0';
You're probably getting confused. 'U' is a legal std_logic state called "uninitialised". So activeHDL IS initialising the signal.
So uninitialized is initialized?
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?