40 #include <boost/format.hpp>
64 using namespace ProGe;
84 generateBusTrace_(
false),
85 exportBustrace_(
false),
86 busTraceStartingCycle_(0) {}
94 delete (*iter).second;
126 coreBlock.
port(NetlistGenerator::DECODER_CLOCK_PORT);
128 NetlistGenerator::DECODER_CLOCK_PORT,
"1",
BIT,
ProGe::IN, *icBlock);
132 coreBlock.
port(NetlistGenerator::DECODER_RESET_PORT);
134 NetlistGenerator::DECODER_RESET_PORT,
"1",
BIT,
ProGe::IN, *icBlock);
143 for (
int i = 0; i < socketNav.
count(); i++) {
153 if (socket->
direction() == Socket::INPUT) {
158 "data port of the input socket %s is zero!\n") %
165 for (
int i = 0; i < socket->
portCount(); i++) {
173 socketDirection, *icBlock);
183 socketDirection, *icBlock);
188 socketDirection, *icBlock);
201 for (
int i = 0; i < socket->
portCount(); i++) {
215 socketDirection, *icBlock);
220 socketDirection, *icBlock);
260 for (
int i = 0; i < busNav.
count(); i++) {
284 const std::string& dstDirectory) {
292 string errorMsg =
"Unable to create file " + icFile;
295 std::ofstream icStream(icFile.c_str(), std::ofstream::out);
309 for (
int i = 0; i < busNav.
count(); i++) {
314 "IC generator does not support segmented buses.");
319 if (bridgeNav.
count() > 0) {
322 "IC generator does not support bridges.");
367 if (socket.
direction() != Socket::OUTPUT) {
373 if (seg == &segment) {
389 bool needSimmSocket =
true;
391 for (
int i = 0; i < socketNav.
count(); i++) {
401 needSimmSocket =
false;
414 if (needSimmSocket) {
416 for (
int i = 0; i < busNav.
count(); i++) {
434 for (
int i = 0; i < gcu->
portCount(); i++) {
436 if (gcuPort == port) {
455 const std::string& dstDirectory)
const {
457 direction, portConns, segmentConns);
462 string errorMsg =
"Unable to create file " + pathToFile;
466 std::ofstream stream(pathToFile.c_str(), std::ofstream::out);
468 stream <<
"library IEEE;" << endl;
469 stream <<
"use IEEE.std_logic_1164.all;" << endl;
470 stream <<
"use IEEE.std_logic_arith.all;" << endl;
471 stream <<
"use work.tce_util.all;" << endl;
476 if (direction == Socket::INPUT) {
478 }
else if (direction == Socket::OUTPUT) {
494 int segmentConns, std::ofstream& stream)
const {
498 stream <<
"entity " << entityName <<
" is" << endl << endl;
500 stream << endl <<
"end " << entityName <<
";" << endl << endl;
502 stream <<
"architecture rtl of " << entityName <<
" is" << endl
506 <<
"-- If width of input bus is greater than width of output,"
508 stream <<
indentation(2) <<
"-- using the LSB bits." << endl;
510 <<
"-- If width of input bus is smaller than width of output,"
513 <<
"-- using zero extension to generate extra bits." << endl;
516 if (segmentConns > 1) {
520 for (
int i = 0; i < segmentConns; i++) {
522 if (i + 1 < segmentConns) {
525 stream <<
")" << endl;
531 <<
" <= (others => '0');" << endl;
535 for (
int i = 0; i < segmentConns; i++) {
536 if (i+1 < segmentConns) {
542 stream <<
indentation(3) <<
"when others =>" << endl;
548 stream <<
indentation(1) <<
"end process sel;" << endl;
555 <<
" <= (others => '0');" << endl;
557 stream <<
indentation(1) <<
"end process;" << endl;
560 stream <<
"end rtl;" << endl;
563 stream <<
"`timescale 10ns/1ns" << endl
564 <<
"module " << entityName <<
"" << endl << endl;
567 <<
"// If width of input bus is greater than width of output,"
569 <<
indentation(2) <<
"// using the LSB bits." << endl
571 <<
"// If width of input bus is smaller than width of output,"
574 <<
"// using zero extension to generate extra bits." << endl
576 if (segmentConns > 1) {
580 for (
int i = 0; i < segmentConns; i++) {
582 if (i + 1 < segmentConns) {
585 stream <<
")" << endl;
591 for (
int i = 0; i < segmentConns; i++) {
592 if (i+1 < segmentConns) {
594 << i <<
" :" << endl;
609 stream <<
"endmodule" << endl;
622 int bus,
int ind, std::ofstream& stream)
const {
626 <<
"'length);" << endl;
636 <<
"-1 : 0];" << endl
640 <<
"-1 : 0];" << endl;
655 std::ofstream& stream)
const {
658 stream <<
"entity " << entityName <<
" is" << endl;
660 portConns, segmentConns, 1, stream);
661 stream <<
"end " << entityName <<
";" << endl << endl << endl;
663 stream <<
"architecture output_socket_andor of " << entityName
668 stream <<
indentation(1) <<
"constant data_widths : integer_array("
669 << portConns - 1 <<
" downto 0) := (";
670 for (
int i = 0; i < portConns; i++) {
672 if (i+1 < portConns) {
676 stream <<
");" << endl;
678 for (
int i = 0; i < segmentConns; i++) {
680 <<
"_temp : std_logic_vector(return_highest(data_widths, "
681 << portConns <<
")-1 downto 0);" << endl;
685 <<
"signal data : std_logic_vector(return_highest(data_widths, "
686 << portConns <<
")-1 downto 0);" << endl;
688 for (
int i = 0; i < segmentConns; i++) {
691 <<
"-1 downto 0);" << endl;
693 stream <<
indentation(1) <<
"signal data : std_logic_vector("
698 stream <<
"begin -- output_socket_andor" << endl << endl;
702 for (
int i = 0; i < portConns; i++) {
706 stream <<
indentation(1) <<
"begin -- process data_sel" << endl;
707 for (
int i = 0; i < portConns; i++) {
710 stream <<
"if conv_integer(unsigned("
713 }
else if (i < portConns-1) {
714 stream <<
"elsif conv_integer(unsignd("
718 stream <<
"else" << endl;
725 stream <<
indentation(1) <<
"end process data_sel;" << endl
729 <<
";" << endl << endl;
732 stream <<
indentation(1) <<
"internal_signal : process(data, "
734 stream <<
indentation(1) <<
"begin -- process internal_signal"
737 for (
int i = 0; i < segmentConns; i++) {
740 <<
"(" << i <<
" downto " << i <<
"), data'length);"
744 stream <<
indentation(1) <<
"end process internal_signal;" << endl
749 for (
int i = 0; i < segmentConns; i++) {
750 stream <<
"databus_" << i <<
"_temp";
751 if (i+1 < segmentConns) {
754 stream <<
")" << endl;
758 stream <<
indentation(1) <<
"begin -- process output" << endl;
760 for (
int i = 0; i < segmentConns; i++) {
762 <<
" <= tce_ext(databus_" << i <<
"_temp, "
765 stream <<
indentation(1) <<
"end process output;" << endl << endl;
766 stream <<
"end output_socket_andor;" << endl;
768 stream <<
"`timescale 10ns/1ns" << endl
769 <<
"module " << entityName << endl;
771 portConns, segmentConns, 1, stream);
776 stream <<
"//architecture output_socket_andor of " << entityName
781 "Case portConns > 1 not supported by Verilog backend!");
805 for (
int i = 0; i < segmentConns; i++) {
809 <<
" databus_" << i <<
"_temp;" << endl;
825 stream <<
"*" <<
")" << endl;
826 stream <<
indentation(1) <<
"begin // process data_sel" << endl;
827 for (
int i = 0; i < portConns; i++) {
833 }
else if (i < portConns-1) {
839 stream <<
"else" << endl;
845 stream <<
indentation(1) <<
"end //process data_sel;" << endl
850 <<
";" << endl << endl;
856 stream <<
indentation(1) <<
"begin //process internal_signal"
859 for (
int i = 0; i < segmentConns; i++) {
861 <<
"databus_" << i <<
"_temp"
864 <<
"[" << i <<
" : " << i <<
"]}};"
868 stream <<
indentation(1) <<
"end //process internal_signal;" << endl
882 stream <<
indentation(1) <<
"begin // process output" << endl;
884 for (
int i = 0; i < segmentConns; i++) {
886 <<
" < " << data_length <<
")" << endl;
888 <<
" = databus_" << i <<
"_temp;" << endl;
892 <<
" = $unsigned(databus_" << i <<
"_temp);"
895 stream <<
indentation(1) <<
"end //process output;" << endl << endl;
896 stream <<
"endmodule //output_socket_andor;" << endl;
907 stream <<
indentation(1) <<
"db_bustraces <= " << endl;
911 for (
int i = 0; i < busNav.
count(); i++) {
917 int idx = busNav.
count() - 1 - i;
918 int busWidth = busNav.
item(idx)->width();
922 stream <<
"\"" << string(32 - busWidth,
'0') <<
"\"&";
927 if (i != busNav.
count() - 1) {
949 stream <<
"library IEEE;" << endl;
950 stream <<
"use IEEE.std_logic_1164.all;" << endl;
951 stream <<
"use IEEE.std_logic_arith.ext;" << endl;
952 stream <<
"use IEEE.std_logic_arith.sxt;" << endl;
954 stream <<
"use IEEE.numeric_std.all;" << endl;
955 stream <<
"use IEEE.math_real.all;" << endl;
956 stream <<
"use STD.textio.all;" << endl;
957 stream <<
"use IEEE.std_logic_textio.all;" << endl;
959 stream <<
"use work." <<
entityNameStr_ <<
"_globals.all;" << endl
960 <<
"use work.tce_util.all;" << endl
964 stream <<
"entity " << entityName <<
" is" << endl << endl;
972 VHDLNetlistWriter::writeGenericDeclaration(
974 VHDLNetlistWriter::writePortDeclaration(
977 stream << endl <<
"end " << entityName <<
";" << endl << endl;
980 stream <<
"architecture comb_andor of " << entityName <<
" is" << endl
986 stream <<
"begin -- comb_andor" << endl << endl;
1000 std::set<Socket*, Component::ComponentNameComparator> socketsToWrite;
1001 for (
int i = 0; i < socketNav.
count(); i++) {
1002 socketsToWrite.insert(socketNav.
item(i));
1006 socketsToWrite.begin();
1007 iter != socketsToWrite.end(); iter++) {
1010 if (segmentCount == 0 || socket->
portCount() == 0) {
1015 stream <<
indentation(2) <<
"generic map (" << endl;
1016 for (
int i = 0; i < segmentCount; i++) {
1017 int actualGenericWidth = 0;
1018 if (socket->
direction() == Socket::OUTPUT) {
1020 }
else if (socket->
direction() == Socket::INPUT) {
1021 actualGenericWidth =
1025 << actualGenericWidth <<
"," << endl;
1027 if (socket->
direction() == Socket::OUTPUT) {
1028 for (
int i = 0; i < socket->
portCount(); i++) {
1029 string socketWidth =
"";
1045 <<
" => " << socketWidth;
1047 stream <<
")" << endl;
1049 stream <<
"," << endl;
1061 <<
" => " << socketWidth <<
")"
1065 for (
int i = 0; i < segmentCount; i++) {
1068 if (socket->
direction() == Socket::INPUT) {
1077 if (socket->
direction() == Socket::OUTPUT) {
1078 for (
int i = 0; i < socket->
portCount(); i++) {
1083 stream <<
"," << endl;
1092 stream <<
"," << endl;
1097 stream <<
"," << endl;
1101 stream <<
");" << endl << endl;
1106 for (
int i = 0; i < busNav.
count(); i++) {
1111 stream <<
indentation(2) <<
"generic map (" << endl;
1128 for (
int i = 0; i < busNav.
count(); i++) {
1133 <<
" <= (others=>'0');" << endl;
1137 std::set<Socket*, Component::ComponentNameComparator> socketsToWrite;
1138 for (std::set<Socket*>::iterator iter =
outputSockets.begin();
1140 socketsToWrite.insert(*iter);
1144 for (
auto iter = socketsToWrite.begin();
1145 iter != socketsToWrite.end();) {
1147 stream <<
"tce_ext(" <<
busAltSignal(*bus, *socket) <<
", "
1150 if (iter != socketsToWrite.end()) {
1155 if (socketsToWrite.begin() != socketsToWrite.end()) {
1159 stream <<
"tce_sxt(";
1161 stream <<
"tce_ext(";
1163 assert(
false &&
"Unknown extension policy.");
1166 <<
", " <<
busSignal(*bus) <<
"'length)";
1168 stream <<
";" << endl;
1172 stream <<
"end comb_andor;" << endl;
1177 stream <<
"`timescale 1ns/1ns" << endl
1178 <<
"module " << entityName << endl
1185 VerilogNetlistWriter::writePortDeclaration(
1187 VerilogNetlistWriter::writeGenericDeclaration(
1201 std::set<Socket*, Component::ComponentNameComparator> socketsToWrite;
1202 for (
int i = 0; i < socketNav.
count(); i++) {
1203 socketsToWrite.insert(socketNav.
item(i));
1207 socketsToWrite.begin(); iter != socketsToWrite.end(); iter++) {
1210 if (segmentCount == 0 || socket->
portCount() == 0) {
1217 for (
int i = 0; i < segmentCount; i++) {
1223 if (socket->
direction() == Socket::OUTPUT) {
1224 for (
int i = 0; i < socket->
portCount(); i++) {
1225 string socketWidth =
"";
1233 <<
"(" << socketWidth;
1235 stream <<
")" << endl;
1237 stream <<
")," << endl;
1249 <<
"(" << socketWidth <<
")"
1255 for (
int i = 0; i < segmentCount; i++) {
1258 if (socket->
direction() == Socket::INPUT) {
1267 if (socket->
direction() == Socket::OUTPUT) {
1268 for (
int i = 0; i < socket->
portCount(); i++) {
1273 stream <<
")," << endl;
1282 stream <<
")," << endl;
1287 stream <<
")," << endl;
1291 stream <<
"));" << endl << endl;
1296 for (
int i = 0; i < busNav.
count(); i++) {
1306 << bus->
width() <<
")," << endl
1322 for (
int i = 0; i < busNav.
count(); i++) {
1327 std::set<Socket*, Component::ComponentNameComparator> socketsToWrite;
1328 for (std::set<Socket*>::iterator iter =
outputSockets.begin();
1330 socketsToWrite.insert(*iter);
1335 socketsToWrite.begin(); iter != socketsToWrite.end();) {
1339 if (iter != socketsToWrite.end()) {
1344 if (socketsToWrite.begin() != socketsToWrite.end()) {
1349 stream <<
";" << endl;
1352 stream <<
"endmodule"<< endl;
1367 for (
int i = 0; i < busNav.
count(); i++) {
1373 <<
" : std_logic_vector(" << bus->
width() - 1
1374 <<
" downto 0);" << endl;
1381 std::set<Socket*, Component::ComponentNameComparator>
1383 for (std::set<Socket*>::iterator iter =
outputSockets.begin();
1385 socketsToWrite.insert(*iter);
1388 for (std::set<Socket*, Component::ComponentNameComparator>::
1389 iterator iter = socketsToWrite.begin();
1390 iter != socketsToWrite.end(); iter++) {
1392 <<
busAltSignal(*bus, **iter) <<
" : std_logic_vector("
1394 <<
" downto 0);" << endl;
1401 <<
" downto 0);" << endl;
1405 for (
int i = 0; i < busNav.
count(); i++) {
1414 std::set<Socket*, Component::ComponentNameComparator> socketsToWrite;
1415 for (std::set<Socket*>::iterator iter =
outputSockets.begin();
1417 socketsToWrite.insert(*iter);
1420 for (std::set<Socket*, Component::ComponentNameComparator>::iterator
1421 iter = socketsToWrite.begin(); iter != socketsToWrite.end();
1446 int segmentCount = iter->second;
1448 stream <<
indentation(1) <<
"component " << entityName <<
" is"
1451 stream <<
indentation(1) <<
"end component;" << endl << endl;
1456 int portCount = iter->first;
1457 int segmentCount = iter->second;
1459 stream <<
indentation(1) <<
"component " << entityName <<
" is"
1462 VHDL, portCount, segmentCount, 2, stream);
1463 stream <<
indentation(1) <<
"end component;" << endl << endl;
1483 std::ostream& stream) {
1485 if (language ==
VHDL) {
1486 stream <<
indentation(ind) <<
"generic (" << endl;
1488 for (
int i = 0; i < segmentConns; i++) {
1490 <<
" : integer := 32;" << endl;
1493 for (
int i = 0; i < portConns; i++) {
1495 <<
" : integer := 32";
1496 if (i+1 == portConns) {
1497 stream <<
");" << endl;
1499 stream <<
";" << endl;
1504 for (
int i = 0; i < segmentConns; i++) {
1507 <<
"-1 downto 0);" << endl;
1509 for (
int i = 0; i < portConns; i++) {
1512 <<
"-1 downto 0);" << endl;
1520 if (portConns > 1) {
1521 stream <<
";" << endl;
1523 Socket::OUTPUT, portConns);
1526 <<
" downto 0));" << endl;
1528 stream <<
");" << endl;
1531 stream <<
indentation(ind) <<
"#( parameter " << endl;
1533 for (
int i = 0; i < segmentConns; i++) {
1535 <<
" = 32," << endl;
1538 for (
int i = 0; i < portConns; i++) {
1541 if (i+1 == portConns) {
1542 stream <<
")" << endl;
1544 stream <<
"," << endl;
1549 for (
int i = 0; i < segmentConns; i++) {
1556 for (
int i = 0; i < portConns; i++) {
1570 if (portConns > 1) {
1571 stream <<
"," << endl;
1573 Socket::OUTPUT, portConns);
1576 <<
" : 0]);" << endl;
1578 stream <<
");" << endl;
1597 std::ostream& stream) {
1599 if (language ==
VHDL) {
1600 stream <<
indentation(ind) <<
"generic (" << endl;
1602 for (
int i = 0; i < segmentConns; i++) {
1604 " : integer := 32;" << endl;
1608 <<
" : integer := 32);" << endl;
1611 for (
int i = 0; i < segmentConns; i++) {
1614 <<
"-1 downto 0);" << endl;
1621 if (segmentConns > 1) {
1622 stream <<
";" << endl;
1624 <<
" : in std_logic_vector(" << controlWidth - 1
1625 <<
" downto 0));" << endl;
1627 stream <<
");" << endl;
1630 stream <<
indentation(ind) <<
"#( parameter " << endl;
1632 for (
int i = 0; i < segmentConns; i++) {
1638 <<
" = 32)" << endl;
1641 for (
int i = 0; i < segmentConns; i++) {
1653 if (segmentConns > 1) {
1654 stream <<
"," << endl;
1656 <<
"input[" << controlWidth - 1
1660 stream <<
");" << endl;
1674 const std::string vhdlFunctionCeil4 =
1675 " -- Rounds integer up to next multiple of four.\n"
1676 " function ceil4 (\n"
1677 " constant val : natural)\n"
1678 " return natural is\n"
1679 " begin -- function ceil4\n"
1680 " return natural(ceil(real(val)/real(4)))*4;\n"
1681 " end function ceil4;\n";
1683 const std::string vhdlFunctionExt4 =
1684 " -- Extends std_logic_vector to multiple of four.\n"
1685 " function ext_to_multiple_of_4 (\n"
1686 " constant slv : std_logic_vector)\n"
1687 " return std_logic_vector is\n"
1689 " return std_logic_vector(resize(\n"
1690 " unsigned(slv), ceil4(slv'length)));\n"
1691 " end function ext_to_multiple_of_4;\n";
1693 const std::string vhdlFunctionToHex =
1694 " function to_unsigned_hex (\n"
1695 " constant slv : std_logic_vector) return string is\n"
1696 " variable resized_slv : std_logic_vector(ceil4(slv'length)"
1698 " variable result : string(1 to ceil4(slv'length)/4)\n"
1699 " := (others => ' ');\n"
1700 " subtype digit_t is std_logic_vector(3 downto 0);\n"
1701 " variable digit : digit_t := \"0000\";\n"
1703 " resized_slv := ext_to_multiple_of_4(slv);\n"
1704 " for i in result'range loop\n"
1705 " digit := resized_slv(\n"
1706 " resized_slv'length-((i-1)*4)-1 downto "
1707 "resized_slv'length-(i*4));\n"
1709 " when \"0000\" => result(i) := '0';\n"
1710 " when \"0001\" => result(i) := '1';\n"
1711 " when \"0010\" => result(i) := '2';\n"
1712 " when \"0011\" => result(i) := '3';\n"
1713 " when \"0100\" => result(i) := '4';\n"
1714 " when \"0101\" => result(i) := '5';\n"
1715 " when \"0110\" => result(i) := '6';\n"
1716 " when \"0111\" => result(i) := '7';\n"
1717 " when \"1000\" => result(i) := '8';\n"
1718 " when \"1001\" => result(i) := '9';\n"
1719 " when \"1010\" => result(i) := 'a';\n"
1720 " when \"1011\" => result(i) := 'b';\n"
1721 " when \"1100\" => result(i) := 'c';\n"
1722 " when \"1101\" => result(i) := 'd';\n"
1723 " when \"1110\" => result(i) := 'e';\n"
1724 " when \"1111\" => result(i) := 'f';\n"
1726 " -- For TTAsim bustrace compatibility\n"
1727 " when others => \n"
1728 " result := (others => '0');\n"
1731 " end loop; -- i in result'range\n"
1733 " end function to_unsigned_hex;\n";
1736 <<
"-- Dump the value on the buses into a file once in clock cycle"
1739 <<
"-- setting DUMP false will disable dumping" << endl << endl;
1740 stream <<
indentation(1) <<
"-- Do not synthesize this process!" << endl;
1741 stream <<
indentation(1) <<
"-- pragma synthesis_off" << endl;
1742 stream <<
indentation(1) <<
"-- pragma translate_off" << endl;
1744 stream <<
indentation(1) <<
"file_output : process" << endl << endl;
1746 <<
"file regularfileout : text;" << endl;
1748 <<
"file executionfileout : text;" << endl << endl;
1749 stream <<
indentation(2) <<
"variable lineout : line;" << endl;
1750 stream <<
indentation(2) <<
"variable start : boolean := true;" << endl;
1751 stream <<
indentation(2) <<
"variable cyclecount : integer := 0;"
1753 stream <<
indentation(2) <<
"variable executioncount : integer := 0;"
1755 stream <<
indentation(2) <<
"constant DUMP : boolean := true;" << endl;
1757 <<
"constant REGULARDUMPFILE : string := \"bus.dump\";"
1760 <<
"constant EXECUTIONDUMPFILE : string := \"execbus.dump\";"
1762 stream << vhdlFunctionCeil4 << endl;
1763 stream << vhdlFunctionExt4 << endl;
1764 stream << vhdlFunctionToHex << endl;
1766 stream <<
indentation(2) <<
"if DUMP = true then" << endl;
1767 stream <<
indentation(3) <<
"if start = true then" << endl;
1769 <<
"file_open(regularfileout, REGULARDUMPFILE, write_mode);"
1772 <<
"file_open(executionfileout, EXECUTIONDUMPFILE, write_mode);"
1774 stream <<
indentation(4) <<
"start := false;" << endl;
1775 stream <<
indentation(3) <<
"end if;" << endl << endl;
1777 stream <<
indentation(3) <<
"-- wait until rising edge of clock"
1780 <<
"wait on clk until clk = '1' and clk'last_value = '0';"
1786 <<
") then" << endl;
1789 stream <<
indentation(ind) <<
"write(lineout, cyclecount-"
1794 for (
int i = 0; i < busNav.
count(); i++) {
1795 stream <<
indentation(ind) <<
"write(lineout, string'(\",\"));"
1798 <<
"write(lineout, to_unsigned_hex("
1803 <<
"writeline(regularfileout, lineout);" << endl;
1805 stream <<
indentation(ind) <<
"if glock = '0' then" << endl;
1806 stream <<
indentation(ind+1) <<
"write(lineout, executioncount" <<
");"
1809 for (
int i = 0; i < busNav.
count(); i++) {
1810 stream <<
indentation(ind+1) <<
"write(lineout, string'(\",\"));"
1813 <<
"write(lineout, to_unsigned_hex("
1817 <<
"writeline(executionfileout, lineout);" << endl;
1818 stream <<
indentation(ind+1) <<
"executioncount := executioncount + 1;"
1825 stream <<
indentation(3) <<
"cyclecount := cyclecount + 1;" << endl;
1827 stream <<
indentation(1) <<
"end process file_output;" << endl;
1828 stream <<
indentation(1) <<
"-- pragma translate_on" << endl;
1829 stream <<
indentation(1) <<
"-- pragma synthesis_on" << endl;
1833 <<
"// Dump the value on the buses into a file once in clock cycle"
1836 <<
"// setting DUMP false will disable dumping" << endl << endl
1837 <<
indentation(1) <<
"// Do not synthesize!" << endl
1838 <<
indentation(1) <<
"//synthesis translate_off" << endl
1839 <<
indentation(1) <<
"integer regularfileout;" << endl << endl
1840 <<
indentation(1) <<
"integer executionfileout;" << endl << endl
1842 <<
indentation(1) <<
"integer executioncount=0;" << endl << endl
1843 <<
indentation(1) <<
"`define REGULARDUMPFILE \"bus.dump\""
1845 <<
"`define EXECUTIONDUMPFILE \"execbus.dump\""
1851 <<
"regularfileout = $fopen(`REGULARDUMPFILE,\"w\");" << endl
1852 <<
indentation(2) <<
"$fclose(regularfileout);" << endl
1854 <<
"executionfileout = $fopen(`EXECUTIONDUMPFILE,\"w\");"
1856 <<
indentation(2) <<
"$fclose(executionfileout);" << endl
1865 std::string format_string =
"%0d";
1866 std::string count_string =
"count - " +
1868 std::string variable_list =
"";
1871 for (
int i = 0; i < busNav.
count(); i++) {
1872 const Bus& bus = *busNav.
item(i);
1873 format_string +=
",%0"
1875 variable_list +=
", $unsigned(" +
1881 "$fopen(`REGULARDUMPFILE,\"a\");" << endl
1883 <<
"\"" << format_string <<
"\\n\"" <<
", "
1884 << count_string << variable_list <<
");" << endl
1885 <<
indentation(4) <<
"$fclose(regularfileout);" << endl
1889 "$fopen(`EXECUTIONDUMPFILE,\"a\");" << endl
1891 <<
"\"" << format_string <<
"\\n\"" <<
", executioncount"
1892 << variable_list <<
");" << endl
1893 <<
indentation(5) <<
"$fclose(executionfileout);" << endl
1894 <<
indentation(5) <<
"executioncount = executioncount + 1;"
1901 <<
indentation(1) <<
"//synthesis translate_on" << endl;
1938 if (socket->
direction() == Socket::INPUT) {
1960 if (socket->
direction() == Socket::OUTPUT) {
1994 auto test_pair = std::make_pair(portConns, segmentConns);
1996 if (direction == Socket::INPUT) {
1998 }
else if (direction == Socket::OUTPUT) {
2018 if (socket.
direction() != Socket::OUTPUT) {
2022 for (
int i = 0; i < socket.
portCount(); i++) {
2023 if (socket.
port(i) == &port) {
2051 if (seg == &segment) {
2073 for (
int i = 0; i < socket.
portCount(); i++) {
2075 if (width < port->width()) {
2076 width = port->
width();
2108 int maxPortWidth = 0;
2110 for (
int i = 0; i < socket.
portCount(); i++) {
2112 if (maxPortWidth < port->width()) {
2113 maxPortWidth = port->
width();
2116 return maxPortWidth;
2135 if (direction == Socket::INPUT) {
2155 if (direction == Socket::OUTPUT) {
2176 assert(
false &&
"Unknown extension policy.");
2191 return "socket_" + socket +
"_data";
2205 const std::string& socket,
2221 return "socket_" + name +
"_bus_cntrl";
2233 return "socket_" + name +
"_data_cntrl";
2245 return "simm_" + busName;
2258 return "simm_cntrl_" + busName;
2304 return bus.
name() +
"_mux_ctrl_in";
2309 return bus.
name() +
"_mux_enable_in";
2320 return "databus_" + bus.
name();
2344 for (
auto iter = signalMap->begin(); iter != signalMap->end();
2346 if ((*iter).second > maxValue) {
2347 maxValue = (*iter).second;
2351 signalMap->emplace(&socket, maxValue);
2354 int value = signalMap->at(&socket);
2391 return "simm_socket_" + bus.
name();
2403 return "databus_" + bus.
name() +
"_simm";
2418 switch (direction) {
2421 case Socket::OUTPUT:
2445 if (direction == Socket::INPUT) {
2447 ((language ==
VHDL) ?
".vhdl" :
".v");
2448 }
else if (direction == Socket::OUTPUT) {
2449 return "output_socket_" +
2465 if (socket.
direction() == Socket::INPUT) {
2467 }
else if (socket.
direction() == Socket::OUTPUT) {
2504 return bus.
name() +
"_bus_mux_inst";
2515 for (
unsigned int i = 0; i < level; i++) {