📄 byte_align_le.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
//
//----------------------------------------------------------------------
//
// Filename : byte_align_le.uc
//
// Description: This macro byte aligns a 64 byte ethernet packet in
// little endian mode.
// It takes as input a 64 byte ethernet packet from SRAM,
// strips off the 14 byte ethernet header and byte aligns
// the contained IP packet back in SRAM.
//
// History :
//
// Date Comment By
// --------------------------------------------------------------------
//
// 10/18/2001 Created. asv
// 01/21/2002 Removed code that was otherwise needed to avoid asv
// assembler warnings in earlier workbench versions.
// 10/14/2002 Cleaned up code. Added coding conventions. asv
//----------------------------------------------------------------------
#include "byte_align_le.h"
//----------------------------------------------------------------------
// _byte_align_le()
//
// Description: This macro byte aligns a 64 byte ethernet packet.
// It takes as input a 64 byte ethernet packet, strips
// off the 14-byte ethernet header and byte aligns the
// contained IP packet.
//
// Parameters:
// Inputs:
// in_src_sram_addr:
// SRAM address containing ethernet packet.
// in_dst_sram_addr:
// SRAM address that will contain IP packet.
//
//----------------------------------------------------------------------
#macro _byte_align_le(in_src_sram_addr, in_dst_sram_addr)
.begin
// Declaring SRAM transfer registers that will be used.
.reg $data0 $data1 $data2 $data3 \
$data4 $data5 $data6 $data7 \
$data8 $data9 $data10 $data11 \
$data12 $data13 $data14 $data15
// Defines the ordering of SRAM transfer registers.
.xfer_order $data0 $data1 $data2 $data3 \
$data4 $data5 $data6 $data7 \
$data8 $data9 $data10 $data11 \
$data12 $data13 $data14 $data15
// Set byte shift as 2 - needed by the byte_align_le instruction.
// Setting a byte shift of 2 aligns the IP packet on a 4 byte
// boundary in SRAM. (see readme.txt)
// The local_csr_wr needs 3 nops or equivalent instructions.
local_csr_wr[byte_index, 2]
// Put zeroes in the upper 16 bits
.reg last_word
immed[last_word, 0, <<16]
// Reading a 64 byte ethernet packet from SRAM into
// transfer registers $data0-$data15
.sig sram_rd_sig
sram[read, $data0, in_src_sram_addr, 0, 8], ctx_swap[sram_rd_sig]
sram[read, $data8, in_src_sram_addr, 32, 8], ctx_swap[sram_rd_sig]
// Discard the ethernet header (first 14 bytes), so start reading
// from the lower 16 bits of $data3.
// Byte align the IP packet starting from the ms 16 bits of $data3
// until the ls 16 bits of $data15
// Store the result of the alignment in $data0-$data12
byte_align_le[--, $data3]
byte_align_le[$data0, $data4]
byte_align_le[$data1, $data5]
byte_align_le[$data2, $data6]
byte_align_le[$data3, $data7]
byte_align_le[$data4, $data8]
byte_align_le[$data5, $data9]
byte_align_le[$data6, $data10]
byte_align_le[$data7, $data11]
byte_align_le[$data8, $data12]
byte_align_le[$data9, $data13]
byte_align_le[$data10, $data14]
byte_align_le[$data11, $data15]
// Byte align the ms 16 bits of $data15 and pad the rest of the
// ouput with zeroes
byte_align_le[$data12, last_word]
// Write the byte aligned IP packet to SRAM starting at location
// 'in_dst_sram_addr'
.sig sram_wr_sig
sram[write, $data0, in_dst_sram_addr, 0, 8], ctx_swap[sram_wr_sig]
sram[write, $data8, in_dst_sram_addr, 32, 5], ctx_swap[sram_wr_sig]
.end
#endm
// Execution starts here.
// Run only on thread 0.
br=ctx[0, start#]
ctx_arb[kill]
start#:
// Set src and dst addresses for packet in SRAM.
.reg src_sram_addr dst_sram_addr
immed[src_sram_addr, _SRC_SRAM_ADDR]
immed[dst_sram_addr, _DST_SRAM_ADDR]
// Byte align an ethernet packet in little endian mode.
_byte_align_le(src_sram_addr, dst_sram_addr)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -