nested ifs vs elsif

Guest #4199189
Rate this post
• ▲ useful
▼ not useful
Hi all, quick question about if-else, what is the difference in 
describing the 2 counters bellow?
1
my_test:process (CLK, RESETn)
2
begin
3
  -- Clear signals to default values
4
  if RESETn = '0' then
5
            addr_inc <= '0';
6
            load <= '0';
7
            trans_dec <= '0';
8
            address_cnt <= 0;
9
            transfer_cnt <= 0;
10
            reset_cnt <= '1';   
11

12

13
  -- register ...
14
  elsif rising_edge(CLK) then
15

16

17
        -- memory address counter 
18
        if reset_cnt = '1' then
19
                address_cnt <=0;           -- reset counter
20
        else
21
                if load = '1' then
22
                        address_cnt <= to_integer(unsigned( head(14 downto 7) ));   -- load value from header
23
                else
24
                        if addr_inc = '1' then
25
                        address_cnt <= address_cnt + 1;                             -- increment by one
26
                        end if;
27
                end if;
28
        end if;
29
        -- memory transfer size counter 
30
        if reset_cnt = '1' then
31
                transfer_cnt <= 0;                                          -- reset counter
32
        elsif load = '1' then
33
                transfer_cnt <= to_integer(unsigned( head(6 downto 3) ));   -- load value from header
34
        elsif trans_dec = '1' then
35
                transfer_cnt <= transfer_cnt - 1;                           -- decrement by one
36
        end if;
37

38
  end if;
39
end process my_test;

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.