I am a bit new to VHDL and am currently trying to write VHDL code to write to a block RAM. I am getting a syntax error "near else" and "near If". I have been trying to figure out what this could mean for quite some time and cannot seem to find a solution. I am guessing it may be something trivial that I am missing but I am not sure. I have listed my code below. Any assistance is appreciated, thanks.
libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;entity top_level isPort( clk_100MHz :inSTD_LOGIC;-- FPGA's external oscillator
switch :inSTD_LOGIC;-- hooked to slide switch SW(0) on Atlys board
RESET:inSTD_Logic;
leds :outSTD_LOGIC_VECTOR(7downto0));-- drives all eight LEDs on boardend top_level;architecture Structural of top_level iscomponent ck_divider
Port(CK_IN :inSTD_LOGIC;
CK_OUT :outSTD_LOGIC);endcomponent;component rom8x8
PORT(addr :instd_logic_vector(2downto0);
dout :outstd_logic_vector(7downto0));endcomponent;-- This component is created using the Core Generator. Its VHDL description-- is inside ipcore_dir/my_bram8x8.vhd, which was created during the use-- Core Generator as explained in the lab.component my_bram8x8
PORT(
clka :INSTD_LOGIC;
wea :INSTD_LOGIC_VECTOR(0DOWNTO0);
addra :INSTD_LOGIC_VECTOR(2DOWNTO0);
dina :INSTD_LOGIC_VECTOR(7DOWNTO0);
douta :OUTSTD_LOGIC_VECTOR(7DOWNTO0));endcomponent;signal clk_1Hz :STD_LOGIC;signal my_addr_counter :STD_LOGIC_VECTOR(2downto0):="000";signal dout_rom8x8, dout_bram8x8 :STD_LOGIC_VECTOR(7downto0);signal dina_null :STD_LOGIC_VECTOR(7downto0);signal data_input :STD_Logic_Vector(7downto0);signal wea_null :STD_LOGIC_Vector(0downto0);begin
clock_divider : ck_divider portmap(clk_100MHz, clk_1Hz);-- poor instantiation
memory1 : rom8x8 portmap(addr => my_addr_counter, dout => dout_rom8x8);-- better instantiation-- Instantiate BRAM.
memory2 : my_bram8x8 portmap(
clka => clk_1Hz, -- clock for writing data to RAM
wea => wea_null, -- write enable signal for Port A
addra => my_addr_counter, -- 3 bit address for the RAM
dina => dina_null, -- 8 bit data input to the RAM
douta => dout_bram8x8);--8 bit data output to the RAM-- select between ROM display and BRAM display
multiplex_out :process(clk_1Hz)isbeginif(clk_1Hz'eventand clk_1Hz = '1')thencase switch iswhen '0' =>
leds <= dout_rom8x8;-- Output display of ROM datawhen '1' =>
leds <= dout_bram8x8;-- output display of BRAM datawhenothers=>NULL;endcase;
my_addr_counter <=std_logic_vector(unsigned(my_addr_counter)+1);-- cycles through the address. Initialized to 000endif;endprocess;-- Pseudo code for Write BRAM-- Begin Process (Trigger on rising edge of clock)-- IF rising_edge of CLK then:-- IF RESET button is pushed THEN set current address data to "0"-- else if write_enable is pushed then prompt for data input-- WHEN specified adress is selected THEN write switch configuration to data_in-- output data_in-- end if's-- end process-- write to BRAM
write_bram :process(clk_1Hz, RESET, wea_null)isbeginif(clk_1Hz'eventand clk_1Hz = '1')thenif RESET = '1' then dout_bram8x8 <="00000000"elseif(wea_null = '1')then-- statements to write input to selected or current adressif my_addr_counter ="000"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="001"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="010"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="011"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="100"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="101"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="110"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;elsif my_addr_counter ="111"then
dina_null <= data_input;
dout_bram8x8 <= dina_null;endif;endif;endif;endif;endprocess;end Structural;
Thanks. I made some changes to the code and now I get this error at the beginning of the first elsif statement: Found '0' definitions of operator "=", cannot determine exact overloaded matching definition for "="
I am not sure what this means. Is it another syntax error? Or should I try and restate this in a different way?
You should not be using a clock divider. You can get ask sorted of problems with logic generated clocks. You should generate a clock enable instead and clock all logic at the 100mhz clock rate