⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lm_example.uc

📁 国内还比较新的network processor的微代码开发
💻 UC
字号:
//---------------------------------------------------------------------------
//
//                  I N T E L   P R O P R I E T A R Y
//
//     COPYRIGHT [c]  2001 BY  INTEL  CORPORATION.  ALL RIGHTS
//     RESERVED.   NO  PART  OF THIS PROGRAM  OR  PUBLICATION  MAY
//     BE  REPRODUCED,   TRANSMITTED,   TRANSCRIBED,   STORED  IN  A
//     RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER
//     LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,
//     MAGNETIC,  OPTICAL,  CHEMICAL, MANUAL, OR OTHERWISE,  WITHOUT
//     THE PRIOR WRITTEN PERMISSION OF :
//
//                        INTEL  CORPORATION
//
//                     2200 MISSION COLLEGE BLVD
//
//               SANTA  CLARA,  CALIFORNIA  95052-8119
//
//---------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////
//
//
//      File Name: lm_example.uc
//
//      Purpose: demonstrates the usage of local memory macros in IXPblocks 
//               Portable library
//
//      History:
//
//
//      Date            Comment                         By
//      ---------------------------------------------------------------------
//
//      10/18/2001      Created                         David Chou
//
//
/////////////////////////////////////////////////////////////////////////////
//
// This program demonstrates the usage of local memory macros in IXPblocks 
// Portable library by first write to loca memory through macros 
// localmem_write1, localmem_write2, ........, localmem_write8, the data in
// each entry will increase by one, then read back through macros 
// localmem_read8, localmem_read7, ............, localmem_read1, and compare,
// if each entry read back is correct, increase pass by one, otherwise 
// increase fail by one. If every entry is correct, the final pass will be 36
// and fail will be 0. This program just runs in thread 0.

//include stdmac.uc in IXPblocks Portable library
#include "stdmac.uc"

//inlcude localmem.uc in IXPblocks Portable library for read/write local memory
#include "localmem.uc"

//macros for assigning and comparing values
#include "assign_compare_macros.uc"  

// the starting value to write to local memory and compared with 
// during read back, can be any 32 bits value
#define _START_VAL          0x12345678

// the starting local memory index offset to write and read back for 
// comparison, local memory index is expressed in byte address, this can be 
// any value between 0 to 636, but must be multiples of 4
#define _START_INDEX        0x0
        
// register declararion
// context relative GPR variables, declared as volatile, so will not be 
// overwritten for data watch purpose 
.reg volatile pass fail src expect
// context relative GPR variables 
.reg ctx_enable_data lm_addr_base index
// context relative GPR variables 
.reg data_0 data_1 data_2 data_3 data_4 data_5 data_6 data_7

  	// kill thread which is not thread 0 
