00001 /* 00002 Trusster Open Source License version 1.0a (TRUST) 00003 copyright (c) 2006 Mike Mintz and Robert Ekendahl. All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, 00006 are permitted provided that the following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, 00009 this list of conditions and the following disclaimer. 00010 * Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation 00012 and/or other materials provided with the distribution. 00013 * Redistributions in any form must be accompanied by information on how to obtain 00014 complete source code for this software and any accompanying software that uses this software. 00015 The source code must either be included in the distribution or be available in a timely fashion for no more than 00016 the cost of distribution plus a nominal fee, and must be freely redistributable under reasonable and no more 00017 restrictive conditions. For an executable file, complete source code means the source code for all modules it 00018 contains. It does not include source code for modules or files that typically accompany the major components 00019 of the operating system on which the executable file runs. 00020 00021 00022 THIS SOFTWARE IS PROVIDED BY MIKE MINTZ AND ROBERT EKENDAHL ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 00023 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 00024 OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL MIKE MINTZ AND ROBERT EKENDAHL OR ITS CONTRIBUTORS 00025 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00027 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00028 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00029 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 00032 //WARNING: This is not a stand-alone header file. It is intended to be used as part of teal.svh 00033 `ifndef __teal_memory__ 00034 `define __teal_memory__ 00035 00036 parameter int MAX_DATA = 1024; 00037 00038 virtual class memory_bank; 00039 extern function new (string path); 00040 00041 //the two methods are pure virtual, you must implement them 00042 `PURE virtual task from_memory (bit [63:0] address, output bit [MAX_DATA - 1:0] value, input int size); 00043 `PURE virtual task to_memory (bit [63:0] address, bit [MAX_DATA - 1:0] value, int size); 00044 00045 extern function bit contains1 (string path); 00046 extern function integer contains2 (bit [63:0] address); 00047 extern function string stats (); 00048 extern function void locate (bit [63:0] first_address, bit [63:0] last_address); 00049 00050 local bit [63:0] first_address_; 00051 local bit [63:0] last_address_; 00052 protected vout log_; 00053 endclass 00054 00055 00056 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00057 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00058 //internal singleton 00059 class memory_impl; 00060 extern function void add_map (string path, bit [63:0] first_address, bit [63:0] last_address); 00061 extern task read (bit [63:0] global_address, output bit [MAX_DATA - 1:0] value, input int size = MAX_DATA); 00062 extern task write (bit [63:0] global_address, input bit [MAX_DATA - 1:0] value, int size = MAX_DATA); 00063 extern function void add_memory_bank (/*owner*/ memory_bank bank); 00064 extern function /*cached*/ memory_bank lookup1 (bit [63:0] address_in_range); 00065 extern function /*cached*/ memory_bank lookup2 (string partial_path); 00066 00067 local memory_bank memory_banks_[$]; 00068 local vout log_; 00069 function new (); log_ = new ("teal::memory_implmentation"); endfunction 00070 endclass 00071 00072 00073 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00074 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00075 function memory_impl memory_get (); 00076 static memory_impl lv;// = new (); //singleton 00077 if (lv == null) lv = new (); 00078 return (lv); 00079 endfunction 00080 00081 00082 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00083 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00084 //The "normal" way to access memory... 00085 00086 //setup a mapping between some global address space and some memory 00087 function void add_map (string path, bit [63:0] first_address, bit [63:0] last_address); 00088 memory_impl impl = memory_get (); 00089 impl.add_map (path, first_address, last_address); 00090 endfunction 00091 00092 00093 //now access it... 00094 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00095 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00096 task read (bit [63:0] global_address, output bit [MAX_DATA - 1:0] value, input int size = MAX_DATA); 00097 memory_impl impl = memory_get (); 00098 impl.read (global_address, value, size); 00099 endtask // teal_add_map 00100 00101 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00102 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00103 task write (bit [63:0] global_address, input bit [MAX_DATA - 1:0] value, int size = MAX_DATA); 00104 memory_impl impl = memory_get (); 00105 impl.write (global_address, value, size); 00106 endtask // teal_add_map 00107 00108 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00109 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00110 function void add_memory_bank (/*owner*/ memory_bank bank); 00111 memory_impl impl = memory_get (); 00112 impl.add_memory_bank (bank); 00113 endfunction 00114 00115 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00116 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00117 function /*cached*/ memory_bank memory_lookup1 (bit [63:0] address_in_range); 00118 memory_impl impl = memory_get (); 00119 return (impl.lookup1 (address_in_range)); 00120 endfunction 00121 00122 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00123 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00124 function /*cached*/ memory_bank memory_lookup2 (string partial_path); 00125 memory_impl impl = memory_get (); 00126 return (impl.lookup2 (partial_path)); 00127 endfunction 00128 00129 `include "teal_memory.sv" 00130 `endif // `ifndef __teal_memory__
![]() Intelligent Design Verification Project: Teal&Truss, Revision: 1.62c |
Copyright (c) 2008-2010 Intelligent Design Verification. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included here: http://www.intelligentdv.com/licenses/fdl.txt |
![]() Doxygen Version: 1.6.3 IDV SV Filter Version: 2.6.3 Sat Jun 19 12:13:42 2010 |