Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Non-loop back Down Counter

Status
Not open for further replies.

Punarva

Newbie level 2
Joined
Apr 19, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
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
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top