34 os <<
"BitStream {\n";
37 os << ccell->getName() <<
": " << bitSetting <<
'\n';
46 const auto context_storage_size = 1;
47 static const char*
const total_num_bits_localparam =
"TOTAL_NUM_BITS";
48 static const char*
const clock_sig =
"clock";
49 static const char*
const enable_sig =
"enable";
50 static const char*
const sync_reset_sig =
"sync_reset";
51 static const char*
const bitstream_sig =
"bitstream";
52 static const char*
const done_sig =
"done";
53 static const char*
const storage =
"storage";
54 static const char*
const storage_pos =
"next_pos";
55 int num_of_elastic_ccells = 0;
57 const auto& ccell = *ccell_it;
59 num_of_elastic_ccells++;
62 if (num_of_elastic_ccells == 0) num_of_elastic_ccells = 1;
64 return accum + ccell_and_setting.first->getStorageSize() * ccell_and_setting.second.size();
68 "module CGRA_configurator(\n"
69 " input "<<clock_sig<<
",\n"
70 " input "<<enable_sig<<
",\n"
71 " input "<<sync_reset_sig<<
",\n"
73 " output reg "<<bitstream_sig<<
",\n"
74 " output reg "<<done_sig<<
"\n"
77 " localparam "<<total_num_bits_localparam<<
" = " << total_num_bits <<
";\n"
84 os <<
"\treg [0:"<<total_num_bits_localparam<<
"-1] "<<storage<<
" = {\n";
87 const auto& ccell = *ccell_it;
90 for (
auto bitsetting_cycle_it = rbegin(setting); bitsetting_cycle_it != rend(setting); ++bitsetting_cycle_it) {
91 for (
auto bitsetting_it = rbegin(*bitsetting_cycle_it); bitsetting_it != rend(*bitsetting_cycle_it); ++bitsetting_it) {
93 const auto& bitsetting = *bitsetting_it;
95 if (std::next(ccell_it) != rend(
ccell_order) || std::next(bitsetting_cycle_it) != rend(setting) || std::next(bitsetting_it) != rend(*bitsetting_cycle_it)) {
102 for (
int i = used_contexts.size(); i > 0; i-- ) {
109 os <<
" // " << ccell->getAllConnectedPorts().at(0)->getModule().parent->getName() <<
"::" << ccell->getName() <<
'\n';
115 " reg [31:0] "<<storage_pos<<
";\n"
116 " always @(posedge "<<clock_sig<<
") begin\n"
117 " if (sync_reset) begin\n"
118 " "<<storage_pos<<
" <= 0;\n"
119 " "<<bitstream_sig<<
" <= 1'b0;\n"
120 " "<<done_sig<<
" <= 0;\n"
121 " end else if ("<<storage_pos<<
" >= "<<total_num_bits_localparam<<
") begin\n"
122 " "<<done_sig<<
" <= 1;\n"
123 " "<<bitstream_sig<<
" <= 1'b0;\n"
124 " end else if ("<<enable_sig<<
") begin\n"
125 " "<<bitstream_sig<<
" <= "<<storage<<
"["<<storage_pos<<
"];\n"
126 " "<<storage_pos<<
" <= "<<storage_pos<<
" + 1;\n"