d_source d_state d_ram, rewrite bit operations
This commit is contained in:
parent
560126526a
commit
b5702020b7
|
|
@ -1,3 +1,9 @@
|
|||
2010-11-21 Robert Larice
|
||||
* src/xspice/icm/digital/d_ram/cfunc.mod ,
|
||||
* src/xspice/icm/digital/d_source/cfunc.mod ,
|
||||
* src/xspice/icm/digital/d_state/cfunc.mod :
|
||||
d_source d_state d_ram, rewrite bit operations
|
||||
|
||||
2010-11-21 Robert Larice
|
||||
* src/xspice/icm/digital/d_ram/cfunc.mod ,
|
||||
* src/xspice/icm/digital/d_source/cfunc.mod ,
|
||||
|
|
|
|||
|
|
@ -58,14 +58,6 @@ NON-STANDARD FEATURES
|
|||
|
||||
/*=== CONSTANTS ========================*/
|
||||
|
||||
#define MASK0 0x0003
|
||||
#define MASK1 0x000c
|
||||
#define MASK2 0x0030
|
||||
#define MASK3 0x00c0
|
||||
#define MASK4 0x0300
|
||||
#define MASK5 0x0c00
|
||||
#define MASK6 0x3000
|
||||
#define MASK7 0xc000
|
||||
|
||||
|
||||
|
||||
|
|
@ -217,133 +209,19 @@ NON-STANDARD FEATURES
|
|||
* Created 7/8/91 J.P.Murray *
|
||||
************************************************/
|
||||
|
||||
static int cm_mask_and_store(short *base,int ram_offset,Digital_State_t out)
|
||||
static void cm_mask_and_store(short *base,int ram_offset,Digital_State_t out)
|
||||
{
|
||||
switch (ram_offset) {
|
||||
case 0:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK0);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xfffd;
|
||||
*base = *base | 0x0001;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xfffe;
|
||||
*base = *base | 0x0002;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK1);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xfff7;
|
||||
*base = *base | 0x0004;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xfffb;
|
||||
*base = *base | 0x0008;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK2);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xffdf;
|
||||
*base = *base | 0x0010;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xffef;
|
||||
*base = *base | 0x0020;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK3);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xff7f;
|
||||
*base = *base | 0x0040;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xffbf;
|
||||
*base = *base | 0x0080;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK4);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xfdff;
|
||||
*base = *base | 0x0100;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xfeff;
|
||||
*base = *base | 0x0200;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK5);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xf7ff;
|
||||
*base = *base | 0x0400;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xfbff;
|
||||
*base = *base | 0x0800;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK6);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0xdfff;
|
||||
*base = *base | 0x1000;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xefff;
|
||||
*base = *base | 0x2000;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if ( ZERO == out ) {
|
||||
*base = *base & ~(MASK7);
|
||||
}
|
||||
else {
|
||||
if (ONE == out) {
|
||||
*base = *base & 0x7fff;
|
||||
*base = *base | 0x4000;
|
||||
}
|
||||
else {
|
||||
*base = *base & 0xbfff;
|
||||
*base = *base | 0x8000;
|
||||
}
|
||||
}
|
||||
break;
|
||||
int val;
|
||||
|
||||
}
|
||||
if ( ZERO == out )
|
||||
val = 0;
|
||||
else if (ONE == out)
|
||||
val = 1;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
return 0;
|
||||
*base &= (short) ~ (3 << (ram_offset * 2));
|
||||
*base |= (short) (val << (ram_offset * 2));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -403,123 +281,15 @@ NON-STANDARD FEATURES
|
|||
* Created 7/8/91 J.P.Murray *
|
||||
**************************************************/
|
||||
|
||||
static int cm_mask_and_retrieve(short base,int ram_offset,Digital_State_t *out)
|
||||
static Digital_State_t cm_mask_and_retrieve(short base, int ram_offset)
|
||||
{
|
||||
int value = 0x0003 & (base >> (ram_offset * 2));
|
||||
|
||||
switch (ram_offset) {
|
||||
case 0:
|
||||
if ( (MASK0 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK0 & base) == 0x0001 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if ( (MASK1 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK1 & base) == 0x0004 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( (MASK2 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK2 & base) == 0x0010 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ( (MASK3 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK3 & base) == 0x0040 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ( (MASK4 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK4 & base) == 0x0100 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if ( (MASK5 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK5 & base) == 0x0400 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if ( (MASK6 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK6 & base) == 0x1000 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if ( (MASK7 & base) == 0x0000 ) {
|
||||
*out = ZERO;
|
||||
}
|
||||
else {
|
||||
if ( (MASK7 & base) == 0x4000 ) {
|
||||
*out = ONE;
|
||||
}
|
||||
else {
|
||||
*out = UNKNOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
switch (value) {
|
||||
case 0: return ZERO;
|
||||
case 1: return ONE;
|
||||
default: return UNKNOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -764,8 +534,8 @@ NON-STANDARD FEATURES
|
|||
* Created 6/27/91 J.P.Murray *
|
||||
************************************************/
|
||||
|
||||
static void cm_get_ram_value(int word_width,int bit_number,Digital_State_t *address,
|
||||
int address_size,short *ram,Digital_State_t *out)
|
||||
static Digital_State_t cm_get_ram_value(int word_width,int bit_number,Digital_State_t *address,
|
||||
int address_size,short *ram)
|
||||
|
||||
{
|
||||
int err, /* error index value */
|
||||
|
|
@ -798,11 +568,11 @@ static void cm_get_ram_value(int word_width,int bit_number,Digital_State_t *addr
|
|||
|
||||
/* for each offset, mask off the bits and determine values */
|
||||
|
||||
cm_mask_and_retrieve(base,ram_offset,out);
|
||||
return cm_mask_and_retrieve(base,ram_offset);
|
||||
|
||||
}
|
||||
else { /** incorrect data returned...return UNKNOWN values **/
|
||||
*out = UNKNOWN;
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -921,7 +691,7 @@ void cm_d_ram(ARGS)
|
|||
word_width = PORT_SIZE(data_in);
|
||||
|
||||
|
||||
num_of_ram_ints = ram_size * word_width / 8 + 1;
|
||||
num_of_ram_ints = (ram_size * word_width + 7) / 8;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1059,7 +829,7 @@ void cm_d_ram(ARGS)
|
|||
for (i=0; i<word_width; i++) {
|
||||
/* for each output bit in the word, */
|
||||
/* retrieve the state value. */
|
||||
cm_get_ram_value(word_width,i,address,address_size,ram,&out);
|
||||
out = cm_get_ram_value(word_width,i,address,address_size,ram);
|
||||
OUTPUT_STATE(data_out[i]) = out;
|
||||
OUTPUT_STRENGTH(data_out[i]) = STRONG;
|
||||
OUTPUT_DELAY(data_out[i]) = PARAM(read_delay);
|
||||
|
|
@ -1150,8 +920,8 @@ void cm_d_ram(ARGS)
|
|||
else {
|
||||
/* for each output bit in the word, */
|
||||
/* retrieve the state value. */
|
||||
cm_get_ram_value(word_width,i,address,
|
||||
address_size,ram,&out);
|
||||
out = cm_get_ram_value(word_width,i,address,
|
||||
address_size,ram);
|
||||
OUTPUT_STATE(data_out[i]) = out;
|
||||
}
|
||||
OUTPUT_STRENGTH(data_out[i]) = STRONG;
|
||||
|
|
|
|||
|
|
@ -514,29 +514,9 @@ static void cm_source_mask_and_retrieve(short base,int bit_offset,Digital_t *out
|
|||
{
|
||||
|
||||
|
||||
short value; /* the hexadecimal value of the masked bit */
|
||||
int value; /* the hexadecimal value of the masked bit */
|
||||
|
||||
|
||||
|
||||
switch (bit_offset) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
base = base >> 4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
base = base >> 8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
base = base >> 12;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
value = 0x000f & base;
|
||||
value = 0x000f & (base >> (bit_offset * 4));
|
||||
|
||||
|
||||
switch (value) {
|
||||
|
|
@ -645,31 +625,10 @@ NON-STANDARD FEATURES
|
|||
* Created 7/15/91 J.P.Murray *
|
||||
************************************************/
|
||||
|
||||
static int cm_source_mask_and_store(short *base,int bit_offset,int bit_value)
|
||||
static void cm_source_mask_and_store(short *base,int bit_offset,int bit_value)
|
||||
{
|
||||
switch (bit_offset) {
|
||||
case 0:
|
||||
*base = *base & 0xfff0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*base = *base & 0xff0f;
|
||||
bit_value = bit_value << 4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*base = *base & 0xf0ff;
|
||||
bit_value = bit_value << 8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
*base = *base & 0x0fff;
|
||||
bit_value = bit_value << 12;
|
||||
break;
|
||||
}
|
||||
|
||||
*base = *base | bit_value;
|
||||
return 0;
|
||||
*base &= (short) ~ (0x000f << (bit_offset * 4));
|
||||
*base |= (short) (bit_value << (bit_offset * 4));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -565,61 +565,20 @@ NON-STANDARD FEATURES
|
|||
* Created 7/23/91 J.P.Murray *
|
||||
**************************************************/
|
||||
|
||||
static void cm_inputs_mask_and_retrieve(short base,int bit_offset,Digital_t *out)
|
||||
static Digital_State_t cm_inputs_mask_and_retrieve(short base, int bit_offset)
|
||||
{
|
||||
|
||||
|
||||
short value; /* the hexadecimal value of the masked bit */
|
||||
int value; /* the hexadecimal value of the masked bit */
|
||||
|
||||
|
||||
|
||||
switch (bit_offset) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
base = base >> 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
base = base >> 4;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
base = base >> 6;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
base = base >> 8;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
base = base >> 10;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
base = base >> 12;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
base = base >> 14;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
value = 0x0003 & base;
|
||||
value = 0x0003 & (base >> (bit_offset * 2));
|
||||
|
||||
|
||||
switch (value) {
|
||||
|
||||
case 0: out->state = ZERO;
|
||||
break;
|
||||
|
||||
case 1: out->state = ONE;
|
||||
break;
|
||||
|
||||
case 2: out->state = UNKNOWN;
|
||||
break;
|
||||
case 0: return ZERO;
|
||||
case 1: return ONE;
|
||||
default: return UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -789,7 +748,7 @@ static int cm_compare_to_inputs(State_Table_t *states,int index,int bit_number,
|
|||
short base; /* variable to hold current base integer for
|
||||
comparison purposes. */
|
||||
|
||||
Digital_t out; /* output variable for state retrieved */
|
||||
Digital_State_t out; /* output variable for state retrieved */
|
||||
|
||||
|
||||
/* obtain offset value from index, word_width & bit_number */
|
||||
|
|
@ -803,13 +762,13 @@ static int cm_compare_to_inputs(State_Table_t *states,int index,int bit_number,
|
|||
|
||||
/* for each offset, mask off the bits and determine values */
|
||||
|
||||
cm_inputs_mask_and_retrieve(base,bit_offset,&out);
|
||||
out = cm_inputs_mask_and_retrieve(base, bit_offset);
|
||||
|
||||
if ( out.state == in ) { /* bit matches */
|
||||
if ( out == in ) { /* bit matches */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if ( 2==out.state ) { /* bit compared to is a "don't care" */
|
||||
if ( out == UNKNOWN ) { /* bit compared to is a "don't care" */
|
||||
return 0;
|
||||
}
|
||||
else { /* no match */
|
||||
|
|
@ -875,51 +834,10 @@ NON-STANDARD FEATURES
|
|||
* Last Modified 7/22/91 J.P.Murray *
|
||||
************************************************/
|
||||
|
||||
static int cm_inputs_mask_and_store(short *base,int bit_offset,int bit_value)
|
||||
static void cm_inputs_mask_and_store(short *base,int bit_offset,int bit_value)
|
||||
{
|
||||
switch (bit_offset) {
|
||||
case 0:
|
||||
*base = *base & 0xfffc;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*base = *base & 0xfff3;
|
||||
bit_value = bit_value << 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*base = *base & 0xffcf;
|
||||
bit_value = bit_value << 4;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
*base = *base & 0xff3f;
|
||||
bit_value = bit_value << 6;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*base = *base & 0xfcff;
|
||||
bit_value = bit_value << 8;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
*base = *base & 0xf3ff;
|
||||
bit_value = bit_value << 10;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
*base = *base & 0xcfff;
|
||||
bit_value = bit_value << 12;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
*base = *base & 0x3fff;
|
||||
bit_value = bit_value << 14;
|
||||
break;
|
||||
}
|
||||
|
||||
*base = *base | bit_value;
|
||||
return 0;
|
||||
*base &= (short) ~ (0x0003 << (bit_offset * 2));
|
||||
*base |= (short) (bit_value << (bit_offset * 2));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1072,31 +990,10 @@ NON-STANDARD FEATURES
|
|||
* Last Modified 7/22/91 J.P.Murray *
|
||||
************************************************/
|
||||
|
||||
static int cm_bits_mask_and_store(short *base,int bit_offset,int bit_value)
|
||||
static void cm_bits_mask_and_store(short *base,int bit_offset,int bit_value)
|
||||
{
|
||||
switch (bit_offset) {
|
||||
case 0:
|
||||
*base = *base & 0xfff0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
*base = *base & 0xff0f;
|
||||
bit_value = bit_value << 4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*base = *base & 0xf0ff;
|
||||
bit_value = bit_value << 8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
*base = *base & 0x0fff;
|
||||
bit_value = bit_value << 12;
|
||||
break;
|
||||
}
|
||||
|
||||
*base = *base | bit_value;
|
||||
return 0;
|
||||
*base &= (short) ~ (0x000f << (bit_offset * 4));
|
||||
*base |= (short) (bit_value << (bit_offset * 4));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1162,29 +1059,9 @@ static void cm_bits_mask_and_retrieve(short base,int bit_offset,Digital_t *out)
|
|||
{
|
||||
|
||||
|
||||
short value; /* the hexadecimal value of the masked bit */
|
||||
int value; /* the hexadecimal value of the masked bit */
|
||||
|
||||
|
||||
|
||||
switch (bit_offset) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
base = base >> 4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
base = base >> 8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
base = base >> 12;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
value = 0x000f & base;
|
||||
value = 0x000f & (base >> (bit_offset * 4));
|
||||
|
||||
|
||||
switch (value) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue