Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clock help

Status
Not open for further replies.

sheenjrg

Programmer
Oct 14, 2003
14
US
Hey guys I need to generate a signal that is low for 8 clk cycles and then high for 8 clk cycles. Which is the shortest way to code for this.
 
Use a 3 bit counter.

here is a sync reset version of the code (just cause i prefer sync reset rather than async, no other reason), same reason goes for my use of unsigned rather than std_logic_vector and signals rather than variables.


-- signal declarations
signal count : unsigned(2 downto 0);
signal hi8low8 : std_logic;

[... snip ...]

process
begin
wait until clock'event and clock= '1';
if reset = '1' then
count <= &quot;000&quot;;
hi8low8 <= '0';
else
-- unsigned signal will roll over when it gets to
-- &quot;111&quot;
count <= count + 1;

if count = unsigned'(&quot;111&quot;) then
hi8low8 <= not hi8low8;
end if;
end if;
end process;

this of course assumes that clock and reset are also declared (in this case in a port declaration to this entity). I didn't include any of the entity/architecture declarations etc.

Of course you could write this lots of ways.
 
Yes I tried that but I don't know why it didn't work.

What I earlier tried was

wait until clk' event and clk ='1';
if rst = '1'then
count <= &quot;000&quot;;
DSP_TOSC_INTV <= '0';
DSP_RESET <= '0';
else

count <= count + 1;
if count = &quot;111&quot; then
DSP_RESET <= not DSP_RESET;
end if;
end if;

end process;

 
What was the problem with this code? Seems ok to me.

Any error messages or other info?
 
No its ok I got it. my bad I didn't define reset.

Thanks a lot dude.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top