📄 imxsim.c
字号:
/*****************************************************************************
Project: iMX Library
----------------------
File: imxsim.c
Description: iMX simulation model
Created: 07/29/1999, Ching-Yu Hung, Deepu Talla
Copyright 1999, Texas Instruments
------------------------------------------------------------
Version:
$Id: imxsim.c,v 1.1 1999/10/13 05:04:05 illgner Exp $
History:
$Log: imxsim.c,v $
Revision 1.1 1999/10/13 05:04:05 illgner
Initial revision
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "imx.h"
unsigned short image_buf[2048];
unsigned short coeff_buf[5120];
/* ================================== */
static short sat_high;
static short sat_high_set;
static short sat_low;
static short sat_low_set;
/* ================================== */
void imxsim_set_parameters(
short a_sat_high,
short a_sat_high_set,
short a_sat_low,
short a_sat_low_set)
{
sat_high = a_sat_high;
sat_high_set = a_sat_high_set;
sat_low = a_sat_low;
sat_low_set = a_sat_low_set;
}
void access_mem(short *ptr_page, short ptr_byte, short points,
short psize, short *dst, short for_coef)
{
short *start;
short start_byte;
short i;
short b[4];
if (psize == iMXTYPE_SHORT) {
start = &ptr_page[ptr_byte >> 1];
b[0] = *start++;
b[1] = *start++;
b[2] = *start++;
b[3] = *start++;
}
else /* byte */ {
for (i=0; i<4; i++) {
start_byte = ptr_byte++;
if (start_byte & 1) /* odd, high byte */
b[i] = (ptr_page[start_byte >> 1] >> 8) & 0xFF;
else /* even, low byte */
b[i] = ptr_page[start_byte >> 1] & 0xFF;
}
}
switch(points) {
case 4: dst[0] = b[0]; dst[1] = b[1];
dst[2] = b[2]; dst[3] = b[3];
break;
case 2: if (for_coef) {
dst[0] = b[0]; dst[1] = b[1];
dst[2] = b[0]; dst[3] = b[1];
}
else {
dst[0] = b[0]; dst[1] = b[0];
dst[2] = b[1]; dst[3] = b[1];
}
break;
case 1: dst[0] = dst[1] = dst[2] = dst[3] = b[0];
break;
default: dst[0] = dst[1] = dst[2] = dst[3] = 0;
}
}
/* ======================================= */
/* miscellaneous short-hands for iMX model */
/* ======================================= */
/* ==================================== */
/* ONLY internal support routine */
/* ------------------------------------ */
short imx_saturate(long x) /* K.I. 4.11.99 */
{
if (x >= sat_high) return (sat_high_set);
else if (x < sat_low) return (sat_low_set);
else return ((short)x);
}
short first3(short i2, short i3, short i4)
{
return(i3 == 0);
}
short first4(short i2, short i3, short i4)
{
return(i4 == 0);
}
short first34(short i2, short i3, short i4)
{
return((i3 == 0) && (i4 == 0));
}
short first23(short i2, short i3, short i4)
{
return((i2 == 0) && (i3 == 0));
}
short first234(short i2, short i3, short i4)
{
return((i2 == 0) && (i3 == 0) && (i4 == 0));
}
short last3(short i2, short i3, short i4, short end2, short end3, short end4)
{
return(i3 == end3);
}
short last4(short i2, short i3, short i4, short end2, short end3, short end4)
{
return(i4 == end4);
}
short last23(short i2, short i3, short i4, short end2, short end3, short end4)
{
return((i3 == end3) && (i2 == end2));
}
short last34(short i2, short i3, short i4, short end2, short end3, short end4)
{
return((i3 == end3) && (i4 == end4));
}
short last234(short i2, short i3, short i4, short end2, short end3, short end4)
{
return((i2 == end2) && (i3 == end3) && (i4 == end4));
}
short last(short i, short lpend)
{
return(i == lpend);
}
/* ================================== */
/* ============================================================ */
void imx_sim(
short acc_mode, /* 0: single acc, 1: multiple, indexed by i4 */
short op, /* 0: mpy, 1: absdiff, 2: add, 3: sub, 4: lookup */
short lpend1,
short lpend2,
short lpend3,
short lpend4,
short *data_init,
short *coef_init,
short *outp_init,
short data_inc1,
short data_inc2,
short data_inc3,
short data_inc4,
short data_inc_mask1,
short data_inc_mask2,
short data_inc_mask3,
short coef_inc1,
short coef_inc2,
short coef_inc3,
short coef_inc4,
short coef_inc_mask1,
short coef_inc_mask2,
short coef_inc_mask3,
short outp_inc1,
short outp_inc2,
short outp_inc3,
short outp_inc4,
short outp_inc_mask1,
short outp_inc_mask2,
short outp_inc_mask3,
short dpoints,
short cpoints,
short opoints,
short dsize,
short csize,
short osize,
short acclp,
short rnd_shift,
short coeff_unsigned,
short *cmd_p)
{
short i1, i2, i3, i4;
short pe;
long acc[3][NO_OF_MACS];
short x[4], y[4], outp_tmp[4];
short init_acc, writeback;
short tlu_offset;
short tlu_out;
long rnd_add;
short *dpage, *cpage, *opage;
short data_byte, coef_byte, outp_byte;
short *outp_short;
#if (DEBUG1)
short membase = 0;
printf("DEBUG1 Start\n");
#endif
if (rnd_shift > 0)
rnd_add = 1 << (rnd_shift - 1);
else
rnd_add = 0;
#if 0
if ((short) data_init >= iMXCOEFFBUF)
dpage = (short *) iMXCOEFFBUF;
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -