2 * Copyright (c) 2009 Princeton University, and
3 * Regents of the University of California
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * Authors: Hangsheng Wang (Orion 1.0, Princeton)
30 * Xinping Zhu (Orion 1.0, Princeton)
31 * Xuning Chen (Orion 1.0, Princeton)
32 * Bin Li (Orion 2.0, Princeton)
33 * Kambiz Samadi (Orion 2.0, UC San Diego)
39 #include "mem/ruby/network/orion/Buffer/Buffer.hh"
40 #include "mem/ruby/network/orion/Buffer/Register.hh"
41 #include "mem/ruby/network/orion/Buffer/SRAM.hh"
42 #include "mem/ruby/network/orion/OrionConfig.hh"
43 #include "mem/ruby/network/orion/TechParameter.hh"
48 const string
& buffer_model_str_
,
53 uint32_t num_read_port_
,
54 uint32_t num_write_port_
,
55 const OrionConfig
* orion_cfg_ptr_
58 if (buffer_model_str_
== string("SRAM"))
60 m_buffer_model
= BUF_SRAM
;
62 else if(buffer_model_str_
== string("REGISTER"))
64 m_buffer_model
= BUF_REG
;
68 m_buffer_model
= NO_MODEL
;
71 if (m_buffer_model
!= NO_MODEL
)
73 assert(num_entry_
== num_entry_
);
74 assert(line_width_
== line_width_
);
75 assert(num_read_port_
== num_read_port_
);
76 assert(num_write_port_
== num_write_port_
);
78 m_num_entry
= num_entry_
;
79 m_line_width
= line_width_
;
81 m_is_outdrv
= is_outdrv_
;
82 m_num_read_port
= num_read_port_
;
83 m_num_write_port
= num_write_port_
;
85 m_orion_cfg_ptr
= orion_cfg_ptr_
;
86 m_tech_param_ptr
= m_orion_cfg_ptr
->get_tech_param_ptr();
97 double Buffer::get_dynamic_energy(
102 if (m_buffer_model
== BUF_SRAM
)
106 return m_sram_ptr
->calc_e_read(is_max_
);
110 return m_sram_ptr
->calc_e_write(is_max_
);
113 else if (m_buffer_model
== BUF_REG
)
117 return m_reg_ptr
->calc_e_read();
121 return m_reg_ptr
->calc_e_write();
130 double Buffer::get_static_power() const
132 double vdd
= m_tech_param_ptr
->get_vdd();
133 double SCALE_S
= m_tech_param_ptr
->get_SCALE_S();
134 if (m_buffer_model
== BUF_SRAM
)
136 return m_sram_ptr
->calc_i_static()*vdd
*SCALE_S
;
138 else if (m_buffer_model
== BUF_REG
)
140 return m_reg_ptr
->calc_i_static()*vdd
*SCALE_S
;
148 void Buffer::print_all() const
150 cout
<< "Buffer" << endl
;
151 cout
<< "\t" << "Read = " << get_dynamic_energy(true, false) << endl
;
152 cout
<< "\t" << "Write = " << get_dynamic_energy(false, false) << endl
;
153 cout
<< "\t" << "Static power = " << get_static_power() << endl
;
159 if(m_buffer_model
== BUF_SRAM
)
161 uint32_t num_data_end
= m_orion_cfg_ptr
->get
<uint32_t>("SRAM_NUM_DATA_END");
162 const string
& rowdec_model_str
= m_orion_cfg_ptr
->get
<string
>("SRAM_ROWDEC_MODEL");
163 const string
& wl_model_str
= m_orion_cfg_ptr
->get
<string
>("SRAM_WORDLINE_MODEL");
164 const string
& bl_pre_model_str
= m_orion_cfg_ptr
->get
<string
>("SRAM_BITLINE_PRE_MODEL");
165 const string
& mem_model_str
= "NORMAL_MEM";
166 const string
& bl_model_str
= m_orion_cfg_ptr
->get
<string
>("SRAM_BITLINE_MODEL");
167 const string
& amp_model_str
= m_orion_cfg_ptr
->get
<string
>("SRAM_AMP_MODEL");
168 const string
& outdrv_model_str
= m_orion_cfg_ptr
->get
<string
>("SRAM_OUTDRV_MODEL");
169 m_sram_ptr
= new SRAM(
170 m_num_entry
, m_line_width
, m_is_fifo
, m_is_outdrv
,
171 m_num_read_port
, m_num_write_port
, num_data_end
,
172 rowdec_model_str
, wl_model_str
, bl_pre_model_str
, mem_model_str
,
173 bl_model_str
, amp_model_str
, outdrv_model_str
, m_tech_param_ptr
);
175 else if (m_buffer_model
== BUF_REG
)
178 m_reg_ptr
= new Register(m_num_entry
, m_line_width
, m_tech_param_ptr
);