kenjo
Newbie level 2
- Joined
- Apr 6, 2015
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 55
Hello,
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.
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.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity top_level is Port ( clk_100MHz : in STD_LOGIC; -- FPGA's external oscillator switch : in STD_LOGIC; -- hooked to slide switch SW(0) on Atlys board RESET: in STD_Logic; leds : out STD_LOGIC_VECTOR (7 downto 0)); -- drives all eight LEDs on board end top_level; architecture Structural of top_level is component ck_divider Port (CK_IN : in STD_LOGIC; CK_OUT : out STD_LOGIC); end component; component rom8x8 PORT (addr : in std_logic_vector(2 downto 0); dout : out std_logic_vector(7 downto 0)); end component; -- 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 : IN STD_LOGIC; wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0); addra : IN STD_LOGIC_VECTOR(2 DOWNTO 0); dina : IN STD_LOGIC_VECTOR(7 DOWNTO 0); douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) ); end component; signal clk_1Hz : STD_LOGIC; signal my_addr_counter : STD_LOGIC_VECTOR (2 downto 0) := "000"; signal dout_rom8x8, dout_bram8x8 : STD_LOGIC_VECTOR (7 downto 0); signal dina_null : STD_LOGIC_VECTOR (7 downto 0); signal data_input : STD_Logic_Vector (7 downto 0); signal wea_null : STD_LOGIC_Vector (0 downto 0); begin clock_divider : ck_divider port map (clk_100MHz, clk_1Hz); -- poor instantiation memory1 : rom8x8 port map (addr => my_addr_counter, dout => dout_rom8x8); -- better instantiation -- Instantiate BRAM. memory2 : my_bram8x8 port map ( 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) is begin if (clk_1Hz'event and clk_1Hz = '1') then case switch is when '0' => leds <= dout_rom8x8; -- Output display of ROM data when '1' => leds <= dout_bram8x8; -- output display of BRAM data when others => NULL; end case; my_addr_counter <= std_logic_vector( unsigned(my_addr_counter) + 1); -- cycles through the address. Initialized to 000 end if; end process; -- 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) is begin if (clk_1Hz'event and clk_1Hz = '1') then if RESET = '1' then dout_bram8x8 <= "00000000" else if (wea_null = '1') then -- statements to write input to selected or current adress if 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; end if; end if; end if; end if; end process; end Structural;
Last edited by a moderator: