Hello everyone, I am new to VHDL so basically I need help with vhdl code
that I have to do till friday for college.
I'm working in Xilinx ISE (dev sys is E2LP)
"Design a clock signal generator circuit. Using switches on the
development system, the frequency of the clock signal should be able to
be selected as: 3 Hz, 6 Hz, 12 Hz, 24 Hz, 100 Hz, 1000 Hz and 2000 Hz."
So I have been working on solution but I'm not sure if it is going to
work on E2LP. Any help is going to be appreciated
1 | library IEEE;
|
2 | use IEEE.STD_LOGIC_1164.ALL;
|
3 |
|
4 | entity clock_generator is
|
5 | Port ( clk_sel : in STD_LOGIC_VECTOR(3 downto 0);
|
6 | clk : out STD_LOGIC);
|
7 | end clock_generator;
|
8 |
|
9 | architecture Behavioral of clock_generator is
|
10 | signal clk_int : std_logic := '0';
|
11 | signal clk_freq : integer := 3;
|
12 | begin
|
13 | clk_gen: process(clk_sel)
|
14 | begin
|
15 | case clk_sel is
|
16 | when "0000" => clk_freq := 3;
|
17 | when "0001" => clk_freq := 6;
|
18 | when "0010" => clk_freq := 12;
|
19 | when "0011" => clk_freq := 24;
|
20 | when "0100" => clk_freq := 100;
|
21 | when "0101" => clk_freq := 1000;
|
22 | when "0110" => clk_freq := 2000;
|
23 | when others => null;
|
24 | end case;
|
25 | end process;
|
26 |
|
27 | clk <= not clk_int;
|
28 | clk_int_gen: process(clk)
|
29 | begin
|
30 | clk_int <= not clk_int after (1000000/clk_freq) ns;
|
31 | end process;
|
32 | end Behavioral;
|