Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinbao chen
ustc_ca2021_lab
Commits
041bd694
Commit
041bd694
authored
May 26, 2021
by
jinbao chen
Browse files
modify report
parent
6860fe63
Changes
7
Hide whitespace changes
Inline
Side-by-side
lab3/CacheSrcCode/cache_FIFO.sv
View file @
041bd694
...
...
@@ -4,7 +4,7 @@ module cache_fifo #(
parameter
LINE_ADDR_LEN
=
3
,
// line内地??长度,决定了每个line具有2^3个word
parameter
SET_ADDR_LEN
=
3
,
// 组地??长度,决定了??共有2^3=8??
parameter
TAG_ADDR_LEN
=
6
,
// tag长度
parameter
WAY_CNT
=
5
// 组相连度,决定了每组中有多少路line,这里是直接映射型cache,因此该参数没用??
parameter
WAY_CNT
=
3
// 组相连度,决定了每组中有多少路line,这里是直接映射型cache,因此该参数没用??
)(
input
clk
,
rst
,
output
miss
,
// 对CPU发出的miss信号
...
...
lab3/CacheSrcCode/cache_LRU.sv
View file @
041bd694
...
...
@@ -4,7 +4,7 @@ module cache_lru #(
parameter
LINE_ADDR_LEN
=
3
,
// line内地??长度,决定了每个line具有2^3个word
parameter
SET_ADDR_LEN
=
3
,
// 组地??长度,决定了??共有2^3=8??
parameter
TAG_ADDR_LEN
=
6
,
// tag长度
parameter
WAY_CNT
=
5
// 组相连度,决定了每组中有多少路line,这里是直接映射型cache,因此该参数没用??
parameter
WAY_CNT
=
3
// 组相连度,决定了每组中有多少路line,这里是直接映射型cache,因此该参数没用??
)(
input
clk
,
rst
,
output
miss
,
// 对CPU发出的miss信号
...
...
lab3/CacheSrcCode/main_mem.sv
View file @
041bd694
...
...
@@ -21,7 +21,7 @@ reg [(ADDR_LEN + LINE_ADDR_LEN) - 1 : 0] mem_addr = 0;
reg
[
31
:
0
]
mem_wr_data
=
0
;
wire
[
31
:
0
]
mem_rd_data
;
mem
#(
mem
MM
#(
.
ADDR_LEN
(
ADDR_LEN
+
LINE_ADDR_LEN
)
)
mem_inst
(
.
clk
(
clk
),
...
...
lab3/media/FIFO_MM_16_RES_3363.PNG
0 → 100644
View file @
041bd694
67.6 KB
lab3/media/LRU_MM_16_RES_3363.PNG
0 → 100644
View file @
041bd694
64.2 KB
lab3/report.md
View file @
041bd694
...
...
@@ -56,7 +56,14 @@ else begin
end
```
运行16
*
16矩阵乘法后的部分ram_cell的仿真截图

ram_cell中的内容符合预期。
### LRU
为实现LRU,为每个set维持一个队列以及队列长度。其中队头的块号是最近使用过的,队尾的块号是最近最少使用的。每当访问一个块(读、写)时,就将其块号放到队列的最前端。则队尾的块一定是要被换出的块。当队列非满时不进行换出。对队列的更新在IDLE状态且cache_hit的情况下进行。
更新队列的部分代码如下,其中lru_stack就是为每个set维持的队列。
...
...
@@ -95,6 +102,12 @@ if(cache_hit) begin
end
```
运行16
*
16矩阵乘法后的部分ram_cell的仿真截图

ram_cell中的内容符合预期
## 缺失率统计
对缺失率的统计在WBSegReg中进行。
...
...
@@ -243,3 +256,9 @@ fifo所需硬件资源
通过以上分析可发现,当ram_cell地址长度不变,cache内组相联度增加时,所需硬件资源会较大幅增加。当组相联度从3变到4时,所需硬件资源增加,但缺失率和运行时间有明显的下降。从4到5时,所需硬件资源进一步增加,miss率和运行时间也有所下降,但没有3-4下降得明显。综合考虑到硬件成本和运行时间,若保持cache前三个参数为336,则cache最佳参数应为3364。此时可在控制一定硬件成本的情况下使得缺失率也较低。
## 实验总结
本实验实现了两种策略cache,并连上cpu,在校验cache正确性的同时也校验了前面cpu的正确性。并通过分析不同参数cache的硬件资源、运行时间等确定较优的策略。
## 实验建议
test_bench可以更精细化,比如测试通过可以有一个类似lab2,三号寄存器为1的标志。
\ No newline at end of file
lab3/report.pdf
View file @
041bd694
No preview for this file type
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