Edit:
I recommend that you start using the numeric_std library instead of std_logic_unsigned.
This means that "count" will be of type unsigned instead of std_logic_vector.
What you coded is a latch that is enabled by your gating circuit "Enable and Clock".
What you need is a flip-flop that activates on the rising edge of clock. In addition, you do not want to use a clock gate ("Enable and Clock"), but instead want to do a data path enable. The following is the template you need.
Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
process(rst, Clock)beginif rst = '1' then
count <="00000";elsif rising_edge(Clk)thenif Enable ='1' then-- note enable coded separate from clock to ensure synthesis tool support -- Do your counter stuff hereendif;endif;endprocess;
Note, if you have a proper flip-flop, you do not need the final else with the assignment "count <= count".
Thanks for your input. After add in "if rising_edge(Clock)" I'm able to run the functional simulation but I can't get the result for timing simulation. There output is 0.
you didn't take synthworks advice and still have the following in your code:
Code:
s<= Enable and Clock;
elsif s='1' then
This is a race condition in the code between the clock edge and generating an enable in the code based on the clock and the Enable signal. Scheduling wise I think the rising_edge(clock) happens before the transition on s is ever seen.
You also have UpDn in your sensitivity list, which it shouldn't be as it's inside the rising_edge(clock) if statement.
Maybe you need to go back and read up on how to code a process.