Punarva
Newbie level 2
I am designing a down counter whose features a re as follows,
It is a 9-bit counter, counting from 24 to 0.
After 0, it will not go back to 24, but stalls at 0.
There is a 32 bit input called 'A', which when changes sets back the counter to 24, and it again starts counting.
I tried to use this code,
process(clk, flag)
begin
if (clk'event and clk='1') then
if j="000000000" then
j <= j;
else
j <= j-'1';
end if;
end if;
if (flag'event and flag='1') then
j <= "0000111000" --binary value for 24
end if;
end process;
process(A)
begin
<Statement to generate a pulse on 'flag' signal>
end process
I am not able to write a proper code to generate a pulse on 'flag' signal whenever input changes.
Please tell me any way to do this.
---------- Post added at 22:41 ---------- Previous post was at 22:08 ----------
Got the solution,
process(clk,flag)
begin
if (clk'event and clk='0') then
if j = "000000000" then
j <= j;
else
j <= j - '1';
end if;
end if;
if last_flag /= flag then
j <= "000011000";
last_flag <= flag;
end if;
end process;
process(A)
begin
flag <= not(flag);
end process;
Works fine
It is a 9-bit counter, counting from 24 to 0.
After 0, it will not go back to 24, but stalls at 0.
There is a 32 bit input called 'A', which when changes sets back the counter to 24, and it again starts counting.
I tried to use this code,
process(clk, flag)
begin
if (clk'event and clk='1') then
if j="000000000" then
j <= j;
else
j <= j-'1';
end if;
end if;
if (flag'event and flag='1') then
j <= "0000111000" --binary value for 24
end if;
end process;
process(A)
begin
<Statement to generate a pulse on 'flag' signal>
end process
I am not able to write a proper code to generate a pulse on 'flag' signal whenever input changes.
Please tell me any way to do this.
---------- Post added at 22:41 ---------- Previous post was at 22:08 ----------
Got the solution,
process(clk,flag)
begin
if (clk'event and clk='0') then
if j = "000000000" then
j <= j;
else
j <= j - '1';
end if;
end if;
if last_flag /= flag then
j <= "000011000";
last_flag <= flag;
end if;
end process;
process(A)
begin
flag <= not(flag);
end process;
Works fine