--------------------------------------------------------------------------<br />-- Download and save file as mem_tb.vhd<br...
Mem Tb
Mem Tb
Mem Tb
Upcoming SlideShare
Loading in …5
×

Mem Tb

366 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
366
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mem Tb

  1. 1. --------------------------------------------------------------------------<br />-- Download and save file as mem_tb.vhd<br />-- AUB<br />-- EECE 321 - Computer Organization, Spring 2009<br />-- Author: M. M.<br />--------------------------------------------------------------------------<br />-- Description: Testbench for memory simulator<br />--------------------------------------------------------------------------<br />library ieee;<br />use ieee.std_logic_1164.all;<br />use ieee.std_logic_unsigned.all;<br />use ieee.std_logic_arith.all;<br />use ieee.std_logic_misc.all;<br />USE ieee.std_logic_textio.all;<br />USE std.textio.all;<br />LIBRARYwork;<br />USE work.auxiliary.all;<br />-- Dummy entity<br />ENTITY mem_tb is<br />END mem_tb;<br />-- Memory simulator architecture<br />ARCHITECTURE mem_tb of mem_tb is <br />-- input and output file name<br />CONSTANT in_fname : STRING := " ..iomem_input_file.txt" ;<br />CONSTANT out_fname : STRING := " ..iomem_image_file.txt" ;<br />BEGIN<br />mem_behavior: process is<br />VARIABLE mem : MEM_ARRAY(0 to 63);<br />VARIABLE word : MIPS_WORD;<br />VARIABLE data : INTEGER;<br />BEGIN<br />-- initialize memory<br />init_mem(in_fname, mem);<br />-- load memory contents and print them<br />for i in mem'range loop<br />word := load_word(mem,4*i); -- note byte address<br />report " word at byte address " & integer'image(i) & " = " & integer'image(conv_integer(word));<br />end loop;<br />-- perform some store operations<br />data := 16#22#;<br />word := conv_std_logic_vector(data,word'length); -- convert data into a 32-bit vector<br />store_word(mem,word,16#4#);<br />data := 16#33#;<br />word := conv_std_logic_vector(data,word'length); -- convert data into a 32-bit vector<br />store_word(mem,word,16#C#);<br />data := 16#44#;<br />word := conv_std_logic_vector(data,word'length); -- convert data into a 32-bit vector<br />store_word(mem,word,16#14#);<br />-- print new memory contents onto console<br />for i in mem'range loop<br />word := load_word(mem,4*i); -- note byte address<br />report " word at byte address " & integer'image(i) & " = " & integer'image(conv_integer(word));<br />end loop;<br />-- copy contents of memory into an external file<br />copy_mem_2_file(out_fname, mem);<br />-- perform other memory functions<br />wait;<br />END process mem_behavior;<br />END mem_tb;<br />

×