| 1 | ---------------------------------------------------------------------------------- |
|---|
| 2 | -- Company: |
|---|
| 3 | -- Engineer: GAMOM Roland Christian |
|---|
| 4 | -- |
|---|
| 5 | -- Create Date: 17:38:35 04/20/2013 |
|---|
| 6 | -- Design Name: |
|---|
| 7 | -- Module Name: Hold_FSM - Behavioral |
|---|
| 8 | -- Project Name: |
|---|
| 9 | -- Target Devices: |
|---|
| 10 | -- Tool versions: |
|---|
| 11 | -- Description: |
|---|
| 12 | -- |
|---|
| 13 | -- Dependencies: |
|---|
| 14 | -- |
|---|
| 15 | -- Revision: |
|---|
| 16 | -- Revision 0.01 - File Created |
|---|
| 17 | -- Additional Comments: |
|---|
| 18 | -- |
|---|
| 19 | ---------------------------------------------------------------------------------- |
|---|
| 20 | library IEEE; |
|---|
| 21 | use IEEE.STD_LOGIC_1164.ALL; |
|---|
| 22 | |
|---|
| 23 | -- Uncomment the following library declaration if using |
|---|
| 24 | -- arithmetic functions with Signed or Unsigned values |
|---|
| 25 | --use IEEE.NUMERIC_STD.ALL; |
|---|
| 26 | |
|---|
| 27 | -- Uncomment the following library declaration if instantiating |
|---|
| 28 | -- any Xilinx primitives in this code. |
|---|
| 29 | --library UNISIM; |
|---|
| 30 | --use UNISIM.VComponents.all; |
|---|
| 31 | |
|---|
| 32 | entity Hold_FSM is |
|---|
| 33 | Port ( Hold_Req : in STD_LOGIC; |
|---|
| 34 | ram_busy : in STD_LOGIC; |
|---|
| 35 | Clk : in STD_LOGIC; |
|---|
| 36 | Reset : in STD_LOGIC; |
|---|
| 37 | Ramsel : out STD_LOGIC; |
|---|
| 38 | Hold_Ack : out STD_LOGIC); |
|---|
| 39 | end Hold_FSM; |
|---|
| 40 | |
|---|
| 41 | architecture Behavioral of Hold_FSM is |
|---|
| 42 | type typ_Hld is (Ht_Lock,Core_Lock,Ht_free); |
|---|
| 43 | signal Holdstate,Hold_st :typ_hld; |
|---|
| 44 | signal Ram_sel :std_logic:='0'; |
|---|
| 45 | signal front_Rbusy,front_hReq:std_logic:='0'; |
|---|
| 46 | begin |
|---|
| 47 | |
|---|
| 48 | hold_sync:process (clk,reset) |
|---|
| 49 | begin |
|---|
| 50 | if rising_edge(clk) then |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | end if; |
|---|
| 54 | end process hold_sync; |
|---|
| 55 | Ramsel_state:process(clk,reset)--,HoldState,Hold_Req,ram_Busy,Front_HReq,Front_RBusy) |
|---|
| 56 | |
|---|
| 57 | begin |
|---|
| 58 | |
|---|
| 59 | if rising_edge(clk) then |
|---|
| 60 | if reset='1' then |
|---|
| 61 | HolDState<=Ht_free; |
|---|
| 62 | else |
|---|
| 63 | -- HolDState<=Hold_St; |
|---|
| 64 | -- Hold_St<=HoldState; |
|---|
| 65 | case HoldState is |
|---|
| 66 | when Ht_free => |
|---|
| 67 | if Hold_Req='1' and ram_busy='0' then |
|---|
| 68 | HolDState <=Core_lock; |
|---|
| 69 | elsif Hold_Req='0' and ram_busy='1' then |
|---|
| 70 | HoldState <=HT_lock; |
|---|
| 71 | else |
|---|
| 72 | HoldState <=HT_free; |
|---|
| 73 | end if; |
|---|
| 74 | when Ht_lock => |
|---|
| 75 | if Hold_Req='0' and ram_busy='0' then |
|---|
| 76 | HoldState <=HT_free; |
|---|
| 77 | elsif Hold_Req='1' and Ram_busy='0' then |
|---|
| 78 | HoldState <=Core_lock; |
|---|
| 79 | else |
|---|
| 80 | HoldState <=HT_lock; |
|---|
| 81 | end if; |
|---|
| 82 | |
|---|
| 83 | When Core_lock => |
|---|
| 84 | If Hold_Req='0' and Ram_busy='0' then |
|---|
| 85 | HoldState <=HT_free; |
|---|
| 86 | elsif Hold_Req='0' and Ram_busy='1' then |
|---|
| 87 | HoldState <=HT_lock; |
|---|
| 88 | else |
|---|
| 89 | HoldState <=Core_lock; |
|---|
| 90 | end if; |
|---|
| 91 | end case ; |
|---|
| 92 | end if; |
|---|
| 93 | end if; |
|---|
| 94 | |
|---|
| 95 | end process; |
|---|
| 96 | |
|---|
| 97 | Ramsel_val:process(HoldState,Hold_Req,Ram_Busy) |
|---|
| 98 | |
|---|
| 99 | begin |
|---|
| 100 | case HoldState is |
|---|
| 101 | when Ht_free => |
|---|
| 102 | ram_sel<='0'; |
|---|
| 103 | Hold_Ack<='0'; |
|---|
| 104 | when Ht_Lock => |
|---|
| 105 | ram_sel<='0'; |
|---|
| 106 | Hold_Ack<='0'; |
|---|
| 107 | when Core_lock => |
|---|
| 108 | Ram_sel <='1'; |
|---|
| 109 | Hold_Ack<='1'; |
|---|
| 110 | end case; |
|---|
| 111 | if Hold_Req= not(front_HReq) then |
|---|
| 112 | front_HReq<= not front_HReq; |
|---|
| 113 | end if; |
|---|
| 114 | |
|---|
| 115 | if Ram_busy= not (front_RBusy) then |
|---|
| 116 | front_RBusy<= not front_RBusy; |
|---|
| 117 | end if; |
|---|
| 118 | end process ramsel_val; |
|---|
| 119 | Ramsel<=Ram_sel; |
|---|
| 120 | --======================================================================= |
|---|
| 121 | end Behavioral; |
|---|
| 122 | |
|---|