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; |