Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Start with the first tick of clock

Status
Not open for further replies.

ustinoff

Member level 2
Joined
Mar 6, 2016
Messages
45
Helped
4
Reputation
8
Reaction score
4
Trophy points
8
Location
Russia
Activity points
308
In the picture, the countdown begins from the second tick of the CLK signal. It's very predicteble result if your desing works on "rising_edge" front:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
 
entity p_test is
port(
   en : in std_logic;
   arst : in std_logic;
   clk : in std_logic;
   dout : out std_logic_vector (3 downto 0)
);
end p_test;
 
architecture arch of p_test is
signal counter : unsigned (3 downto 0);
begin
   process(en,clk)
   begin
      if arst = '1' then
         counter <= (others=>'0');
      elsif (rising_edge(clk)) then
          if en = '1' then
     counter <= counter + 1;
     end if;
     end if;
  end process;
dout <= std_logic_vector(counter);
end arch;



But i want to start counting with the first tick of CLK. I know what i need - low front of CLK (CLK = '0') before EN = '1'. Is there another way?

 

This is one advantage of using rising_edge(clk). you have a transition from 'U' to '1'. Is that a rising edge -- from unknown state to '1'?

I don't know how you defined clk, but you should ensure it is '0' before the first transition to '1'.

the older style, (clk'event and clk = '1') would also "work", but the problem really is that you should have clearly defined edges in the simulation.
 

Add initial values of '0' to your clock and enable signal in your testbench.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top