The following code results in a combinational logic warning but I don't see it. Perhaps someone here can explain.
process(clk_count_400hz)
begin
if (clk_count_400hz <= x"002710") then
clk_count_400hz <= clk_count_400hz + 1;
clk_400hz_enable <= '0';
else
clk_count_400hz <= x"000000";
clk_400hz_enable <= '1';
end if;
end process;
I've tried rewriting it in multiple ways but still get the same warning. It seems clk_count_400hz
should simply count up and then the register reset back to 0 when x"002710"
is exceeded.
The following code results in a combinational logic warning but I don't see it. Perhaps someone here can explain.
process(clk_count_400hz)
begin
if (clk_count_400hz <= x"002710") then
clk_count_400hz <= clk_count_400hz + 1;
clk_400hz_enable <= '0';
else
clk_count_400hz <= x"000000";
clk_400hz_enable <= '1';
end if;
end process;
I've tried rewriting it in multiple ways but still get the same warning. It seems clk_count_400hz
should simply count up and then the register reset back to 0 when x"002710"
is exceeded.
1 Answer
Reset to default 3Combinational logic feedback happens when a circuit triggers itself - or is its own input. The simplest form of this is:
Y <= not Y ;
Or add the complexity of a process and it becomes:
process (Y)
begin
Y <= not Y ;
end process ;
Your process is nothing more than a more complicated form the following:
process (clk_count_400hz)
begin
clk_count_400hz <= clk_count_400hz + 1 ;
end process ;
This process updates once every delta cycle. There is no good hardware that does this.
Generally hardware is going to update a counter once every clock. This is coded like:
process (clk)
begin
if rising_edge(Clk) then
clk_count_400hz <= clk_count_400hz + 1 ;
end if ;
end process ;
Applying this to your code, you would have something like:
process(clk)
begin
if rising_edge(Clk) then
if (clk_count_400hz <= x"002710") then
clk_count_400hz <= clk_count_400hz + 1;
clk_400hz_enable <= '0';
else
clk_count_400hz <= x"000000";
clk_400hz_enable <= '1';
end if;
end if;
end process;
The next question you have to solve is how do these objects get their initial value? On technologies that load behavior at powerup (like Xilinx or Altera), you can initialize the signals, however, for static devices (like ASICs, many plds, and Microchip/Actel) a reset signal is required with the flip-flop.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745663993a4639011.html
clk_count_400hz <= clk_count_400hz + 1;
is feedback around combinational logic, which is really bad for synthesis workflows. Put it in a synchronous process to correctly model a synchronous counter. If you don't know why 'feedback around combinational logic' is bad search the term or search 'how to avoid creating latches in your fpga'. – Mikef Commented Nov 17, 2024 at 1:18