24 , pipeline_mode(II, latency)
25 , supported_modes(std::move(supported_modes_))
29 std::cout << II <<
'\n';
30 make_and_throw<cgrame_error>([&](
auto&& s) { s <<
"dont support an II other than 1 (given II=" << II <<
')'; });
35 make_and_throw<cgrame_error>([&](
auto&& s) { s <<
"fracturable unit does not support opcode: " << mode; });
309 {
OpCode::MULU_FULL_LO, {
"op_multiply_unsigned_full_lo",
"multiply_unsigned_full_lo", {
"//mulu_full_lo;"},
"mulu_full_lo_sel"}},
310 {
OpCode::MULU_HALF_LO, {
"op_multiply_unsigned_half_lo",
"multiply_unsigned_half_lo", {
"//mulu_half_lo;"},
"mulu_half_lo_sel"}},
311 {
OpCode::MULU_QUART_LO, {
"op_multiply_unsigned_quart_lo",
"multiply_unsigned_quart_lo", {
"//mulu_quart_lo;"},
"mulu_quart_lo_sel"}},
312 {
OpCode::MULU_FULL_HI, {
"op_multiply_unsigned_full_hi",
"multiply_unsigned_full_hi", {
"//mulu_full_hi;"},
"mulu_full_hi_sel"}},
313 {
OpCode::MULU_HALF_HI, {
"op_multiply_unsigned_half_hi",
"multiply_unsigned_half_hi", {
"//mulu_half_hi;"},
"mulu_half_hi_sel"}},
314 {
OpCode::MULU_QUART_HI, {
"op_multiply_unsigned_quart_hi",
"multiply_unsigned_quart_hi", {
"//mulu_quart_hi;"},
"mulu_quart_hi_sel"}},
315 {
OpCode::MULS_FULL_LO, {
"op_multiply_signed_full_lo",
"multiply_signed_full_lo", {
"//muls_full_lo;"},
"muls_full_lo_sel"}},
316 {
OpCode::MULS_HALF_LO, {
"op_multiply_signed_half_lo",
"multiply_signed_half_lo", {
"//muls_half_lo;"},
"muls_half_lo_sel"}},
317 {
OpCode::MULS_QUART_LO, {
"op_multiply_signed_quart_lo",
"multiply_signed_quart_lo", {
"//muls_quart_lo;"},
"muls_quart_lo_sel"}},
318 {
OpCode::MULS_FULL_HI, {
"op_multiply_signed_full_hi",
"multiply_signed_full_hi", {
"//muls_full_hi;"},
"muls_full_hi_sel"}},
319 {
OpCode::MULS_HALF_HI, {
"op_multiply_signed_half_hi",
"multiply_signed_half_hi", {
"//muls_half_hi;"},
"muls_half_hi_sel"}},
320 {
OpCode::MULS_QUART_HI, {
"op_multiply_signed_quart_hi",
"multiply_signed_quart_hi", {
"//muls_quart_hi;"},
"muls_quart_hi_sel"}}
340 , pipeline_mode(II, latency)
357 nlohmann::json vjson;
360 vjson[
"prefix"] =
"cgrame_";
361 vjson[
"parameters"] = {};
364 vjson[
"parameters"].push_back(parameter.first);
366 vjson[
"interface"] = {};
367 for (
auto& port :
ports)
369 std::string portName = port.second->getName();
370 vjson[
"interface"].push_back(portName);
374 std::string portName = port.getName();
375 vjson[
"interface"].push_back(portName);
379 std::string moduleDefinition;
380 for (
auto& port :
ports)
383 std::string portTypeString = {};
386 portTypeString =
"input";
390 portTypeString =
"output";
394 portTypeString =
"output reg";
398 portTypeString =
"inout";
400 std::string portSizeString;
401 if (!(port.second->parameter).empty())
403 std::string portParameterName = port.second->parameter;
404 portSizeString =
"[" + portParameterName +
"-1:0]";
408 portSizeString =
"[" +
std::to_string(port.second->size - 1) +
":0]";
410 std::string portName = port.second->getName();
411 std::string portDeclaration = portTypeString +
" " + portSizeString +
" " + portName +
";\n";
412 moduleDefinition += std::string(
SET_INDENT) + portDeclaration;
416 moduleDefinition += std::string(
SET_INDENT) +
"wire sign_a0, sign_a1, sign_a2, sign_a3, sign_b0, sign_b1, sign_b2, sign_b3, sign_out0, sign_out1, sign_out2, sign_out3;\n";
417 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_a0 = in_a[size-1];\n";
418 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_a1 = in_a[size/4*3-1];\n";
419 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_a2 = in_a[size/2-1];\n";
420 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_a3 = in_a[size/4-1];\n";
421 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_b0 = in_b[size-1];\n";
422 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_b1 = in_b[size/4*3-1];\n";
423 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_b2 = in_b[size/2-1];\n";
424 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_b3 = in_b[size/4-1];\n\n";
426 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_out0 = sign_a0 ^ sign_b0;\n";
427 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_out1 = sign_a1 ^ sign_b1;\n";
428 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_out2 = sign_a2 ^ sign_b2;\n";
429 moduleDefinition += std::string(
SET_INDENT) +
"assign sign_out3 = sign_a3 ^ sign_b3;\n\n";
432 moduleDefinition += std::string(
SET_INDENT) +
"wire b0, b1, b2;\n";
433 moduleDefinition += std::string(
SET_INDENT) +
"wire a_c1, a_c2, a_c3, a_carry1, a_carry2, a_carry3;\n";
434 moduleDefinition += std::string(
SET_INDENT) +
"wire b_c1, b_c2, b_c3, b_carry1, b_carry2, b_carry3;\n";
435 moduleDefinition += std::string(
SET_INDENT) +
"wire [(size/4)-1:0] comp_a0, comp_a1, comp_a2, comp_a3;\n";
436 moduleDefinition += std::string(
SET_INDENT) +
" wire [(size/4)-1:0] comp_b0, comp_b1, comp_b2, comp_b3;\n\n";
439 moduleDefinition += std::string(
SET_INDENT) +
"assign b0 = (m_sel==5'd8 | m_sel==5'd11) ? 1'b1 : 1'b0;\n";
440 moduleDefinition += std::string(
SET_INDENT) +
"assign b1 = (m_sel==5'd7 | m_sel==5'd10 | m_sel==5'd8 | m_sel==5'd11) ? 1'b1 : 1'b0;\n";
441 moduleDefinition += std::string(
SET_INDENT) +
"assign b2 = (m_sel==5'd8 | m_sel==5'd11) ? 1'b1 : 1'b0;\n\n";
444 moduleDefinition += std::string(
SET_INDENT) +
"assign a_c1 = (m_sel==5'd6 | m_sel==5'd9 | m_sel==5'd7 | m_sel==5'd10) ? a_carry1 : 1'b0;\n";
445 moduleDefinition += std::string(
SET_INDENT) +
"assign a_c2 = (m_sel==5'd6 | m_sel==5'd9) ? a_carry2 : 1'b0;\n";
446 moduleDefinition += std::string(
SET_INDENT) +
"assign a_c3 = (m_sel==5'd6 | m_sel==5'd9 | m_sel==5'd7 | m_sel==5'd10) ? a_carry3 : 1'b0;\n\n";
448 moduleDefinition += std::string(
SET_INDENT) +
"assign b_c1 = (m_sel==5'd6 | m_sel==5'd9 | m_sel==5'd7 | m_sel==5'd10) ? b_carry1 : 1'b0; // full or half\n";
449 moduleDefinition += std::string(
SET_INDENT) +
"assign b_c2 = (m_sel==5'd6 | m_sel==5'd9) ? b_carry2 : 1'b0; // full\n";
450 moduleDefinition += std::string(
SET_INDENT) +
"assign b_c3 = (m_sel==5'd6 | m_sel==5'd9 | m_sel==5'd7 | m_sel==5'd10) ? b_carry3 : 1'b0; // full or half\n\n";
453 moduleDefinition += std::string(
SET_INDENT) +
"assign comp_a0 = ~in_a[size-1 : size/4*3] + b0;\n";
454 moduleDefinition += std::string(
SET_INDENT) +
"assign {a_carry1, comp_a1} = ~in_a[(size/4*3)-1 : size/2] + b1;\n";
455 moduleDefinition += std::string(
SET_INDENT) +
"assign {a_carry2, comp_a2} = ~in_a[(size/2)-1 : size/4] + b2;\n";
456 moduleDefinition += std::string(
SET_INDENT) +
"assign {a_carry3, comp_a3} = ~in_a[(size/4)-1 : 0] + 1'b1;\n\n";
458 moduleDefinition += std::string(
SET_INDENT) +
"assign comp_b0 = ~in_b[size-1 : size/4*3] + b0;\n";
459 moduleDefinition += std::string(
SET_INDENT) +
"assign {b_carry1, comp_b1} = ~in_b[(size/4*3)-1 : size/2] + b1;\n";
460 moduleDefinition += std::string(
SET_INDENT) +
"assign {b_carry2, comp_b2} = ~in_b[(size/2)-1 : size/4] + b2;\n";
461 moduleDefinition += std::string(
SET_INDENT) +
"assign {b_carry3, comp_b3} = ~in_b[(size/4)-1 : 0] + 1'b1;\n\n";
464 moduleDefinition += std::string(
SET_INDENT) +
"wire [size-1:0] unsigned_a, unsigned_b;\n";
465 moduleDefinition += std::string(
SET_INDENT) +
"wire [size-1:0] comped_a, comped_b;\n\n";
467 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_a[size-1 : size/4*3] = sign_a0 ? comp_a0 : in_a[size-1 : size/4*3];\n";
468 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_a[(size/4*3)-1 : size/2] = ( (sign_a0 & (m_sel==5'd6 | m_sel==5'd9 | m_sel==5'd7 | m_sel==5'd10)) | (sign_a1 & (m_sel==5'd8 | m_sel==5'd11)) ) ? comp_a1 : in_a[(size/4*3)-1 : size/2];\n";
469 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_a[(size/2)-1 : size/4] = ( (sign_a0 & (m_sel==5'd6 | m_sel==5'd9)) | (sign_a2 & (m_sel==5'd7 | m_sel==5'd10 | m_sel==5'd8 | m_sel==5'd11)) ) ? comp_a2 : in_a[(size/2)-1 : size/4];\n";
470 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_a[(size/4)-1 : 0] = ( (sign_a0 & (m_sel==5'd6 | m_sel==5'd9)) | (sign_a2 & (m_sel==5'd7 | m_sel==5'd10)) | (sign_a3 & (m_sel==5'd8 | m_sel==5'd11)) ) ? comp_a3 : in_a[(size/4)-1 : 0];\n\n";
472 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_b[size-1 : size/4*3] = sign_b0 ? comp_b0 : in_b[size-1 : size/4*3];\n";
473 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_b[(size/4*3)-1 : size/2] = ( (sign_b0 & (m_sel==5'd6 | m_sel==5'd9 | m_sel==5'd7 | m_sel==5'd10)) | (sign_b1 & (m_sel==5'd8 | m_sel==5'd11)) ) ? comp_b1 : in_b[(size/4*3)-1 : size/2];\n";
474 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_b[(size/2)-1 : size/4] = ( (sign_b0 & (m_sel==5'd6 | m_sel==5'd9)) | (sign_b2 & (m_sel==5'd7 | m_sel==5'd10 | m_sel==5'd8 | m_sel==5'd11)) ) ? comp_b2 : in_b[(size/2)-1 : size/4];\n";
475 moduleDefinition += std::string(
SET_INDENT) +
"assign comped_b[(size/4)-1 : 0] = ( (sign_b0 & (m_sel==5'd6 | m_sel==5'd9)) | (sign_b2 & (m_sel==5'd7 | m_sel==5'd10)) | (sign_b3 & (m_sel==5'd8 | m_sel==5'd11)) ) ? comp_b3 : in_b[(size/4)-1 : 0];\n\n";
477 moduleDefinition += std::string(
SET_INDENT) +
"assign unsigned_a = (m_sel < 5'd6) ? in_a : comped_a;\n";
478 moduleDefinition += std::string(
SET_INDENT) +
"assign unsigned_b = (m_sel < 5'd6) ? in_b : comped_b;\n\n";
504 moduleDefinition += std::string(
SET_INDENT) +
"wire [size/2-1:0] m0_op1, m0_op2, m1_op1, m1_op2, m2_op1, m2_op2, m3_op1, m3_op2;\n";
506 moduleDefinition += std::string(
SET_INDENT) +
"assign m0_op1 = (m_sel%3 == 2) ? {unsigned_a[size-1:size/4*3], 8'b0} : unsigned_a[size-1:size/2];\n";
507 moduleDefinition += std::string(
SET_INDENT) +
"assign m0_op2 = (m_sel%3 == 2) ? {unsigned_b[size-1:size/4*3], 8'b0} : unsigned_b[size-1:size/2];\n";
508 moduleDefinition += std::string(
SET_INDENT) +
"assign m1_op1 = (m_sel%3 == 2) ? {8'b0, unsigned_a[size/4*3-1:size/2]} : unsigned_a[size-1:size/2];\n";
509 moduleDefinition += std::string(
SET_INDENT) +
"assign m1_op2 = (m_sel%3 == 2) ? {8'b0, unsigned_b[size/4*3-1:size/2]} : unsigned_b[size/2-1:0];\n";
510 moduleDefinition += std::string(
SET_INDENT) +
"assign m2_op1 = (m_sel%3 == 2) ? {unsigned_a[size/2-1:size/4], 8'b0} : unsigned_a[size/2-1:0];\n";
511 moduleDefinition += std::string(
SET_INDENT) +
"assign m2_op2 = (m_sel%3 == 2) ? {unsigned_b[size/2-1:size/4], 8'b0} : unsigned_b[size-1:size/2];\n";
512 moduleDefinition += std::string(
SET_INDENT) +
"assign m3_op1 = (m_sel%3 == 2) ? {8'b0, unsigned_a[size/4-1:0]} : unsigned_a[size/2-1:0];\n";
513 moduleDefinition += std::string(
SET_INDENT) +
"assign m3_op2 = (m_sel%3 == 2) ? {8'b0, unsigned_b[size/4-1:0]} : unsigned_b[size/2-1:0];\n\n";
516 moduleDefinition += std::string(
SET_INDENT) +
"wire [size-1:0] m0_out, m1_out, m2_out, m3_out;\n";
518 moduleDefinition += std::string(
SET_INDENT) +
"assign m0_out = m0_op1 * m0_op2;\n";
519 moduleDefinition += std::string(
SET_INDENT) +
"assign m1_out = m1_op1 * m1_op2;\n";
520 moduleDefinition += std::string(
SET_INDENT) +
"assign m2_out = m2_op1 * m2_op2;\n";
521 moduleDefinition += std::string(
SET_INDENT) +
"assign m3_out = m3_op1 * m3_op2;\n\n";
524 moduleDefinition += std::string(
SET_INDENT) +
"wire [2*size-1:0] out_mul_full, out_mul_full_0;\n";
525 moduleDefinition += std::string(
SET_INDENT) +
"wire [size-1:0] out_mul_half_0, out_mul_half_1;\n";
526 moduleDefinition += std::string(
SET_INDENT) +
"wire [size/2-1:0] out_mul_quart_0, out_mul_quart_1, out_mul_quart_2, out_mul_quart_3;\n";
528 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_full = (m0_out << size) + ((m1_out + m2_out) << (size/2)) + m3_out;\n";
529 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_full_0 = (sign_out0 & (m_sel >= 6)) ? ~out_mul_full + 1'b1 : out_mul_full;\n";
530 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_half_0 = (sign_out0 & (m_sel >= 6)) ? ~m0_out + 1'b1 : m0_out;\n";
531 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_half_1 = (sign_out2 & (m_sel >= 6)) ? ~m3_out + 1'b1 : m3_out;\n";
532 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_quart_0 = (sign_out0 & (m_sel >= 6)) ? ~m0_out[size-1:size/2] + 1'b1 : m0_out[size-1:size/2];\n";
533 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_quart_1 = (sign_out1 & (m_sel >= 6)) ? ~m1_out[size/2-1:0] + 1'b1 : m1_out[size/2-1:0];\n";
534 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_quart_2 = (sign_out2 & (m_sel >= 6)) ? ~m2_out[size-1:size/2] + 1'b1 : m2_out[size-1:size/2];\n";
535 moduleDefinition += std::string(
SET_INDENT) +
"assign out_mul_quart_3 = (sign_out3 & (m_sel >= 6)) ? ~m3_out[size/2-1:0] + 1'b1 : m3_out[size/2-1:0];\n\n";
537 moduleDefinition += std::string(
SET_INDENT) +
"always @(*) begin\n";
539 moduleDefinition += std::string(
SET_TRIPLE_INDENT) +
"3'd0: begin // lo -----------------\n";
540 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = out_mul_full_0[size-1:0];\n";
543 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = {out_mul_half_0[size/2-1:0], out_mul_half_1[size/2-1:0]};\n";
546 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = {out_mul_quart_0[size/4-1:0], out_mul_quart_1[size/4-1:0], out_mul_quart_2[size/4-1:0], out_mul_quart_3[size/4-1:0]};\n";
548 moduleDefinition += std::string(
SET_TRIPLE_INDENT) +
"3'd3: begin // hi -----------------\n";
549 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = out_mul_full_0[2*size-1:size];\n";
552 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = {out_mul_half_0[size-1:size/2], out_mul_half_1[size-1:size/2]};\n";
555 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = {out_mul_quart_0[size/2-1:size/4], out_mul_quart_1[size/2-1:size/4], out_mul_quart_2[size/2-1:size/4], out_mul_quart_3[size/2-1:size/4]};\n";
558 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = {size{1'bx}};\n";
561 moduleDefinition += std::string(
SET_INDENT) +
"end";
563 vjson[
"definition"] = moduleDefinition;
575 (void)mrrg_nodes_from_val_node;
582 for (
const auto& op_and_mrrg_nodes : mrrg_nodes_from_op_node) {
583 for (
const auto& mrrg_node : op_and_mrrg_nodes.second) {
584 opNodesByCycle[mrrg_node->cycle][op_and_mrrg_nodes.first].insert(mrrg_node);
589 for (
auto & op_and_mrrg_nodes : opNodesByCycle) {
590 if (op_and_mrrg_nodes.empty()) {
592 }
else if (op_and_mrrg_nodes.size() == 1) {
595 throw cgrame_error(
"couldn't find op in supported modes list");
612 auto& result = *result_ptr;
614 for(
unsigned i = 0; i < II; i+=
getII())
624 result.link(in_a, fu);
625 result.link(in_b, fu);
629 for(
unsigned i = 0; i < II; i+=
getII())
634 result.link(fu, out_next);
650 {
OpCode::ADD_FULL, {
"op_add_full",
"add_full", {
"//add_full;"},
"add_full_sel"}},
651 {
OpCode::ADD_HALF, {
"op_add_half",
"add_half", {
"//add_half;"},
"add_half_sel"}},
652 {
OpCode::ADD_QUART, {
"op_add_quart",
"add_quart", {
"//add_quart;"},
"add_quart_sel"}}
663 , pipeline_mode(II, latency)
680 nlohmann::json vjson;
683 vjson[
"prefix"] =
"cgrame_";
684 vjson[
"parameters"] = {};
687 vjson[
"parameters"].push_back(parameter.first);
689 vjson[
"interface"] = {};
690 for (
auto& port :
ports)
692 std::string portName = port.second->getName();
693 vjson[
"interface"].push_back(portName);
697 std::string portName = port.getName();
698 vjson[
"interface"].push_back(portName);
702 std::string moduleDefinition;
703 for (
auto& port :
ports)
706 std::string portTypeString = {};
709 portTypeString =
"input";
713 portTypeString =
"output";
717 portTypeString =
"output reg";
721 portTypeString =
"inout";
723 std::string portSizeString;
724 if (!(port.second->parameter).empty())
726 std::string portParameterName = port.second->parameter;
727 portSizeString =
"[" + portParameterName +
"-1:0]";
731 portSizeString =
"[" +
std::to_string(port.second->size - 1) +
":0]";
733 std::string portName = port.second->getName();
734 std::string portDeclaration = portTypeString +
" " + portSizeString +
" " + portName +
";\n";
735 moduleDefinition += std::string(
SET_INDENT) + portDeclaration;
739 moduleDefinition += std::string(
SET_INDENT) +
"wire a1_carry, a2_carry, a3_carry;\n";
740 moduleDefinition += std::string(
SET_INDENT) +
"wire [size/4-1:0] a0_out, a1_out, a2_out, a3_out;\n";
741 moduleDefinition += std::string(
SET_INDENT) +
"wire [size-1:0] f0;\n";
742 moduleDefinition += std::string(
SET_INDENT) +
"wire [size/2-1:0] h0, h1;\n";
743 moduleDefinition += std::string(
SET_INDENT) +
"wire [size/4-1:0] q0, q1, q2, q3;\n";
744 moduleDefinition += std::string(
SET_INDENT) +
"wire [size-1:0] out_add_full, out_add_half, out_add_quart;\n\n";
747 moduleDefinition += std::string(
SET_INDENT) +
"assign a0_out = in_a[size-1:size/4*3] + in_b[size-1:size/4*3];\n";
748 moduleDefinition += std::string(
SET_INDENT) +
"assign {a1_carry, a1_out} = in_a[size/4*3-1:size/2] + in_b[size/4*3-1:size/2];\n";
749 moduleDefinition += std::string(
SET_INDENT) +
"assign {a2_carry, a2_out} = in_a[size/2-1:size/4] + in_b[size/2-1:size/4];\n";
750 moduleDefinition += std::string(
SET_INDENT) +
"assign {a3_carry, a3_out} = in_a[size/4-1:0] + in_b[size/4-1:0];\n\n";
753 moduleDefinition += std::string(
SET_INDENT) +
"assign f0 = {(a0_out + a1_carry), (a1_out + a2_carry), (a2_out + a3_carry), a3_out};\n";
754 moduleDefinition += std::string(
SET_INDENT) +
"assign h0 = {(a0_out + a1_carry), a1_out};\n";
755 moduleDefinition += std::string(
SET_INDENT) +
"assign h1 = {(a2_out + a3_carry), a3_out};\n";
756 moduleDefinition += std::string(
SET_INDENT) +
"assign q0 = a0_out;\n";
757 moduleDefinition += std::string(
SET_INDENT) +
"assign q1 = a1_out;\n";
758 moduleDefinition += std::string(
SET_INDENT) +
"assign q2 = a2_out;\n";
759 moduleDefinition += std::string(
SET_INDENT) +
"assign q3 = a3_out;\n\n";
761 moduleDefinition += std::string(
SET_INDENT) +
"assign out_add_full = f0;\n";
762 moduleDefinition += std::string(
SET_INDENT) +
"assign out_add_half = {h0, h1};\n";
763 moduleDefinition += std::string(
SET_INDENT) +
"assign out_add_quart = {q0, q1, q2, q3};\n\n";
766 moduleDefinition += std::string(
SET_INDENT) +
"always @* begin\n";
769 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = out_add_full;\n";
772 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = out_add_half;\n";
775 moduleDefinition += std::string(
SET_QUAD_INDENT) +
"out = out_add_quart;\n";
781 moduleDefinition += std::string(
SET_INDENT) +
"end";
783 vjson[
"definition"] = moduleDefinition;
795 (void)mrrg_nodes_from_val_node;
802 for (
const auto& op_and_mrrg_nodes : mrrg_nodes_from_op_node) {
803 for (
const auto& mrrg_node : op_and_mrrg_nodes.second) {
804 opNodesByCycle[mrrg_node->cycle][op_and_mrrg_nodes.first].insert(mrrg_node);
809 for (
auto & op_and_mrrg_nodes : opNodesByCycle) {
810 if (op_and_mrrg_nodes.empty()) {
812 }
else if (op_and_mrrg_nodes.size() == 1) {
815 throw cgrame_error(
"couldn't find op in supported modes list");
832 auto& result = *result_ptr;
834 for(
unsigned i = 0; i < II; i+=
getII())
844 result.link(in_a, fu);
845 result.link(in_b, fu);
849 for(
unsigned i = 0; i < II; i+=
getII())
854 result.link(fu, out_next);