Presentation is loading. Please wait.

Presentation is loading. Please wait.

مرتضي صاحب الزماني Memory Modeling. مرتضي صاحب الزماني مدل ساده package body Mem_Pkg is constant DataWidth_c : Natural := 8; constant AddrWidth_c : Natural.

Similar presentations


Presentation on theme: "مرتضي صاحب الزماني Memory Modeling. مرتضي صاحب الزماني مدل ساده package body Mem_Pkg is constant DataWidth_c : Natural := 8; constant AddrWidth_c : Natural."— Presentation transcript:

1 مرتضي صاحب الزماني Memory Modeling

2 مرتضي صاحب الزماني مدل ساده package body Mem_Pkg is constant DataWidth_c : Natural := 8; constant AddrWidth_c : Natural := 16; constant MaxDepth_c : Natural := 2 ** AddrWidth_c; -- 64K end Mem_Pkg; … entity Memory_Nty is generic (FileName_g : String(1 to 12):= "memdata_.txt"); port( MemAddr : in Natural; MemData : inout Std_Logic_Vector(Mem_Pkg.DataWidth_c - 1 downto 0); RdWrF : in Std_Logic; CeF : in Std_Logic); -- Chip Select end Memory_Nty;

3 مرتضي صاحب الزماني مدل ساده architecture Memory_a of Memory_Nty is begin -- Memory_a Memory_Lbl : process(MemAddr, MemData, RdWrF, CeF) subtype Data_Typ is Std_Logic_Vector(Mem_Pkg.DataWidth_c - 1 downto 0); subtype MemSize_Typ is integer range 0 to Mem_Pkg.MaxDepth_c - 1; type Mem_Typ is array(MemSize_Typ) of Data_Typ; variable Memory_v : Mem_Typ; begin … end; اشکالات : حافظه ي زياد و زمان شبيه سازي بالا.

4 مرتضي صاحب الزماني مدل کارآ تر فقط براي I/O از std_logic_vector استفاده شود و براي داخل حافظه آرايه ي INTEGER به کاررود. ( براي std_logic معمولا به ازاي هر عنصر، يک بايت گرفته مي شود ). به توابع تبديل type نياز داريم. مقادير metalogical از دست مي روند. عناصر حافظه را مي توان VARIABLE گرفت چون SIGNAL زمان و حافظه ي زيادي مصرف مي کند. ( فقط interface هاي حافظه از نوع سيگنال باشند ).

5 مرتضي صاحب الزماني مدل Fixed Array Caching معمولا براي شبيه سازي به تعداد محدودي از عناصر حافظه دسترسي مي يابيم ( نه مثلا کل 4GB).  از يک آرايه به سايز مثلا 256 استفاده مي کنيم ( به طولي که انتظار داريم کاربر به آن تعداد دسترسي خواهد يافت ). Addr data Addr data Addr data (0) (1) (255) به يک متغير نياز داريم که نشان دهد تا کجا نوشته ايم (max).  با هر دسترسي به حافظه در فيلد آدرسها جستجو مي کنيم. براي نوشتن : به محض يافتن آدرس مورد تقاضا، داده را در آن انديس مي نويسيم. اگر اين آدرس قبلا موجود نبود آن را در آدرس ++max مي نويسيم. براي خواندن : اگر اين آدرس قبلا موجود نبود “XXX..X” را روي خط data قرار مي دهيم.

6 مرتضي صاحب الزماني مدل Fixed Array Caching entity RAM is generic(DataWidth_g : positive := 16; AddrWidth_g : positive := 32); port(Address : in Std_Logic_Vector(AddrWidth_g -1 downto 0); Data : inout Std_Logic_Vector(DataWidth_g -1 downto 0); CeF : in Std_Logic; RdWrF : in Std_Logic); end RAM; architecture RAMFIX_A of RAM is constant CacheSize_c : positive := 255; subtype CacheRange_Typ is integer range 0 to CacheSize_c; type CacheBlock_Typ is record Address: std_logic_vector (AddrWidth_g - 1 downto 0); Data : std_logic_vector (DataWidth_g - 1 downto 0); end record; begin

7 مرتضي صاحب الزماني مدل Fixed Array Caching Mem_Lbl: process(Address, Data, RdWrF, CeF) type RAM_Typ is array (CacheRange_Typ) of CacheBlock_Typ; variable IndexMax_v : CacheRange_Typ := 0; variable RAM_v : RAM_Typ := (others => (Address => (others => 'X'), Data => (others => 'X'))); variable FoundAddr_v : Boolean;

8 مرتضي صاحب الزماني مدل Fixed Array Caching begin if (CeF = '0') or (CeF = 'L') then FoundAddr_v := False; Search_Lbl: for Cache_i in 0 to IndexMax_v loop if RAM_v(Cache_i).Address = Address then -- Already accessed FoundAddr_v := True; if RdWrF'event and -- check for rising edge for a write ((RdWrF = '1') or (RdWrF = 'H')) and ((RdWrF'last_value = '0') or (RdWrF'last_value = 'L')) then RAM_v(Cache_i).Address := Address; RAM_v(Cache_i).Data := Data; elsif ((RdWrF = '1') or (RdWrF = 'H')) then Data <= RAM_v(Cache_i).Data; elsif RdWrF'event and -- check for falling edge for a write ((RdWrF = '0') or (RdWrF = 'L')) and ((RdWrF'last_value = '1') or (RdWrF'last_value = 'H')) then null;

9 مرتضي صاحب الزماني مدل Fixed Array Caching else assert false report "Error in RdWrF signal" severity Warning; end if; exit Search_Lbl; end if; end loop;

10 مرتضي صاحب الزماني مدل Fixed Array Caching if not FoundAddr_v then if RdWrF'event and -- check for rising edge for a write ((RdWrF = '1') or (RdWrF = 'H')) and ((RdWrF'last_value = '0') or (RdWrF'last_value = 'L')) then RAM_v(IndexMax_v).Address := Address; RAM_v(IndexMax_v).Data := Data; if IndexMax_v /= CacheSize_c then IndexMax_v := IndexMax_v + 1; else assert false report "Maximum limit for cache entry is reached" severity note; end if;

11 مرتضي صاحب الزماني مدل Fixed Array Caching elsif ((RdWrF = '1') or (RdWrF = 'H')) then Data 'X'); elsif RdWrF'event and -- check for falling edge for a write ((RdWrF = '0') or (RdWrF = 'L')) and ((RdWrF'last_value = '1') or (RdWrF'last_value = 'H')) then null; else assert false report "Error in RdWrF signal" severity Warning; end if; else -- Ce_F /='0'| 'L' data 'Z'); end if; end process Mem_Lbl; end RamFix_a;

12 مرتضي صاحب الزماني مدل Fixed Page Caching براي هر page address ، يک صفحه از RAM ( و نه يک word ) در دسترس قرار مي گيرد. Addr Data ِ Data … Data (0) (255) Addr Data ِ Data … Data

13 مرتضي صاحب الزماني مدل Dynamic Page Caching مانند Fixed Page اما به صورت ليست پيوندي.


Download ppt "مرتضي صاحب الزماني Memory Modeling. مرتضي صاحب الزماني مدل ساده package body Mem_Pkg is constant DataWidth_c : Natural := 8; constant AddrWidth_c : Natural."

Similar presentations


Ads by Google