@@ -30,7 +30,6 @@ OTHER DEALINGS IN THE SOFTWARE.
30
30
#include " odin_types.h"
31
31
#include " odin_util.h"
32
32
#include " node_creation_library.h"
33
- #include " soft_logic_def_parser.h"
34
33
#include " adders.h"
35
34
#include " netlist_utils.h"
36
35
#include " partial_map.h"
@@ -1355,20 +1354,10 @@ int match_pins(nnode_t *node, nnode_t *next_node)
1355
1354
return flag;
1356
1355
}
1357
1356
1358
-
1359
- /* ---------------------------------------------------------------------------------------------
1360
- * ###########################################################
1361
- * These are function for the soft_logic adders only
1362
- *-------------------------------------------------------------------------------------------*/
1363
- void connect_output_pin_to_node (int *width, int current_pin, int output_pin_id, nnode_t *node, nnode_t *current_adder, short subtraction);
1364
- nnode_t *make_mux_2to1 (nnode_t *select, nnode_t *port_a, nnode_t *port_b, nnode_t *node, short mark);
1365
- nnode_t *make_adder (operation_list funct, nnode_t *current_adder, nnode_t *previous_carry, int *width, int current_pin, netlist_t *netlist, nnode_t *node, short subtraction, short mark);
1366
- nnode_t *make_bec (operation_list funct, nnode_t *current_adder, nnode_t *previous_carry, int *width, int current_pin, netlist_t *netlist, nnode_t *node, short subtraction, short mark);
1367
-
1368
1357
/* ---------------------------------------------------------------------------------------------
1369
1358
* connect adder type output pin to a node
1370
1359
*-------------------------------------------------------------------------------------------*/
1371
- void connect_output_pin_to_node (int *width, int current_pin, int output_pin_id, nnode_t *node, nnode_t *current_adder, short subtraction)
1360
+ static void connect_output_pin_to_node (int *width, int current_pin, int output_pin_id, nnode_t *node, nnode_t *current_adder, short subtraction)
1372
1361
{
1373
1362
// output
1374
1363
if (subtraction)
@@ -1390,75 +1379,10 @@ void connect_output_pin_to_node(int *width, int current_pin, int output_pin_id,
1390
1379
}
1391
1380
}
1392
1381
1393
- /* ---------------------------------------------------------------------------------------------
1394
- * makes a 2 to 1 mux (select == 1)? port_a : port_b
1395
- *-------------------------------------------------------------------------------------------*/
1396
- nnode_t *make_mux_2to1 (nnode_t *select, nnode_t *port_a, nnode_t *port_b, nnode_t *node, short mark)
1397
- {
1398
- nnode_t *mux_2 = make_2port_gate (MUX_2, 2 , 2 , 1 , node, mark);
1399
-
1400
- // driver
1401
- nnode_t *notted_gate = make_not_gate (node,mark);
1402
- connect_nodes (select,0 ,notted_gate,0 );
1403
-
1404
-
1405
- connect_nodes (select,0 ,mux_2,0 );
1406
- connect_nodes (notted_gate,0 ,mux_2,1 );
1407
-
1408
- // connect carry skip to mux
1409
- connect_nodes (port_a,0 ,mux_2,2 );
1410
- connect_nodes (port_b,0 ,mux_2,3 );
1411
- return mux_2;
1412
- }
1413
-
1414
- nnode_t *make_bec (operation_list funct, nnode_t *current_adder, nnode_t *previous_carry, int * /* width */ , int /* current_pin */ , netlist_t *netlist, nnode_t *node, short /* subtraction */ , short mark)
1415
- {
1416
- nnode_t *new_funct = NULL ;
1417
- if (previous_carry == netlist->vcc_node )
1418
- {
1419
- if (funct == ADDER_FUNC)
1420
- {
1421
- new_funct = make_not_gate (node, mark);
1422
- connect_nodes (current_adder, 0 , new_funct, 0 );
1423
- }
1424
- else if (funct == CARRY_FUNC)
1425
- {
1426
- new_funct = current_adder;
1427
- }
1428
- }
1429
- else if (previous_carry == netlist->gnd_node )
1430
- {
1431
- if (funct == ADDER_FUNC)
1432
- {
1433
- new_funct = current_adder;
1434
- }
1435
- else if (funct == CARRY_FUNC)
1436
- {
1437
- new_funct = netlist->gnd_node ;
1438
- }
1439
- }
1440
- else
1441
- {
1442
- if (funct == ADDER_FUNC)
1443
- {
1444
- new_funct = make_2port_gate (LOGICAL_XOR, 1 , 1 , 1 , node, mark);
1445
- connect_nodes (previous_carry,0 , new_funct, 0 );
1446
- connect_nodes (current_adder,0 , new_funct, 1 );
1447
- }
1448
- else if (funct == CARRY_FUNC)
1449
- {
1450
- new_funct = make_2port_gate (LOGICAL_AND, 1 , 1 , 1 , node, mark);
1451
- connect_nodes (previous_carry,0 , new_funct, 0 );
1452
- connect_nodes (current_adder,0 , new_funct, 1 );
1453
- }
1454
- }
1455
- return new_funct;
1456
- }
1457
-
1458
1382
/* ---------------------------------------------------------------------------------------------
1459
1383
* make a single half-adder (can do unary subtraction, binary subtraction and addition)
1460
1384
*-------------------------------------------------------------------------------------------*/
1461
- nnode_t *make_adder (operation_list funct, nnode_t *current_adder, nnode_t *previous_carry, int *width, int current_pin, netlist_t *netlist, nnode_t *node, short subtraction, short mark)
1385
+ static nnode_t *make_adder (operation_list funct, nnode_t *current_adder, nnode_t *previous_carry, int *width, int current_pin, netlist_t *netlist, nnode_t *node, short subtraction, short mark)
1462
1386
{
1463
1387
// make a 2 bit 0r 3 bit sum or carry based on previous carry
1464
1388
nnode_t *new_funct = NULL ;
@@ -1481,10 +1405,7 @@ nnode_t *make_adder(operation_list funct, nnode_t *current_adder, nnode_t *previ
1481
1405
}
1482
1406
else
1483
1407
{
1484
- if (funct == ADDER_FUNC)
1485
- new_funct = make_3port_gate (ADDER_FUNC, 1 , 1 , 1 , 1 , node, mark);
1486
- else if (funct == CARRY_FUNC)
1487
- new_funct = make_3port_gate (CARRY_FUNC, 1 , 1 , 1 , 1 , node, mark);
1408
+ new_funct = make_3port_gate (funct, 1 , 1 , 1 , 1 , node, mark);
1488
1409
connect_nodes (previous_carry, 0 , new_funct, 0 );
1489
1410
is_three_port_gate = 1 ;
1490
1411
}
@@ -1562,126 +1483,20 @@ nnode_t *make_adder(operation_list funct, nnode_t *current_adder, nnode_t *previ
1562
1483
return new_funct;
1563
1484
}
1564
1485
1565
- /* **---------------------------------------------------------------------------------------------
1566
- *
1567
- * bit # : | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
1568
- * blk_type: R->[heterogenous ]
1569
- * [blk size and blk type ]
1570
- *
1571
- * the first bit is built from an/xor gate, everything between could be anything
1572
- * create a single adder block using adder_type_definition file input to select blk size and type
1573
- *-------------------------------------------------------------------------------------------*/
1574
1486
void instantiate_add_w_carry_block (int *width, nnode_t *node, short mark, netlist_t *netlist, short subtraction)
1575
1487
{
1576
- // set the default
1577
- int blk_size = width[0 ];
1578
- nnode_t *initial_carry = (subtraction)? netlist->vcc_node : netlist->gnd_node ;
1579
- for (int start_pin=0 , current_counter=1 ; start_pin<width[0 ]; start_pin+=blk_size, current_counter++)
1580
- {
1581
- std::string my_type = " soft" ;
1582
- std::string sub_structure = " default" ;
1583
- blk_size = width[0 ]-start_pin;
1584
-
1585
- soft_sub_structure *def = fetch_blk (" +" ,width[0 ]-start_pin);
1586
- if (def)
1587
- {
1588
- blk_size = (def->bitsize > blk_size)? blk_size: def->bitsize ;
1589
-
1590
- // don't optimize small circuit
1591
- if (blk_size != 1 )
1592
- {
1593
- my_type = def->type ;
1594
- sub_structure = def->name ;
1595
- }
1596
-
1597
- /* pretty print info */
1598
- if (current_counter == 1 )
1599
- printf (" \n ::%s\n [target-bit_size:<%d>START]~" , node->name , width[0 ]-start_pin);
1600
-
1601
- printf (" ~[<%s><%s>::%d]~" ,my_type.c_str (), sub_structure.c_str (), blk_size);
1602
-
1603
- if (blk_size+start_pin == width[0 ]){
1604
- printf (" ~[END::sub_module_count:<%d>] \n " , current_counter);
1605
- fflush (stdout);
1606
- }
1607
- }
1608
-
1609
- nnode_t *previous_carry = initial_carry;
1610
- nnode_t *previous_carry_gnd = netlist->gnd_node ;
1611
- nnode_t *previous_carry_vcc = netlist->vcc_node ;
1612
-
1613
- for (int i = start_pin; i < start_pin+blk_size; i++)
1614
- {
1615
- /* set of flags for building purposes */
1616
- short construct_last_carry_flag = (i != width[0 ]-1 || !subtraction)? 1 :0 ;
1617
- short last_pin_on_blk_flag = (i == start_pin+blk_size-1 )? 1 :0 ;
1618
-
1619
- if (my_type == " soft" )
1620
- {
1621
- // Ripple Carry Adder
1622
- if (sub_structure == " default" ){
1623
- // build adder
1624
- nnode_t *current_adder = make_adder (ADDER_FUNC, NULL , previous_carry, width, i, netlist, node, subtraction, mark);
1625
- if (construct_last_carry_flag)
1626
- previous_carry = make_adder (CARRY_FUNC, current_adder, previous_carry, width, i, netlist, node, subtraction, mark);
1627
-
1628
- connect_output_pin_to_node (width, i, 0 , node, current_adder, subtraction);
1629
- }
1630
- // Carry Select Adder
1631
- else if (sub_structure == " csla" )
1632
- {
1633
- nnode_t *current_adder_gnd = make_adder (ADDER_FUNC, NULL , previous_carry_gnd, width, i, netlist, node, subtraction, mark);
1634
- if (construct_last_carry_flag)
1635
- previous_carry_gnd = make_adder (CARRY_FUNC, current_adder_gnd, previous_carry_gnd, width, i, netlist, node, subtraction, mark);
1636
-
1637
- nnode_t *current_adder_vcc = make_adder (ADDER_FUNC, current_adder_gnd, previous_carry_vcc, width, i, netlist, node, subtraction, mark);
1638
- if (construct_last_carry_flag)
1639
- previous_carry_vcc = make_adder (CARRY_FUNC, current_adder_gnd, previous_carry_vcc, width, i, netlist, node, subtraction, mark);
1640
-
1641
- nnode_t *current_adder = make_mux_2to1 (previous_carry, current_adder_vcc, current_adder_gnd, node, mark);
1642
-
1643
- if (last_pin_on_blk_flag && construct_last_carry_flag)
1644
- previous_carry = make_mux_2to1 (previous_carry, previous_carry_vcc, previous_carry_gnd, node, mark);
1645
-
1646
- connect_output_pin_to_node (width, i, 0 , node, current_adder, subtraction);
1647
- }
1648
- // binary to excess Carry Select Adder
1649
- else if (sub_structure == " bec_csla" )
1650
- {
1651
- nnode_t *current_adder_gnd = make_adder (ADDER_FUNC, NULL , previous_carry_gnd, width, i, netlist, node, subtraction, mark);
1652
- if (construct_last_carry_flag)
1653
- previous_carry_gnd = make_adder (CARRY_FUNC, current_adder_gnd, previous_carry_gnd, width, i, netlist, node, subtraction, mark);
1488
+ nnode_t *previous_carry = (subtraction)? netlist->vcc_node : netlist->gnd_node ;
1654
1489
1655
- nnode_t *current_adder_vcc = make_bec (ADDER_FUNC, current_adder_gnd, previous_carry_vcc, width, i, netlist, node, subtraction, mark);
1656
- if (construct_last_carry_flag)
1657
- previous_carry_vcc = make_bec (CARRY_FUNC, current_adder_gnd, previous_carry_vcc, width, i, netlist, node, subtraction, mark);
1658
-
1659
- nnode_t *current_adder = make_mux_2to1 (previous_carry, current_adder_vcc, current_adder_gnd, node, mark);
1490
+ for (int i = 0 ; i < width[0 ]; i++)
1491
+ {
1492
+ /* set of flags for building purposes */
1493
+ short construct_last_carry_flag = (i != width[0 ]-1 || !subtraction)? 1 :0 ;
1660
1494
1661
- if (last_pin_on_blk_flag && construct_last_carry_flag)
1662
- previous_carry = make_mux_2to1 (previous_carry, previous_carry_vcc, previous_carry_gnd, node, mark);
1495
+ // build Ripple Carry Adder
1496
+ nnode_t *current_adder = make_adder (ADDER_FUNC, NULL , previous_carry, width, i, netlist, node, subtraction, mark);
1497
+ if (construct_last_carry_flag)
1498
+ previous_carry = make_adder (CARRY_FUNC, current_adder, previous_carry, width, i, netlist, node, subtraction, mark);
1663
1499
1664
- connect_output_pin_to_node (width, i, 0 , node, current_adder, subtraction);
1665
- }
1666
- else
1667
- {
1668
- error_message (NETLIST_ERROR, -1 , -1 , " ( %s )is not a valid substructure name" , sub_structure.c_str ());
1669
- return ;
1670
- }
1671
- }
1672
- else // if(my_type == "hard")
1673
- {
1674
- // carry lookahead
1675
- // if(sub_structure == "cla")
1676
- // {
1677
- // error_message(NETLIST_ERROR, -1, -1, "( %s )is not a valid substructure name", sub_structure.c_str());
1678
- // }
1679
- // else
1680
- // {
1681
- error_message (NETLIST_ERROR, -1 , -1 , " ( %s )is not a valid substructure name" , sub_structure.c_str ());
1682
- // }
1683
- }
1684
- }
1685
- initial_carry = previous_carry;
1500
+ connect_output_pin_to_node (width, i, 0 , node, current_adder, subtraction);
1686
1501
}
1687
1502
}
0 commit comments