📄 cam_example_util.uc
字号:
loop_2_begin#:
//Read tag form DRAM
//Waite read finished
//Do a CAM look up
//Update hit/miss count
//Do a CAM look up again
//Update hit/miss count
dram[read, $$xfer_0, dram_base, 0, 1],sig_done[dram_sleep_sig]
ctx_arb[dram_sleep_sig]
cam_lookup[status_2, $$xfer_0]
miss_hit_count_update[miss_count_2, hit_count_2, status_2]
cam_lookup[status_2, $$xfer_1]
miss_hit_count_update[miss_count_2, hit_count_2, status_2]
//Increase dram address
//Decrement iterate value
//iterate value not zero,repeat
alu[dram_base, dram_base, +, 8]
alu[count_2, count_2, - ,1]
BNE[loop_2_begin#]
loop_2_end#:
//Get hit count storage address in DRAM
//move hit count value to $$xfer_0
//move miss count value to $$xfer_1
//Write the count to DRAM
//Do context switch
//End cam lookup 2
add[dram_base_2, dram_base_2, _CAM_DRAM_HITCOUNT_OFFSET] //Get hit count storage address in DRAM
move[$$xfer_0,hit_count_2]
move[$$xfer_1,miss_count_2]
dram[write, $$xfer_0, dram_base_2, 0, 1],sig_done[dram_sleep_sig]
ctx_arb[dram_sleep_sig]
#ifdef DEBUG_CAM
nop //For debug purpose
nop
#endif
.endlocal
//End cam lookup 2
.endlocal //End cam_loopup_test
cam_loohup_test_end#:
#endm
//Macro cam_lookup_analyze_dram
// Description: This macro test the CAM look up based on the initialization from DRAM
//
// Outputs: The step by step operation will show the result
//
//
// Inputs: None
//
// Others: Assembler warinings because some GPR's are assigned value but not used
#macro cam_lookup_analyze_dram[]
.local stat, status, test_tag, cam_entry
//Following code will give an example how to use cam_lookup to find an entry
//for both miss and hit cases when the CAM is initialized with SRAM init values
//Assign a HIT value to test_tag
//Do a cam look up, the stae should be 0xf
//Status shoud be 1 (hit), the cam_entry
//should be 3
move[test_tag, DRAM_HIT_4]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a miss value to the test tag
//Do a cam look up, the state should be 0x0
//status should be 0(miss), the cam_enrty
//should should be 0 (LRU)
move[test_tag, DRAM_MISS_4]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a miss value to the test tag
//Do a cam look up, the state should be 0x0
//status should be 0(miss), the cam_enrty
//should should be 0 (LRU)
move[test_tag, DRAM_MISS_3]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a hit value to the test tag
//Do a cam look up, the stae should be 0xf
//Status shoud be 1 (hit), the cam_entry
//should be 9
move[test_tag, DRAM_HIT_a]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a hit value to the test tag
//Do a cam look up, the state should be 0xf
//status should be 1(hit), the cam_enrty
//should should be 0
move[test_tag, DRAM_HIT_1]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a miss value to the test tag
//Do a cam look up, the state should be 0x0
//status should be 0(miss), the cam_enrty
//should should be 1 (LRU)
move[test_tag, DRAM_MISS_6]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
.endlocal
#endm
//Macro cam_lookup_analyze_sram
// Description: This macro test the CAM look up based on the initialization from SRAM
//
// Outputs: The step by step operation will show the result
//
//
// Inputs: None
//
// Others: Assembler warinings because some GPR's are assigned value but not used
#macro cam_lookup_analyze_sram[]
.local stat, status, test_tag, cam_entry
//Following code will give an example how to use cam_lookup to find an entry
//for both miss and hit cases when the CAM is initialized with SRAM init values
//Assign a HIT value to test_tag
//Do a cam look up, the stae should be 0xf
//Status shoud be 1 (hit), the cam_entry
//should be 3
move[test_tag, SRAM_HIT_4]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a miss value to the test tag
//Do a cam look up, the state should be 0x0
//status should be 0(miss), the cam_enrty
//should should be 0 (LRU)
move[test_tag, SRAM_MISS_4]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a miss value to the test tag
//Do a cam look up, the state should be 0x0
//status should be 0(miss), the cam_enrty
//should should be 0 (LRU)
move[test_tag, SRAM_MISS_3]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a hit value to the test tag
//Do a cam look up, the stae should be 0xf
//Status shoud be 1 (hit), the cam_entry
//should be 9
move[test_tag, SRAM_HIT_a]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a hit value to the test tag
//Do a cam look up, the state should be 0xf
//status should be 1(hit), the cam_enrty
//should should be 0
move[test_tag, SRAM_HIT_1]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
//Assign a miss value to the test tag
//Do a cam look up, the state should be 0x0
//status should be 0(miss), the cam_enrty
//should should be 1 (LRU)
move[test_tag, SRAM_MISS_6]
get_cam_lookup_result[stat, status, cam_entry, test_tag]
//Set break point to watch each register return value
move($sink,stat)
move($sink,status)
move($sink,cam_entry)
.endlocal
#endm
//Macro cam_lookup_lm_dram
// Description: This macro test the CAM look up write the result to local memory
//
// Outputs: The step by step operation will show the result
//
//
// Inputs: None
//
// Others: Currently, the local memory are not be update by the CAM_LOOKUP result
// Already broad casted the issue to the micro code developing group
//LM_ADDR after CAM_lookup: OLD: NEW:
// [4:0] ='0s [5:0] ='0s
// [8:5] = entry# [9:6] = entry#
// [11:9] = [num] -- 3 bits [11:10] = [num] - 2bits
#macro cam_lookup_lm_dram[]
.local test_tag, status, dst
//Write the local CSR
//local_csr_wr needs three cycles to complete
local_csr_wr[active_lm_addr_0, 0x0]
nop
nop
nop
//Assign a HIT value to test_tag
//Do look up and put result to local memory
//Three cycles are required delay
move[test_tag, DRAM_HIT_4]
cam_lookup[status, test_tag],lm_addr0[1]
nop
nop
nop
//Read active_lm_addr_0
//Put active_lm_addr_0 to dst register [dst] should be 0x4C0
;put a break point to examine the dst value
local_csr_rd[active_lm_addr_0]
immed[dst, 0]
move[$$sink,status] //Avoid warnings
move[$$sink,dst] //Avoid warnings
//Assign a Miss value to test_tag
//Do look up and put result to dst register
//Three cycles are required delay
move[test_tag, DRAM_MISS_4]
cam_lookup[status, test_tag],lm_addr0[1]
nop
nop
nop
//Read active_lm_addr_0
//Put active_lm_addr_0 to dst register
//If this routine executed after cam_lookup_analyze_dram[]
//as shown in cam_example.uc
//[dst] should be 0x440
local_csr_rd[active_lm_addr_0]
immed[dst, 0]
move[$$sink,dst] //Avoid warnings
move[$$sink,status] //Avoid warnings
.endlocal
#endm
//Macro cam_lookup_lm_sram
// Description: This macro test the CAM look up write the result to local memory
//
// Outputs: The step by step operation will show the result
//
//
// Inputs: None
//
// Others: Currently, the local memory are not be update by the CAM_LOOKUP result
// Already broad casted the issue to the micro code developing group
// This problem is solved by a clearification
#macro cam_lookup_lm_sram[]
.local test_tag, status, dst
//Write the local CSR
//local_csr_wr needs three cycles to complete
local_csr_wr[active_lm_addr_0, 0x0]
nop
nop
nop
//Assign a HIT value to test_tag
//Do look up and put result to local memory
//Three cycles are required delay
move[test_tag, SRAM_HIT_4]
cam_lookup[status, test_tag],lm_addr0[1]
nop
nop
nop
//Read active_lm_addr_0
//Put active_lm_addr_0 to dst register [dst] should be 0x4C0
//put a break point to examine the dst value
local_csr_rd[active_lm_addr_0]
immed[dst, 0]
move[$sink,status] //Avoid warnings
move[$sink,dst] //Avoid warnings
//Assign a Miss value to test_tag
//Do look up and put result to dst register
//Three cycles are required
move[test_tag, SRAM_MISS_4]
cam_lookup[status, test_tag],lm_addr0[1]
nop
nop
nop
//Read active_lm_addr_0
//Put active_lm_addr_0 to dst register
//If this routinre is executed after cam_lookup_analyze_sram[] as shown in cam_example.uc
;[dst] should be 0x440
local_csr_rd[active_lm_addr_0]
immed[dst, 0]
move[$sink,dst] //Avoid warnings
move[$sink,status] //Avoid warnings
.endlocal
#endm
//Macro lm_rd_wr_test
// Description: This macro test local memory read/write operation and set init value
// for testing the cam_lookup_lm
//
// Outputs: The step by step operation will show the result
//
//
// Inputs: None
//
// Others: None
#macro lm_rd_wr_test[]
.local dst
//Set active local memory address
//local_csr_wr needs three cycles to complete
//Use three nops for thre extra cycles request
local_csr_wr[active_lm_addr_0, 0x0]
nop
nop
nop
//Prepare one data the local memory
//write one data the local memory
//Prepare second data the local memory
//write second data the local memory
move[dst, 0x12345678]
alu[*l$index0++,--,B,dst]
move[dst, 0x9abcdef0]
alu[*l$index0++,--,B,dst]
//Reset active local memory address
//local_csr_wr needs three cycles to complete
//Use three nops for thre extra cycles request
local_csr_wr[active_lm_addr_0, 0x0]
nop
nop
nop
//Read first data from the local memory
//Read second data from the local memory
alu[dst,--, b,*l$index0++]
move[$$sink,dst] //Avoid warnings
alu[dst,--, b,*l$index0++]
move[$$sink,dst] //Avoid warnings
.endlocal
#endm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -