Professional Documents
Culture Documents
VHDL Code For The Stack System
VHDL Code For The Stack System
VHDL Code For The Stack System
Lab Objective:Implement & Simulating the Stack System using VHDL The block diagram below shows the basic building block of a stack system:
begin process (clock) begin RAM1(0)<=x"0"; RAM1(1)<=x"1"; RAM1(2)<=x"2"; RAM1(3)<=x"3"; RAM1(4)<=x"4"; RAM1(5)<=x"5"; RAM1(6)<=x"6"; RAM1(7)<=x"7"; RAM1(8)<=x"8"; RAM1(9)<=x"9"; RAM1(10)<=x"A"; RAM1(11)<=x"B"; RAM1(12)<=x"C"; RAM1(13)<=x"D"; RAM1(14)<=x"E"; RAM1(15)<=x"F"; case M is when "01" => if full='1' then assert false report "The stack is full" ; elsif (clock'event and clock='1') then state <= state+1; end if; when "10" => if empty='1' then assert false report "The stack is empty"; elsif (clock'event and clock='1') then state <= state-1; end if; when others => state <= state; end case; end process; full <= state(0) and state(1) and state (2) and state (3); empty <= not ( state(0) or state(1) or state(2) or state (3)); address <= conv_integer(state); RAM1(address)<= datain dataout <= RAM1(address) else "ZZZZ"; end architecture; when when m="01"; m="10"
- When the stack is full, we will get a message in the TextIO that the stack is full