Needs explanation... thanks

Status
Not open for further replies.

mjvm171

Newbie level 5
Joined
May 5, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,332
I found this code as a part of a whole other code for a clk counter I think, but I can't understand it much and I really need for a project in school... Please help:| thank you

Code:
gen_clken: process(clk, nReset)
begin
if (nReset = '0') then
cnt <= (others => '0');
clk_en <= '1'; --'0';
elsif (clk'event and clk = '1') then
if (cnt = 0) then
clk_en <= '1';
cnt <= clk_cnt; -- loading of clk_cnt when clk_en is disabled
else
if (slave_wait = '0') then
cnt <= cnt -1;
end if;
clk_en <= '0';
end if;
end if;

end process gen_clken;

:grin:
 

What part of the code you don't understand


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
gen_clken: process(clk, nReset)
begin
    if (nReset = '0') then      -- if reset input is 0
        cnt <= (others => '0');
        clk_en <= '1'; --'0';
    elsif (clk'event and clk = '1') then    -- else on rising edge of the clock
        if (cnt = 0) then
            clk_en <= '1';
            cnt <= clk_cnt; -- loading of clk_cnt when clk_en is disabled
        else
            if (slave_wait = '0') then
                cnt <= cnt -1;
            end if;
            clk_en <= '0';
        end if;
    end if;
 
end process gen_clken;



Alex
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…