Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ramulator_bazel
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songxinkai
ramulator_bazel
Commits
230065be
Commit
230065be
authored
Nov 01, 2019
by
songxinkai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
async ram
parent
29ddcdc3
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
37 deletions
+101
-37
build.sh
+1
-0
questions.txt
+3
-0
ramulator/BUILD
+16
-0
ramulator/ram.cpp
+40
-26
ramulator/ram.h
+13
-8
ramulator/testram.cpp
+3
-3
ramulator/testram_break.cpp
+24
-0
run.sh
+1
-0
No files found.
build.sh
View file @
230065be
#!/bin/bash
#!/bin/bash
bazel build
--copt
=
"-DRAMULATOR"
//ramulator:main
bazel build
--copt
=
"-DRAMULATOR"
//ramulator:main
bazel build
--copt
=
"-DRAMULATOR"
//ramulator:testram
bazel build
--copt
=
"-DRAMULATOR"
//ramulator:testram
bazel build
--copt
=
"-DRAMULATOR"
//ramulator:testram_break
questions.txt
0 → 100644
View file @
230065be
1. burst len是多长?能控制吗?
2. 调用一次send能读到多少数据?
3. Dram的频率是多少?和处理器怎么适配?
ramulator/BUILD
View file @
230065be
cc_binary(
cc_binary(
name="testram_break",
srcs=[
"testram_break.cpp",
],
deps=[
"ram",
],
copts=[
"-O3",
"-std=c++11",
"-g",
"-Wall",
],
)
cc_binary(
name="testram",
name="testram",
srcs=[
srcs=[
"testram.cpp",
"testram.cpp",
...
...
ramulator/ram.cpp
View file @
230065be
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
template
<
typename
T
>
template
<
typename
T
>
Ram
<
T
>::
Ram
(
const
std
::
string
&
config_file
){
Ram
<
T
>::
Ram
(
const
std
::
string
&
config_file
){
clk_
=
0
;
clk_
=
0
;
processor_frequency_ratio
_
=
1
;
frequency
_
=
1
;
Config
configs
(
config_file
);
Config
configs
(
config_file
);
const
std
::
string
&
standard
=
configs
[
"standard"
];
const
std
::
string
&
standard
=
configs
[
"standard"
];
assert
(
standard
!=
""
||
"DRAM standard should be specified."
);
assert
(
standard
!=
""
||
"DRAM standard should be specified."
);
...
@@ -93,32 +93,47 @@ void Ram<T>::InitMemory(const Config& configs, T* spec){
...
@@ -93,32 +93,47 @@ void Ram<T>::InitMemory(const Config& configs, T* spec){
memory_
=
std
::
make_shared
<
Memory
<
T
,
Controller
>
>
(
configs
,
ctrls
);
memory_
=
std
::
make_shared
<
Memory
<
T
,
Controller
>
>
(
configs
,
ctrls
);
}
}
// Loop: memory_->tick()
template
<
typename
T
>
template
<
typename
T
>
long
Ram
<
T
>::
AccessMemory
(
const
long
req_addr
,
const
Request
::
Type
req_type
){
void
Ram
<
T
>::
WaitUntil
(
const
double
time
){
long
tmp_clk
=
0
;
long
ram_time
=
long
(
std
::
ceil
(
time
*
frequency_
));
while
(
clk_
<
ram_time
){
memory_
->
tick
();
clk_
++
;
}
}
// Loop: memory_->tick()
template
<
typename
T
>
void
Ram
<
T
>::
WaitFor
(
const
double
time
){
long
ram_time
=
long
(
std
::
ceil
(
time
*
this
->
frequency_
));
for
(
long
i
=
0
;
i
<
ram_time
;
++
i
){
memory_
->
tick
();
clk_
++
;
}
}
// memory_->send() and memory_->tick()
template
<
typename
T
>
void
Ram
<
T
>::
AccessCommand
(
const
long
req_addr
,
const
Request
::
Type
req_type
){
bool
data_return
=
false
;
bool
data_return
=
false
;
long
req_addr_param
=
req_addr
;
long
req_addr_param
=
req_addr
;
auto
req_type_param
=
req_type
;
auto
req_type_param
=
req_type
;
auto
callback
=
std
::
function
<
void
(
Request
&
)
>
([
&
data_return
](
Request
&
rq
){
data_return
=
true
;});
auto
clk
=
this
->
clk_
;
auto
callback
=
std
::
function
<
void
(
Request
&
)
>
(
[
&
data_return
,
clk
,
this
](
Request
&
rq
){
data_return
=
true
;
std
::
cout
<<
"send at: "
<<
clk
<<
", recieve at: "
<<
this
->
clk_
<<
" ("
<<
this
->
clk_
-
clk
<<
")"
<<
std
::
endl
;
});
Request
req
(
req_addr_param
,
req_type_param
,
callback
,
0
);
Request
req
(
req_addr_param
,
req_type_param
,
callback
,
0
);
memory_
->
send
(
req
);
memory_
->
send
(
req
);
while
(
!
data_return
){
memory_
->
tick
();
memory_
->
tick
();
clk_
++
;
clk_
++
;
tmp_clk
++
;
}
return
ConvertCyclesRam2Processor
(
tmp_clk
);
}
}
template
<
typename
T
>
template
<
typename
T
>
long
Ram
<
T
>::
AccessMemory
(
const
long
send_clk_processor
,
const
long
req_addr
,
const
Request
::
Type
req_type
){
double
Ram
<
T
>::
AccessAndWaitUntilReturn
(
const
long
req_addr
,
const
Request
::
Type
req_type
){
long
send_clk
=
ConvertCyclesRam2Processor
(
send_clk_processor
);
long
tmp_clk
=
0
;
long
tmp_clk
=
0
;
while
(
clk_
<
send_clk
){
memory_
->
tick
();
clk_
++
;
tmp_clk
++
;
}
bool
data_return
=
false
;
bool
data_return
=
false
;
long
req_addr_param
=
req_addr
;
long
req_addr_param
=
req_addr
;
auto
req_type_param
=
req_type
;
auto
req_type_param
=
req_type
;
...
@@ -130,28 +145,27 @@ long Ram<T>::AccessMemory(const long send_clk_processor, const long req_addr, co
...
@@ -130,28 +145,27 @@ long Ram<T>::AccessMemory(const long send_clk_processor, const long req_addr, co
clk_
++
;
clk_
++
;
tmp_clk
++
;
tmp_clk
++
;
}
}
return
Convert
CyclesRam2Processor
(
tmp_clk
);
return
Convert
RamCycle2Realtime
(
tmp_clk
);
}
}
template
<
typename
T
>
template
<
typename
T
>
long
Ram
<
T
>::
ConvertCyclesRam2Processor
(
const
long
cycles
){
double
Ram
<
T
>::
ConvertRamCycle2Realtime
(
const
long
cycles
){
return
long
(
double
(
cycles
)
*
processor_frequency_ratio_
)
;
return
double
(
cycles
)
/
frequency_
;
}
}
template
<
typename
T
>
template
<
typename
T
>
long
Ram
<
T
>::
Convert
CyclesProcessor2Ram
(
const
long
cycles
){
long
Ram
<
T
>::
Convert
Realtime2RamCycle
(
const
double
realtime
){
return
long
(
double
(
cycles
)
/
processor_frequency_ratio
_
);
return
long
(
double
(
realtime
)
*
frequency
_
);
}
}
template
<
typename
T
>
template
<
typename
T
>
void
Ram
<
T
>::
SetProcessorFrequencyRatio
(
const
double
r
){
void
Ram
<
T
>::
SetFrequency
(
const
double
r
){
void
SetProcessorFrequencyRatio
(
const
double
r
);
this
->
frequency_
=
r
;
this
->
processor_frequency_ratio_
=
r
;
}
}
template
<
typename
T
>
template
<
typename
T
>
long
Ram
<
T
>::
GetClockProcessor
(){
double
Ram
<
T
>::
GetClockRealtime
(){
return
this
->
clk_
*
processor_frequency_ratio
_
;
return
double
(
this
->
clk_
)
*
frequency
_
;
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
ramulator/ram.h
View file @
230065be
...
@@ -32,16 +32,21 @@ class Ram{
...
@@ -32,16 +32,21 @@ class Ram{
public
:
public
:
Ram
(
const
std
::
string
&
config_file
);
Ram
(
const
std
::
string
&
config_file
);
~
Ram
();
~
Ram
();
long
AccessMemory
(
const
long
req_addr
,
const
Request
::
Type
req_type
);
// Loop: memory_->tick()
long
AccessMemory
(
const
long
send_clk_processor
,
const
long
req_addr
,
const
Request
::
Type
req_type
);
void
WaitUntil
(
const
double
time
);
long
ConvertCyclesRam2Processor
(
const
long
cycles
);
void
WaitFor
(
const
double
time
);
long
ConvertCyclesProcessor2Ram
(
const
long
cycles
);
// memory_->send() and memory_->tick()
void
SetProcessorFrequencyRatio
(
const
double
r
);
void
AccessCommand
(
const
long
req_addr
,
const
Request
::
Type
req_type
);
long
GetClockProcessor
();
// memory_->send() and Loop: memory_->tick(), return: realtime from send to return
long
GetClockRam
();
double
AccessAndWaitUntilReturn
(
const
long
req_addr
,
const
Request
::
Type
req_type
);
double
ConvertRamCycle2Realtime
(
const
long
ram_cycle
);
long
ConvertRealtime2RamCycle
(
const
double
realtime
);
void
SetFrequency
(
const
double
r
);
double
GetClockRealtime
();
// unit: ns
long
GetClockRam
();
// unit: ram cycle
protected:
protected:
void
InitMemory
(
const
Config
&
configs
,
T
*
spec
);
void
InitMemory
(
const
Config
&
configs
,
T
*
spec
);
double
processor_frequency_ratio_
;
double
frequency_
;
// unit: Ghz
long
clk_
;
long
clk_
;
std
::
shared_ptr
<
Memory
<
T
,
Controller
>
>
memory_
;
std
::
shared_ptr
<
Memory
<
T
,
Controller
>
>
memory_
;
};
};
ramulator/testram.cpp
View file @
230065be
...
@@ -12,12 +12,12 @@ int main(int argc, const char *argv[]){
...
@@ -12,12 +12,12 @@ int main(int argc, const char *argv[]){
return
0
;
return
0
;
}
}
Ram
<
ramulator
::
DDR3
>
ram
(
argv
[
1
]);
Ram
<
ramulator
::
DDR3
>
ram
(
argv
[
1
]);
ram
.
Set
ProcessorFrequencyRatio
(
4
.0
);
ram
.
Set
Frequency
(
1
.0
);
int
addr_interval
=
std
::
stoi
(
argv
[
2
]);
int
addr_interval
=
std
::
stoi
(
argv
[
2
]);
long
last_access_time
=
-
1
;
long
last_access_time
=
-
1
;
int
same_access_time_count
=
0
;
int
same_access_time_count
=
0
;
for
(
int
i
=
0
;
i
<
1000
;
++
i
){
for
(
int
i
=
0
;
i
<
1000
;
++
i
){
long
access_time
=
ram
.
Access
Memory
(
long
(
20734016
+
i
*
addr_interval
),
ramulator
::
Request
::
Type
::
READ
);
long
access_time
=
ram
.
Access
AndWaitUntilReturn
(
long
(
20734016
+
i
*
addr_interval
),
ramulator
::
Request
::
Type
::
READ
);
if
(
last_access_time
!=
access_time
&&
last_access_time
>
0
){
if
(
last_access_time
!=
access_time
&&
last_access_time
>
0
){
cout
<<
"access id: "
<<
i
<<
", cycles: "
<<
last_access_time
<<
" ("
<<
same_access_time_count
<<
")"
<<
endl
;
cout
<<
"access id: "
<<
i
<<
", cycles: "
<<
last_access_time
<<
" ("
<<
same_access_time_count
<<
")"
<<
endl
;
same_access_time_count
=
1
;
same_access_time_count
=
1
;
...
@@ -26,6 +26,6 @@ int main(int argc, const char *argv[]){
...
@@ -26,6 +26,6 @@ int main(int argc, const char *argv[]){
}
}
last_access_time
=
access_time
;
last_access_time
=
access_time
;
}
}
std
::
cout
<<
"total cycles: "
<<
ram
.
GetClock
Processor
()
<<
std
::
endl
;
std
::
cout
<<
"total cycles: "
<<
ram
.
GetClock
Realtime
()
<<
std
::
endl
;
return
0
;
return
0
;
}
}
ramulator/testram_break.cpp
0 → 100644
View file @
230065be
#include "ram.h"
#include <iostream>
#include <string>
using
namespace
ramulator
;
int
main
(
int
argc
,
const
char
*
argv
[]){
if
(
argc
<
3
)
{
printf
(
"Usage: %s <configs-file> <memory access interval>
\n
"
"Example: %s ramulator-configs.cfg 16
\n
"
,
argv
[
0
],
argv
[
0
]);
return
0
;
}
Ram
<
ramulator
::
DDR3
>
ram
(
argv
[
1
]);
ram
.
SetFrequency
(
1.0
);
int
addr_interval
=
std
::
stoi
(
argv
[
2
]);
for
(
int
i
=
0
;
i
<
1000
;
++
i
){
ram
.
AccessCommand
(
long
(
20734016
+
i
*
addr_interval
),
ramulator
::
Request
::
Type
::
READ
);
ram
.
WaitFor
(
10
);
}
ram
.
WaitUntil
(
80000
);
std
::
cout
<<
"total cycles: "
<<
ram
.
GetClockRealtime
()
<<
std
::
endl
;
return
0
;
}
run.sh
View file @
230065be
#!/bin/bash
#!/bin/bash
./bazel-bin/ramulator/testram ./configs/DDR3-config.cfg
$1
./bazel-bin/ramulator/testram ./configs/DDR3-config.cfg
$1
./bazel-bin/ramulator/testram_break ./configs/DDR3-config.cfg
$1
./bazel-bin/ramulator/main ./configs/DDR3-config.cfg
$1
./bazel-bin/ramulator/main ./configs/DDR3-config.cfg
$1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment