1

Here I have uploaded Simulation Result. In that at highlighted portion it should assign sys_clk to the both signal

I have written vhdl code to assign system clock(Sys_clk) after some delay on defined sclk_1 and sclk_2 signals.

When code run and executed, in simulation after 25 count of the counter, the status of these both signals simply show high (logic level high) instead of system Clock (Sys_Clk).

I'm using Artix 7 Basys -3 Board, and its having 100MHZ system Clock.

Can anyone help me how can I assign system clock (Sys_Clk) on defined signal ??

architecture Behavioral of Power_Sequence is
signal counter : integer := 0;
signal sclk_1 : std_logic := '0';
signal sclk_2 : std_logic := '0';

begin

process(Sys_Clk)

begin

    if(Sys_Clk 'event and Sys_Clk = '1') then
        if(resetb = '0')then
            sclk_1 <= '0';
            sclk_2 <= '0';
        else
            counter <= counter + 1;
            if (counter > 24 and counter < 50) then
            sclk_1 <= Sys_Clk;
            sclk_2 <= Sys_Clk;
            end if;
        end if;
     end if;    
end process;
end Behavioral;
Renaud Pacalet
  • 25,260
  • 3
  • 34
  • 51
Kelvin Kalariya
  • 151
  • 1
  • 1
  • 7
  • 1
    Edit the question and make this an [MCVE]. Include the exact error message you get. At the moment we can't see ANY of the relevant declarations (though the missing semicolon is obvious. The code posted can't even compile, let alone give the wrong results) –  Dec 13 '17 at 12:37
  • A clock signal is a CLOCK signal. You should only connect it to the clock input of synchronous elements. Do not connect it to FF data inputs. By the way, your if statement is only true if Sys_Clk is '1', so it is correct that sclk_tp and sclk_bt will always be high. – Juergen Dec 13 '17 at 13:27
  • What are `sclk_tp` and `sclk_bt`? Are they meant to be `sclk_1` and `sclk_2`? – mkrieger1 Dec 13 '17 at 13:33
  • @mkrieger Yes, both are same. – Kelvin Kalariya Dec 13 '17 at 13:38
  • @KelvinKalariya What you apparently do not understand is that when the simulator executes `sig <= expression;` it evaluates `expression`, assigns the result to `sig` and does not do anything else with `sig` until it executes again a `sig <= expression;` statement. – Renaud Pacalet Dec 13 '17 at 14:08
  • 1
    @KelvinKalariya ...In other words `sclk_1 <= Sys_Clk;` does not mean *starting from now `sclk_1` shall be the same as `Sys_Clk`*. It means: *let `sclk_1` take the current value of `Sys_Clk` and keep it until we assign it another value by executing another `sclk_1 <= expression;`*. – Renaud Pacalet Dec 13 '17 at 14:10
  • @RenaudPacalet .. You are right.. But I wana to make it follow system clock. Is there any alternative you know?? – Kelvin Kalariya Dec 13 '17 at 14:16
  • @KelvinKalariya Yes, see FabienM's response. – Renaud Pacalet Dec 13 '17 at 14:38

1 Answers1

2

Your code can't works. The code in process between lines :

    if(Sys_Clk 'event and Sys_Clk = '1') then
...
    end if;

Will be executed when the Sys_clk is rising. At this moment, the value of the Sys_Clk is '1' ! Then if you copy it on signals sclk_tp and sclk_bt it will always copy '1'.

To make it works you have to assign sclk_tp and sclk_bt signals in an asynchronous process like this:

sclk_tp <= Sys_Clk when (counter > 24 and counter < 50) else '0';

And just use the synchronous process to count.

[edit]

As paebbels explain, the line above is not a good solution to make clock gating. You can find a explanation on this stackoverflow response for colck gating.

FabienM
  • 3,421
  • 23
  • 45