Hi there,
I apologize for the unspecific subject, but for me it is like that.
I am working on an FPGA project which consists of a CPU (8bit), a UART, a sensor keypad controller, LCD module controller, and SPI flash controller. Since all these modules need a clock to run, but with different clock speeds I decided to do a dedicated "clock generator" module which divides the various frequencies from the master clock. The "unpredictable behaviour" manifests itself most prominently in this clock generator module; although I assume that there might be other effects as well. The sequence is this:
- I edit a VHDL source file (currently I am working on the keypad controller module)
- I compile the project
- I load the bitstream into the FPGA
- the CPU would not run, or maybe the LCD, or maybe the SPI or the UART
The point I quite do not understand is that the area I made the last changes definitely does have nothing to do with the affected design area (e.g. keypad - LCD). (ha, I am sounding like a SW developer...) Anyway, to give a bit more information here is like I implemented the clock dividers:
****************************** code ****************************** library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all;entity clock_generator is port ( rst : in std_logic; clk_in : in std_logic; -- input clock (25MHz) sel : in std_logic; nWR : in std_logic; ddrive : in std_logic; d_in : in std_logic_vector (7 downto 0); d_out : out std_logic_vector (7 downto 0); cpu_clk : out std_logic; -- CPU clock (3Hz .. 12.5MHz) uart_clk : out std_logic; -- UART clock (115.2kHz:38400b/sec) lcd_clk : out std_logic; -- LCD controller clock (1MHz) key_clk : out std_logic; -- keypad controller clock (333kHz) spi_clk : out std_logic -- SPI controller clock (6.25MHz) ); end clock_generator;
architecture divider of clock_generator is constant SYS_FREQ : integer := 25000000; -- 25MHz constant UART_FREQ : integer := 115200; -- 3*38.4kHz constant LCD_FREQ : integer := 1000000; -- 1MHz constant KEY_FREQ : integer := 333333; -- 333kHz constant SPI_FREQ : integer := 6250000; -- 6.25MHz signal uart_cnt : integer; signal lcd_cnt : integer; signal key_cnt : integer; signal spi_cnt : integer; signal cpu_cnt, cpu_end : std_logic_vector (23 downto 0); signal cpu_div : std_logic_vector (7 downto 0); signal wr_cpu_div : std_logic; begin -- write the clock divider wr_cpu_div