begin#:
	br=ctx[0, thread_0#]	; if it is thread 0, go to thread_0#
	ctx_arb[kill]			; not thread 0, just kill

thread_0#:
    // initialize ctx_enables csr for global mode local memory address index
	// bit 17 in CTX_ENABLE - LM_ADDR_1_GLOBAL = 0 : LM_ADDR_1 is context relative
	//                                         = 1 : LM_ADDR_1 is global
	// bit 16 in CTX_ENABLE - LM_ADDR_0_GLOBAL = 0 : LM_ADDR_0 is context relative
	//                                         = 1 : LM_ADDR_0 is global
	// bits [15:8] CTX enables for contexts 0 to 7
    immed[ctx_enable_data, 0xFF00]				; set low word value
    immed_w1[ctx_enable_data, 0x0003]           ; set high word value
    local_csr_wr[CTX_ENABLES, ctx_enable_data] 	; initialize CTX_ENABLES

 	// initialize GPR variables pass, fail, lm_addr_base, src, and index 
    immed[pass, 0]								; initialize pass count
	immed[fail, 0]								; initialize fail count
	immed[lm_addr_base, 0]						; initialize local memory index base
    move[src, _START_VAL]						; initialize source value                                       
    move[index, _START_INDEX]    				; initialize local memory index offset
 	
	// assigning and writing one 32 bits entry into local memory through macros
	// and increase local memory index offset accordingly
    assign_1_inc_src[src, data_0]					; assign source value
    localmem_write1[data_0, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index,  +, 4]						; increase local memory index offset

	// assigning and writing two 32 bits entries into local memory through macros
	// and increase local memory index offset accordingly
    assign_2[src, data_0, data_1]				; assign source value				
    localmem_write2[data_0, data_1, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index, +, 8]							; increase local memory index offset

	// assigning and writing three 32 bits entries into local memory through macros
	// and increase local memory index offset accordingly
    assign_3[src, data_0, data_1, data_2]		; assign source value
    localmem_write3[data_0, data_1, data_2, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index, +, 12]						; increase local memory index offset

	// assigning and writing four 32 bits entries into local memory through macros
	// and increase local memory index offset accordingly
    assign_4[src, data_0, data_1, data_2, data_3]	; assign source value
    localmem_write4[data_0, data_1, data_2, data_3, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index, +, 16]						; increase local memory index offset

	// assigning and writing five 32 bits entries into local memory through macros
	// and increase local memory index offset accordingly
    assign_5[src, data_0, data_1, data_2, data_3, data_4]	; assign source value	
    localmem_write5[data_0, data_1, data_2, data_3, data_4, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index, +, 20]						; increase local memory index offset

	// assigning and writing six 32 bits entries into local memory through macros
	// and increase local memory index offset accordingly
    assign_6[src, data_0, data_1, data_2, data_3, data_4, data_5]	; assign source value
    localmem_write6[data_0, data_1, data_2, data_3, data_4, data_5, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index, +, 24]						; increase local memory index offset

	// assigning and writing seven 32 bits entries into local memory through macros
	// and increase local memory index offset accordingly
    assign_7[src, data_0, data_1, data_2, data_3, data_4, data_5, data_6]	; assign source value
    localmem_write7[data_0, data_1, data_2, data_3, data_4, data_5, data_6, lm_addr_base, index]	; write to local memory through IXPblocks macros
    alu[index, index, +, 28]						; increase local memory index offset

	// assigning and writing eight 32 bits entries into local memory through macros
    assign_8[src, data_0, data_1, data_2, data_3, data_4, data_5, data_6, data_7]	; assign source value
    localmem_write8[data_0, data_1, data_2, data_3, data_4, data_5, data_6, data_7, lm_addr_base, index]	; write to local memory through IXPblocks macros

    // initialize starting expected value and reset local memory index ofset
    move[expect, _START_VAL]					; initialize expected value                                     
    move[index, _START_INDEX]    				; reset local memory index offset

	// reading eight 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly 
    localmem_read8[data_0, data_1, data_2, data_3, data_4, data_5, data_6, data_7, lm_addr_base, index]	; read back through IXPblocks macros
    compare_8[expect, data_0, data_1, data_2, data_3, data_4, data_5, data_6, data_7, pass, fail]	; compare with expected
 	alu[index, index, +, 32]						; increase local memory index offset

	// reading seven 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly 
	localmem_read7[data_0, data_1, data_2, data_3, data_4, data_5, data_6, lm_addr_base, index]	; read back through IXPblocks macros
    compare_7[expect, data_0, data_1, data_2, data_3, data_4, data_5, data_6, pass, fail]	; compare with expected
    alu[index, index, +, 28]						; increase local memory index offset

	// reading six 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly
    localmem_read6[data_0, data_1, data_2, data_3, data_4, data_5, lm_addr_base, index]	; read back through IXPblocks macros
    compare_6[expect, data_0, data_1, data_2, data_3, data_4, data_5, pass, fail]	; compare with expected
    alu[index, index, +, 24]						; increase local memory index offset

	// reading five 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly 
    localmem_read5[data_0, data_1, data_2, data_3, data_4, lm_addr_base, index]	; read back through IXPblocks macros
    compare_5[expect, data_0, data_1, data_2, data_3, data_4, pass, fail]	; compare with expected
    alu[index, index, +, 20]						; increase local memory index offset

	// reading four 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly
    localmem_read4[data_0, data_1, data_2, data_3, lm_addr_base, index]	; read back through IXPblocks macros
    compare_4[expect, data_0, data_1, data_2, data_3, pass, fail]	; compare with expected	
    alu[index, index, +, 16]						; increase local memory index offset

	// reading three 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly
    localmem_read3[data_0, data_1, data_2, lm_addr_base, index]	; read back through IXPblocks macros
    compare_3[expect, data_0, data_1, data_2, pass, fail]	; compare with expected
    alu[index, index, +, 12]						; increase local memory index offset

	// reading two 32 bits entries from local memory and comparing them with 
	// expected values through macros, then increase local memory index offset
	// accordingly
    localmem_read2[data_0, data_1, lm_addr_base, index]	; read back through IXPblocks macros
    compare_2[expect, data_0, data_1, pass, fail]	; compare with expected 
    alu[index, index, +, 8]							; increase local memory index offset

	// reading one 32 bits entry from local memory and comparing it with expected
	// value through macros,
    localmem_read1[data_0, lm_addr_base, index]		; read back through IXPblocks macros
    compare_1_inc_src[expect, data_0, pass, fail]	; compare with expected
  
done#:

// The following loop is added so we could prevent program from running into 
// undefined ucode area
end_of_program#:
	nop						; nop
	br[end_of_program#]		; loop back 
	nop						; nop
	nop						; nop
	nop						; nop
	nop						; nop

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -