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.

Understanding VHDL code snippet logic ?

Status
Not open for further replies.

syedshan

Advanced Member level 1
Joined
Feb 27, 2012
Messages
463
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,308
Location
Jeonju, South Korea
Activity points
5,134
Dear all,

I am trying to understand a design code where operation starts after trigger, I have a little propblem
in understanding WHY a certain operation is done in the code...


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
29
30
...
port(...
trigger_to_fpga  : in std_logic; -- external trigger to start data capture from ADC
...
);
...
signal ext_trigg_pipe   :std_logic_vector(10 downto 0);
signal ext_trigg_edge  :std_logic; --This signal is the reference for the operations to start
...
...
process (rst, clk)
begin
  if (rst = '1') then
 
    ext_trigg_edge  <= '0';  
    ext_trigg_pipe         <= (others =>'0');
 
  elsif (rising_edge(clk)) then
 
    --couple of deglitching register
    ext_trigg_pipe <= trigger_to_fpga & ext_trigg_pipe(10 downto 1);
 
    if (ext_trigg_pipe(1) = '1' and ext_trigg_pipe(0)='0') then
      ext_trigg_edge <= '1'; --This signal is the reference for the operations to start
    else
      ext_trigg_edge <= '0';
    end if;
 
  end if;
end process;




Here I understand that the purpose is to capture the external trigger removing the glitches or uncertrainities in the external trigger,
but what I dont understand is the usage of ext_trigg_pipe variable's size...Why is it 11 bit, Any suggestion...

Also if I have multuple clock domain, can I replicate (changing signals and clock of course) this to other clocks or do I have to change the
ext_trigg_pipe size.

Many thanks
Shan
 
Last edited by a moderator:

I assume trigger_to_fpga is asynchronous or on another clock domain? For this you will need at least a double register to capture it without metastability. If this is the case, the edge should be checked on 1 and 2, not 0 and 1, as 0 could be metastable.

If the above is not the case, then it could have just been set up as a shift register to align it with other control signals and then not used. The synthesisor will just trim any unused registers.
 

Thank you for your reply,


Yes you guess right, trigger is totally asynchronous.

For this you will need at least a double register to capture it without metastability. If this is the case, the edge should be checked on 1 and 2, not 0 and 1, as 0 could be metastable.

Pardon me, can you explain this thing what you define about bits 1,2 and 0. Can you tell me the logic behind.
Also the concatenation is just the shift register, hence it is there to remove the metastability, right?

Simply put, it is an asynchronous edge detection, right?

Bests,
Shan
 
Last edited:

It is OK to use bit 0 for the edge detection since the new data is clocked into bit 10.
It is enough with 3 bits for synchronization and edge detection, so your circuit is just a synchronization + extra delay + edge detection.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top