Altera_Forum
Honored Contributor
16 years agoProblems with Synthesis ?
Hola All,
I've made some code that describes a counter that first adds one to a count "c", compares its value with an input "N", and if they are the same then a Hold_All bit goes high. I think the problem I'm having is I'm thinking of it like a program, and not hardware. When I implement it on my de1 board the hold_all bit always goes high after 32 clks no matter what my N value is. I tried changing the bit width of N to see if that would have any effect, and it did. When changed to 2 the Hold_all bit goes high at 8 clks . 8 = 2^(2 +1), which is the first number N can't count to. Thanks for the help ~Triston
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
----------------------------------->
Entity Compare_N is
Generic( k :integer :=2);
Port(
clk,clr : in std_logic;
N : in Unsigned(k downto 0);
Hold_all : out std_logic
);
End Compare_N;
---------------------------------->
Architecture Compare_inside of Compare_N is
Signal All_hold_int : std_logic;
Signal c_int : integer range 0 to ((2**(k+1))-1);
Begin
---------- Compare Process -------------------------->
Compare_Me : Process(clk,clr,N)
Variable Num_Val : integer Range 0 to ((2**(k+1))-1);
Variable c : integer range 0 to ((2**(k+1))-1);
begin
Num_Val := To_Integer(N);
--****************************************************************
if (clr ='1') then
c := 0;
All_hold_int <= '0';
elsif(clk'event and clk='1') then
if (All_hold_int = '0') then
c := c + 1;
end if;
-------------------------------
if( c = Num_Val ) then
All_hold_int <= '1';
end if;
-------------------------------
end if;
c_int <= c;
End Process Compare_Me;
---------------------------------------------------------
Hold_All <= All_hold_int;
End Compare_inside;