N
Niall
Guest
Howdy all.
I'm essentially trying to make a clock. Here's the code I have, I'll
explain my problems later on (I'm very new to VHDL, so if there are
any design issues with this or whatever, let me know, please):
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY clock IS
PORT( en : IN STD_LOGIC;
per_time : IN TIME;
clk : OUT STD_LOGIC );
END ENTITY clock;
ARCHITECTURE clock_arch OF clock IS
BEGIN
clocking : PROCESS ( en, per_time ) IS
VARIABLE temp : STD_LOGIC := '1';
BEGIN
IF en = '1' THEN
FOR i IN 0 TO 100 LOOP
clk <= temp AFTER per_time;
temp := NOT temp;
END LOOP;
END IF;
END PROCESS clocking;
END ARCHITECTURE;
And here's some testing code:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY clock_tb IS
END ENTITY;
ARCHITECTURE clock_tb_arch OF clock_tb IS
SIGNAL en : STD_LOGIC;
SIGNAL per_time : TIME;
SIGNAL clk : STD_LOGIC;
BEGIN
thing : ENTITY WORK.clock( clock_arch )
PORT MAP ( en, per_time, clk );
stimulous : PROCESS IS
BEGIN
per_time <= 1 NS;
en <= '0';
WAIT FOR 10 NS;
en <= '1';
WAIT FOR 100 NS;
WAIT;
END PROCESS stimulous;
END ARCHITECTURE;
What I'd like this to do is when the enable port is '1' I'd like the
clk port to change state 100 times (This is just for learning, I'll
modify it to suit my needs when they arise, so it serves no use at the
moment). However, I don't get the expected wave signal. Once the
enable port goes high the clk port follows it after 1 ns and doesn't
vary as I hoped it would. This is an image of the outputted waves -
http://twomers.googlepages.com/VHDL_CLOCK_WAVE.JPG
Does anyone know why this is happening, and if so could they suggest a
remedy?
Thanks
I'm essentially trying to make a clock. Here's the code I have, I'll
explain my problems later on (I'm very new to VHDL, so if there are
any design issues with this or whatever, let me know, please):
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY clock IS
PORT( en : IN STD_LOGIC;
per_time : IN TIME;
clk : OUT STD_LOGIC );
END ENTITY clock;
ARCHITECTURE clock_arch OF clock IS
BEGIN
clocking : PROCESS ( en, per_time ) IS
VARIABLE temp : STD_LOGIC := '1';
BEGIN
IF en = '1' THEN
FOR i IN 0 TO 100 LOOP
clk <= temp AFTER per_time;
temp := NOT temp;
END LOOP;
END IF;
END PROCESS clocking;
END ARCHITECTURE;
And here's some testing code:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY clock_tb IS
END ENTITY;
ARCHITECTURE clock_tb_arch OF clock_tb IS
SIGNAL en : STD_LOGIC;
SIGNAL per_time : TIME;
SIGNAL clk : STD_LOGIC;
BEGIN
thing : ENTITY WORK.clock( clock_arch )
PORT MAP ( en, per_time, clk );
stimulous : PROCESS IS
BEGIN
per_time <= 1 NS;
en <= '0';
WAIT FOR 10 NS;
en <= '1';
WAIT FOR 100 NS;
WAIT;
END PROCESS stimulous;
END ARCHITECTURE;
What I'd like this to do is when the enable port is '1' I'd like the
clk port to change state 100 times (This is just for learning, I'll
modify it to suit my needs when they arise, so it serves no use at the
moment). However, I don't get the expected wave signal. Once the
enable port goes high the clk port follows it after 1 ns and doesn't
vary as I hoped it would. This is an image of the outputted waves -
http://twomers.googlepages.com/VHDL_CLOCK_WAVE.JPG
Does anyone know why this is happening, and if so could they suggest a
remedy?
Thanks