| Line 893... | Line 893... | 
      
        | "\toutput       reg                             o_sync;\n"
 | "\toutput       reg                             o_sync;\n"
 | 
      
        | "\n"
 | "\n"
 | 
      
        | "\treg  wait_for_sync;\n"
 | "\treg  wait_for_sync;\n"
 | 
      
        | "\treg  [(2*IWIDTH-1):0]        ib_a, ib_b;\n"
 | "\treg  [(2*IWIDTH-1):0]        ib_a, ib_b;\n"
 | 
      
        | "\treg  [(2*CWIDTH-1):0]        ib_c;\n"
 | "\treg  [(2*CWIDTH-1):0]        ib_c;\n"
 | 
      
        | "\treg  ib_sync, b_ce;\n"
 | "\treg  ib_sync;\n"
 | 
      
        | "\n"
 | "\n"
 | 
      
        | "\treg  b_started;\n"
 | "\treg  b_started;\n"
 | 
      
        | "\twire ob_sync;\n"
 | "\twire ob_sync;\n"
 | 
      
        | "\twire [(2*OWIDTH-1):0]        ob_a, ob_b;\n");
 | "\twire [(2*OWIDTH-1):0]        ob_a, ob_b;\n");
 | 
      
        |         fprintf(fstage,
 |         fprintf(fstage,
 | 
      
        | Line 954... | Line 954... | 
      
        |  
 |  
 | 
      
        |         fprintf(fstage,
 |         fprintf(fstage,
 | 
      
        | "\treg  [(LGWIDTH-2):0]         iaddr;\n"
 | "\treg  [(LGWIDTH-2):0]         iaddr;\n"
 | 
      
        | "\treg  [(2*IWIDTH-1):0]        imem    [0:((1<<LGSPAN)-1)];\n"
 | "\treg  [(2*IWIDTH-1):0]        imem    [0:((1<<LGSPAN)-1)];\n"
 | 
      
        | "\n"
 | "\n"
 | 
      
        | "\treg  [(LGSPAN-1):0]          oB;\n"
 | "\treg  [LGSPAN:0]              oB;\n"
 | 
      
        | "\treg  [(2*OWIDTH-1):0]        omem    [0:((1<<LGSPAN)-1)];\n"
 | "\treg  [(2*OWIDTH-1):0]        omem    [0:((1<<LGSPAN)-1)];\n"
 | 
      
        | "\n"
 | "\n"
 | 
      
        | "\talways @(posedge i_clk)\n"
 | "\talways @(posedge i_clk)\n"
 | 
      
        |         "\t\tif (i_rst)\n"
 |         "\t\tif (i_rst)\n"
 | 
      
        |         "\t\tbegin\n"
 |         "\t\tbegin\n"
 | 
      
        |                 "\t\t\twait_for_sync <= 1'b1;\n"
 |                 "\t\t\twait_for_sync <= 1'b1;\n"
 | 
      
        |                 "\t\t\tiaddr <= 0;\n"
 |                 "\t\t\tiaddr <= 0;\n"
 | 
      
        |                 "\t\t\toB <= 0;\n"
 |                 "\t\t\toB <= 0;\n"
 | 
      
        |                 "\t\t\tb_ce <= 1'b0;\n"
 |                 "\t\t\tib_sync   <= 1'b0;\n"
 | 
      
        |   |                 "\t\t\to_sync    <= 1'b0;\n"
 | 
      
        |   |                 "\t\t\tb_started <= 1'b0;\n"
 | 
      
        |         "\t\tend\n"
 |         "\t\tend\n"
 | 
      
        |         "\t\telse if ((i_ce)&&((~wait_for_sync)||(i_sync)))\n"
 |         "\t\telse if ((i_ce)&&((~wait_for_sync)||(i_sync)))\n"
 | 
      
        |         "\t\tbegin\n"
 |         "\t\tbegin\n"
 | 
      
        |                 "\t\t\t//\n"
 |                 "\t\t\t//\n"
 | 
      
        |                 "\t\t\t// First step: Record what we\'re not ready to use yet\n"
 |                 "\t\t\t// First step: Record what we\'re not ready to use yet\n"
 | 
      
        | Line 989... | Line 991... | 
      
        |                         "\t\t\t\t// Set the sync to true on the very first\n"
 |                         "\t\t\t\t// Set the sync to true on the very first\n"
 | 
      
        |                         "\t\t\t\t// valid input in, and hence on the very\n"
 |                         "\t\t\t\t// valid input in, and hence on the very\n"
 | 
      
        |                         "\t\t\t\t// first valid data out per FFT.\n"
 |                         "\t\t\t\t// first valid data out per FFT.\n"
 | 
      
        |                         "\t\t\t\tib_sync <= (iaddr==(1<<(LGSPAN)));\n"
 |                         "\t\t\t\tib_sync <= (iaddr==(1<<(LGSPAN)));\n"
 | 
      
        |                         "\t\t\t\tib_c <= %scmem[iaddr[(LGSPAN-1):0]];\n"
 |                         "\t\t\t\tib_c <= %scmem[iaddr[(LGSPAN-1):0]];\n"
 | 
      
        |                         "\t\t\t\tb_ce <= 1'b1;\n"
 |                 "\t\t\tend else begin\n"
 | 
      
        |                 "\t\t\tend else\n"
 |                         "\t\t\t\t// Just to make debugging easier, let\'s\n"
 | 
      
        |                         "\t\t\t\tb_ce <= 1'b0;\n"
 |                         "\t\t\t\t// clear these registers.  That\'ll make\n"
 | 
      
        |   |                         "\t\t\t\t// the transition easier to watch.\n"
 | 
      
        |   |                         "\t\t\t\tib_a <= {(2*IWIDTH){1'b0}};\n"
 | 
      
        |   |                         "\t\t\t\tib_b <= {(2*IWIDTH){1'b0}};\n"
 | 
      
        |   |                         "\t\t\t\tib_sync <= 1'b0;\n"
 | 
      
        |   |                 "\t\t\tend\n"
 | 
      
        | "\n"
 | "\n"
 | 
      
        |                 "\t\t\t//\n"
 |                 "\t\t\t//\n"
 | 
      
        |                 "\t\t\t// Next step: recover the outputs from the butterfly\n"
 |                 "\t\t\t// Next step: recover the outputs from the butterfly\n"
 | 
      
        |                 "\t\t\t//\n"
 |                 "\t\t\t//\n"
 | 
      
        |                 "\t\t\tif ((ob_sync||b_started)&&(b_ce))\n"
 |                 "\t\t\tif ((ob_sync||b_started)&&(~oB[LGSPAN]))\n"
 | 
      
        |                 "\t\t\tbegin // A butterfly output is available\n"
 |                 "\t\t\tbegin // A butterfly output is available\n"
 | 
      
        |                         "\t\t\t\tb_started <= 1'b1;\n"
 |                         "\t\t\t\tb_started <= 1'b1;\n"
 | 
      
        |                         "\t\t\t\tomem[oB] <= ob_b;\n"
 |                         "\t\t\t\tomem[oB[(LGSPAN-1):0]] <= ob_b;\n"
 | 
      
        |                         "\t\t\t\toB <= oB+1;\n"
 |                         "\t\t\t\toB <= oB+1;\n"
 | 
      
        | "\n"
 | "\n"
 | 
      
        |                         "\t\t\t\to_sync <= (ob_sync);\n"
 |                         "\t\t\t\to_sync <= (ob_sync);\n"
 | 
      
        |                         "\t\t\t\to_data <= ob_a;\n"
 |                         "\t\t\t\to_data <= ob_a;\n"
 | 
      
        |                 "\t\t\tend else if (b_started)\n"
 |                 "\t\t\tend else if (b_started)\n"
 | 
      
        |                 "\t\t\tbegin // and keep outputting once you start--at a rate\n"
 |                 "\t\t\tbegin // and keep outputting once you start--at a rate\n"
 | 
      
        |                 "\t\t\t// of one guaranteed output per clock that has i_ce set.\n"
 |                 "\t\t\t// of one guaranteed output per clock that has i_ce set.\n"
 | 
      
        |                         "\t\t\t\to_data <= omem[oB];\n"
 |                         "\t\t\t\to_data <= omem[oB[(LGSPAN-1):0]];\n"
 | 
      
        |                         "\t\t\t\toB <= oB + 1;\n"
 |                         "\t\t\t\toB <= oB + 1;\n"
 | 
      
        |                         "\t\t\t\to_sync <= 1'b0;\n"
 |                         "\t\t\t\to_sync <= 1'b0;\n"
 | 
      
        |                 "\t\t\tend else\n"
 |                 "\t\t\tend else\n"
 | 
      
        |                         "\t\t\t\to_sync <= 1'b0;\n"
 |                         "\t\t\t\to_sync <= 1'b0;\n"
 | 
      
        |         "\t\tend\n"
 |         "\t\tend\n"
 | 
      
        | "\n", (inv)?"i":"");
 | "\n", (inv)?"i":"");
 | 
      
        |         fprintf(fstage,
 |         fprintf(fstage,
 | 
      
        | "\tbutterfly #(.IWIDTH(IWIDTH),.CWIDTH(CWIDTH),.OWIDTH(OWIDTH),\n"
 | "\tbutterfly #(.IWIDTH(IWIDTH),.CWIDTH(CWIDTH),.OWIDTH(OWIDTH),\n"
 | 
      
        | "\t\t\t.MPYDELAY(%d\'d%d),.LGDELAY(LGBDLY),.SHIFT(BFLYSHIFT))\n"
 | "\t\t\t.MPYDELAY(%d\'d%d),.LGDELAY(LGBDLY),.SHIFT(BFLYSHIFT))\n"
 | 
      
        | "\t\tbfly(i_clk, i_rst, (b_ce&i_ce), ib_c,\n"
 | "\t\tbfly(i_clk, i_rst, i_ce, ib_c,\n"
 | 
      
        | "\t\t\tib_a, ib_b, ib_sync, ob_a, ob_b, ob_sync);\n"
 | "\t\t\tib_a, ib_b, ib_sync, ob_a, ob_b, ob_sync);\n"
 | 
      
        | "endmodule;\n",
 | "endmodule;\n",
 | 
      
        |         lgdelay(nbits, xtra), (1<xtra)?(nbits+4):(nbits+xtra+3));
 |         lgdelay(nbits, xtra), (1<xtra)?(nbits+4):(nbits+xtra+3));
 | 
      
        | }
 | }
 | 
      
        |  
 |  
 |