287 int dont_care_start_pos;
289 num_SRAM_bits = 1 << LUT_size;
290 SRAM_values = (
char*)
my_calloc(num_SRAM_bits + 1,
sizeof(
char));
291 SRAM_values[num_SRAM_bits] =
'\0';
294 for (i = 0; i < num_SRAM_bits; i++) {
295 SRAM_values[i] =
'1';
300 binary_str = (
char*)
my_calloc(LUT_size + 1,
sizeof(
char));
301 buffer = (
char*)
my_calloc(LUT_size + 10,
sizeof(
char));
303 strcpy(buffer, (
char*) truth_table->
data_vptr);
308 if (strcmp(buffer,
" 0") == 0) {
312 }
else if (strcmp(buffer,
" 1") == 0) {
313 for (i = 0; i < num_SRAM_bits; i++) {
314 SRAM_values[i] =
'1';
322 str_loc = strtok(buffer,
" \t");
323 dont_care_start_pos = strlen(str_loc);
326 str_loc = strtok(NULL,
" \t");
328 if (str_loc[0] ==
'1') {
329 }
else if (str_loc[0] ==
'0') {
337 for (list_ptr = truth_table; list_ptr != NULL; list_ptr = list_ptr->
next) {
340 terms = (
char**)
my_calloc(num_terms,
sizeof(
char *));
343 for (list_ptr = truth_table, term_idx = 0; list_ptr != NULL; list_ptr =
344 list_ptr->
next, term_idx++) {
345 terms[term_idx] = (
char*)
my_calloc(LUT_size + 1,
sizeof(
char));
347 strcpy(buffer, (
char*) list_ptr->
data_vptr);
348 str_loc = strtok(buffer,
" \t");
349 strcpy(terms[term_idx], str_loc);
352 for (bit_idx = dont_care_start_pos; bit_idx < LUT_size; bit_idx++) {
353 terms[term_idx][bit_idx] =
'-';
357 str_loc = strtok(NULL,
" \t");
359 assert(str_loc[0] ==
'1');
361 assert(str_loc[0] ==
'0');
366 for (i = 0; i < num_SRAM_bits; i++) {
369 SRAM_values[i] =
'0';
371 SRAM_values[i] =
'1';
378 for (term_idx = 0; term_idx < num_terms; term_idx++) {
381 for (bit_idx = 0; bit_idx < LUT_size; bit_idx++) {
382 if ((terms[term_idx][bit_idx] !=
'-')
383 && (terms[term_idx][bit_idx] != binary_str[bit_idx])) {
391 SRAM_values[i] =
'1';
393 SRAM_values[i] =
'0';
404 for (term_idx = 0; term_idx < num_terms; term_idx++) {
405 free(terms[term_idx]);
static void int_2_binary_str(char *binary_str, int value, int str_length)
void * my_calloc(size_t nelem, size_t size)
struct s_linked_vptr * next
static const char * match(const struct slre *, int, const char *, int, int *, struct cap *)