Get rid of all the _next garbage it's just making the design less readable, perform the assignments of _next signals in the sequential process.
Instead of doing this...
Code VHDL - [expand] |
1
2
3
4
5
6
7
8
9
10
| process (clk, reset) begin
if reset = '1' then
gcounter <= 0;
elsif clk='1' and clk'event then
gcounter <= gcounter_next;
end if;
end process;
gcounter_next <= 0 when gcounter = period
else gcounter +1; |
You should have done the following...
Code VHDL - [expand] |
1
2
3
4
5
6
7
8
9
10
11
| process (clk, reset) begin
if reset = '1' then
gcounter <= 0;
elsif rising_edge(clk) then
if gcounter = period then
gcounter <= 0;
else
gcounter <= gcounter +1;
end if;
end if;
end process; |
This is going to glitch like crazy as all the comaparisons are done with 32-bit values (integer). I guarantee the routing won't be the same for all the bits.
Code VHDL - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| gtick <= '1' when gcounter= 0
else '0';
--Changing Duty Cycle
process(gclose,gopen,gtick,gduty_cycle) begin
gduty_cycle_next<=gduty_cycle;
if gtick='1' then
if gclose ='1' and gduty_cycle >dcycle_min then
gduty_cycle_next<=gduty_cycle-duty_in;
elsif gopen ='1' and gduty_cycle < dcycle_max then
gduty_cycle_next<=gduty_cycle+duty_in;
end if;
end if;
end process; |
I can keep going, but it's just more of the same observations. You need to think about what the code represents. Sequential processes (clocked) end up becoming flip-flops and the combinational processes become the logic between the registers.
You also have an asynchronous reset that is an input to this component. Unless this is a sub-component in a top level that asyncrhonous reset may cause problems as it is unlikely to be debounced or able to make any sort of recovery removal time.
If you coded this properly your 119 lines would have likely been 80 lines or less.
Regards