data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v
1: b'%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:77: Cannot find file containing module: \'decoder_3_8\'\n   decoder_3_8 dec(.sel(which_buf),.res(sel_a));\n   ^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/447976230/fpga/usrp2/fifo,data/full_repos/permissive/447976230/decoder_3_8\n             data/full_repos/permissive/447976230/fpga/usrp2/fifo,data/full_repos/permissive/447976230/decoder_3_8.v\n             data/full_repos/permissive/447976230/fpga/usrp2/fifo,data/full_repos/permissive/447976230/decoder_3_8.sv\n             decoder_3_8\n             decoder_3_8.v\n             decoder_3_8.sv\n             obj_dir/decoder_3_8\n             obj_dir/decoder_3_8.v\n             obj_dir/decoder_3_8.sv\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:111: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s0 = buf_addrb[0];\n               ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:112: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s1 = buf_addrb[1];\n               ^\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:113: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s2 = buf_addrb[2];\n               ^\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:114: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s3 = buf_addrb[3];\n               ^\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:115: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s4 = buf_addrb[4];\n               ^\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:116: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s5 = buf_addrb[5];\n               ^\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:117: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s6 = buf_addrb[6];\n               ^\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:118: Operator ASSIGNW expects 32 bits on the Assign RHS, but Assign RHS\'s ARRAYSEL generates 9 bits.\n                                                                                      : ... In instance buffer_pool\n   assign   s7 = buf_addrb[7];\n               ^\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:121: Cannot find file containing module: \'setting_reg\'\n   setting_reg #(.my_addr(SET_ADDR)) \n   ^~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:132: Operator EQ expects 32 bits on the LHS, but LHS\'s SEL generates 4 bits.\n                                                                                      : ... In instance buffer_pool\n  if(go & (fifo_ctrl[31:28]==k))\n                           ^~\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:141: Operator EQ expects 32 bits on the LHS, but LHS\'s SEL generates 3 bits.\n                                                                                      : ... In instance buffer_pool\n  if(go & fifo_ctrl[22] & (fifo_ctrl[27:25]==k))\n                                           ^~\n%Warning-WIDTH: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:150: Operator EQ expects 32 bits on the LHS, but LHS\'s SEL generates 3 bits.\n                                                                                      : ... In instance buffer_pool\n  if(go & fifo_ctrl[23] & (fifo_ctrl[27:25]==k))\n                                           ^~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:156: Cannot find file containing module: \'RAMB16_S36_S36\'\n    RAMB16_S36_S36 dpram\n    ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:171: Cannot find file containing module: \'buffer_int\'\n    buffer_int #(.BUF_NUM(i),.BUF_SIZE(BUF_SIZE)) buffer_int\n    ^~~~~~~~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:188: Cannot find file containing module: \'mux4\'\n    mux4 #(.WIDTH(37))\n    ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:195: Cannot find file containing module: \'mux4\'\n    mux4 #(.WIDTH(1))\n    ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:226: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(1)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:232: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(1)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:238: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(1)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:244: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(1)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:250: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(37)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:262: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(37)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:274: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(37)) \n   ^~~~\n%Error: data/full_repos/permissive/447976230/fpga/usrp2/fifo/buffer_pool.v:286: Cannot find file containing module: \'mux8\'\n   mux8 #(.WIDTH(37)) \n   ^~~~\n%Error: Exiting due to 14 error(s), 11 warning(s)\n'
module buffer_pool
  #(parameter BUF_SIZE = 9,
    parameter SET_ADDR = 64)
    (input wb_clk_i,
     input wb_rst_i,
     input wb_we_i,
     input wb_stb_i,
     input [15:0] wb_adr_i,
     input [31:0] wb_dat_i,   
     output [31:0] wb_dat_o,
     output reg wb_ack_o,
     output wb_err_o,
     output wb_rty_o,
   
     input stream_clk,
     input stream_rst,
     
     input set_stb, input [7:0] set_addr, input [31:0] set_data,
     output [31:0] status,
     output sys_int_o,
     
     output [31:0] s0, output [31:0] s1, output [31:0] s2, output [31:0] s3,
     output [31:0] s4, output [31:0] s5, output [31:0] s6, output [31:0] s7,
     

     input [31:0] wr0_data_i, input [3:0] wr0_flags_i, input wr0_ready_i, output wr0_ready_o,
     input [31:0] wr1_data_i, input [3:0] wr1_flags_i, input wr1_ready_i, output wr1_ready_o,
     input [31:0] wr2_data_i, input [3:0] wr2_flags_i, input wr2_ready_i, output wr2_ready_o,
     input [31:0] wr3_data_i, input [3:0] wr3_flags_i, input wr3_ready_i, output wr3_ready_o,
     

     output [31:0] rd0_data_o, output [3:0] rd0_flags_o, output rd0_ready_o, input rd0_ready_i, 
     output [31:0] rd1_data_o, output [3:0] rd1_flags_o, output rd1_ready_o, input rd1_ready_i, 
     output [31:0] rd2_data_o, output [3:0] rd2_flags_o, output rd2_ready_o, input rd2_ready_i, 
     output [31:0] rd3_data_o, output [3:0] rd3_flags_o, output rd3_ready_o, input rd3_ready_i
     );
   
   wire [7:0] 	   sel_a;
   
   wire [BUF_SIZE-1:0] 	   buf_addra = wb_adr_i[BUF_SIZE+1:2];
   wire [2:0] 		   which_buf = wb_adr_i[BUF_SIZE+4:BUF_SIZE+2];
   
   decoder_3_8 dec(.sel(which_buf),.res(sel_a));
   
   genvar 	 i;
   
   wire 	 go;

   reg [2:0] 	 port[0:7];	 
   reg [3:0] 	 read_src[0:3];
   reg [3:0] 	 write_src[0:3];
   
   wire [7:0] 	 done;
   wire [7:0] 	 error;
   wire [7:0] 	 idle;
   
   wire [31:0] 	 buf_doa[0:7];
   
   wire [7:0] 	 buf_enb;
   wire [7:0] 	 buf_web;
   wire [BUF_SIZE-1:0] 	 buf_addrb[0:7];
   wire [31:0] 	 buf_dib[0:7];
   wire [31:0] 	 buf_dob[0:7];
   
   wire [31:0] 	 wr_data_i[0:7];
   wire [3:0] 	 wr_flags_i[0:7];
   wire [7:0] 	 wr_ready_i;
   wire [7:0] 	 wr_ready_o;
   
   wire [31:0] 	 rd_data_o[0:7];
   wire [3:0] 	 rd_flags_o[0:7];
   wire [7:0] 	 rd_ready_o;
   wire [7:0] 	 rd_ready_i;
   
   assign 	 status = {8'd0,idle[7:0],error[7:0],done[7:0]};

   assign 	 s0 = buf_addrb[0];
   assign 	 s1 = buf_addrb[1];
   assign 	 s2 = buf_addrb[2];
   assign 	 s3 = buf_addrb[3];
   assign 	 s4 = buf_addrb[4];
   assign 	 s5 = buf_addrb[5];
   assign 	 s6 = buf_addrb[6];
   assign 	 s7 = buf_addrb[7];
   
   wire [31:0] 	 fifo_ctrl;
   setting_reg #(.my_addr(SET_ADDR)) 
     sreg(.clk(stream_clk),.rst(stream_rst),.strobe(set_stb),.addr(set_addr),.in(set_data),
	  .out(fifo_ctrl),.changed(go));

   integer 	 k;
   always @(posedge stream_clk)
     if(stream_rst)
       for(k=0;k<8;k=k+1)
	 port[k] <= 4;
     else
       for(k=0;k<8;k=k+1)
	 if(go & (fifo_ctrl[31:28]==k))
	   port[k] <= fifo_ctrl[27:25];

   always @(posedge stream_clk)
     if(stream_rst)
       for(k=0;k<4;k=k+1)
	 read_src[k] <= 8;
     else
       for(k=0;k<4;k=k+1)
	 if(go & fifo_ctrl[22] & (fifo_ctrl[27:25]==k))
	   read_src[k] <= fifo_ctrl[31:28];
   
   always @(posedge stream_clk)
     if(stream_rst)
       for(k=0;k<4;k=k+1)
	 write_src[k] <= 8;
     else
       for(k=0;k<4;k=k+1)
	 if(go & fifo_ctrl[23] & (fifo_ctrl[27:25]==k))
	   write_src[k] <= fifo_ctrl[31:28];
   
   generate
      for(i=0;i<8;i=i+1)
	begin : gen_buffer
	   RAMB16_S36_S36 dpram
	     (.DOA(buf_doa[i]),.ADDRA(buf_addra),.CLKA(wb_clk_i),.DIA(wb_dat_i),.DIPA(4'h0),
	      .ENA(wb_stb_i & sel_a[i]),.SSRA(0),.WEA(wb_we_i),
	      .DOB(buf_dob[i]),.ADDRB(buf_addrb[i]),.CLKB(stream_clk),.DIB(buf_dib[i]),.DIPB(4'h0),
	      .ENB(buf_enb[i]),.SSRB(0),.WEB(buf_web[i]) );
	   

	   
	   buffer_int #(.BUF_NUM(i),.BUF_SIZE(BUF_SIZE)) buffer_int
	     (.clk(stream_clk),.rst(stream_rst),
	      .ctrl_word(fifo_ctrl),.go(go & (fifo_ctrl[31:28]==i)),
	      .done(done[i]),.error(error[i]),.idle(idle[i]),
	      .en_o(buf_enb[i]),
	      .we_o(buf_web[i]),
	      .addr_o(buf_addrb[i]),
	      .dat_to_buf(buf_dib[i]),
	      .dat_from_buf(buf_dob[i]),
	      .wr_data_i(wr_data_i[i]),
	      .wr_flags_i(wr_flags_i[i]),
	      .wr_ready_i(wr_ready_i[i]),
	      .wr_ready_o(wr_ready_o[i]),
	      .rd_data_o(rd_data_o[i]),
	      .rd_flags_o(rd_flags_o[i]),
	      .rd_ready_o(rd_ready_o[i]),
	      .rd_ready_i(rd_ready_i[i]) );
	   mux4 #(.WIDTH(37))
	     mux4_wr (.en(~port[i][2]),.sel(port[i][1:0]),
		      .i0({wr0_data_i,wr0_flags_i,wr0_ready_i}),
		      .i1({wr1_data_i,wr1_flags_i,wr1_ready_i}),
		      .i2({wr2_data_i,wr2_flags_i,wr2_ready_i}),
		      .i3({wr3_data_i,wr3_flags_i,wr3_ready_i}),
		      .o({wr_data_i[i],wr_flags_i[i],wr_ready_i[i]}) );
	   mux4 #(.WIDTH(1))
	     mux4_rd (.en(~port[i][2]),.sel(port[i][1:0]),
		      .i0(rd0_ready_i),.i1(rd1_ready_i),.i2(rd2_ready_i),.i3(rd3_ready_i),
		      .o(rd_ready_i[i]));
	end
   endgenerate






   assign wb_err_o = 1'b0;
   assign wb_rty_o = 1'b0;
   
   always @(posedge wb_clk_i)
     wb_ack_o <= wb_stb_i & ~wb_ack_o;
   assign wb_dat_o = buf_doa[which_buf];












   
   mux8 #(.WIDTH(1)) 
     mux8_wr0(.en(~write_src[0][3]),.sel(write_src[0][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr0_ready_o));

   mux8 #(.WIDTH(1)) 
     mux8_wr1(.en(~write_src[1][3]),.sel(write_src[1][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr1_ready_o));

   mux8 #(.WIDTH(1)) 
     mux8_wr2(.en(~write_src[2][3]),.sel(write_src[2][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr2_ready_o));

   mux8 #(.WIDTH(1)) 
     mux8_wr3(.en(~write_src[3][3]),.sel(write_src[3][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr3_ready_o));

   mux8 #(.WIDTH(37)) 
     mux8_rd0(.en(~read_src[0][3]),.sel(read_src[0][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd0_data_o,rd0_flags_o,rd0_ready_o}));
   
   mux8 #(.WIDTH(37)) 
     mux8_rd1(.en(~read_src[1][3]),.sel(read_src[1][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd1_data_o,rd1_flags_o,rd1_ready_o}));
   
   mux8 #(.WIDTH(37)) 
     mux8_rd2(.en(~read_src[2][3]),.sel(read_src[2][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd2_data_o,rd2_flags_o,rd2_ready_o}));
   
   mux8 #(.WIDTH(37)) 
     mux8_rd3(.en(~read_src[3][3]),.sel(read_src[3][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd3_data_o,rd3_flags_o,rd3_ready_o}));
   
   assign sys_int_o = (|error) | (|done);
   
endmodule
module buffer_pool
  #(parameter BUF_SIZE = 9,
    parameter SET_ADDR = 64)
    (input wb_clk_i,
     input wb_rst_i,
     input wb_we_i,
     input wb_stb_i,
     input [15:0] wb_adr_i,
     input [31:0] wb_dat_i,   
     output [31:0] wb_dat_o,
     output reg wb_ack_o,
     output wb_err_o,
     output wb_rty_o,
   
     input stream_clk,
     input stream_rst,
     
     input set_stb, input [7:0] set_addr, input [31:0] set_data,
     output [31:0] status,
     output sys_int_o,
     
     output [31:0] s0, output [31:0] s1, output [31:0] s2, output [31:0] s3,
     output [31:0] s4, output [31:0] s5, output [31:0] s6, output [31:0] s7,
     

     input [31:0] wr0_data_i, input [3:0] wr0_flags_i, input wr0_ready_i, output wr0_ready_o,
     input [31:0] wr1_data_i, input [3:0] wr1_flags_i, input wr1_ready_i, output wr1_ready_o,
     input [31:0] wr2_data_i, input [3:0] wr2_flags_i, input wr2_ready_i, output wr2_ready_o,
     input [31:0] wr3_data_i, input [3:0] wr3_flags_i, input wr3_ready_i, output wr3_ready_o,
     

     output [31:0] rd0_data_o, output [3:0] rd0_flags_o, output rd0_ready_o, input rd0_ready_i, 
     output [31:0] rd1_data_o, output [3:0] rd1_flags_o, output rd1_ready_o, input rd1_ready_i, 
     output [31:0] rd2_data_o, output [3:0] rd2_flags_o, output rd2_ready_o, input rd2_ready_i, 
     output [31:0] rd3_data_o, output [3:0] rd3_flags_o, output rd3_ready_o, input rd3_ready_i
     );

   
   wire [7:0] 	   sel_a;
   
   wire [BUF_SIZE-1:0] 	   buf_addra = wb_adr_i[BUF_SIZE+1:2];
   wire [2:0] 		   which_buf = wb_adr_i[BUF_SIZE+4:BUF_SIZE+2];
   
   decoder_3_8 dec(.sel(which_buf),.res(sel_a));
   
   genvar 	 i;
   
   wire 	 go;

   reg [2:0] 	 port[0:7];	 
   reg [3:0] 	 read_src[0:3];
   reg [3:0] 	 write_src[0:3];
   
   wire [7:0] 	 done;
   wire [7:0] 	 error;
   wire [7:0] 	 idle;
   
   wire [31:0] 	 buf_doa[0:7];
   
   wire [7:0] 	 buf_enb;
   wire [7:0] 	 buf_web;
   wire [BUF_SIZE-1:0] 	 buf_addrb[0:7];
   wire [31:0] 	 buf_dib[0:7];
   wire [31:0] 	 buf_dob[0:7];
   
   wire [31:0] 	 wr_data_i[0:7];
   wire [3:0] 	 wr_flags_i[0:7];
   wire [7:0] 	 wr_ready_i;
   wire [7:0] 	 wr_ready_o;
   
   wire [31:0] 	 rd_data_o[0:7];
   wire [3:0] 	 rd_flags_o[0:7];
   wire [7:0] 	 rd_ready_o;
   wire [7:0] 	 rd_ready_i;
   
   assign 	 status = {8'd0,idle[7:0],error[7:0],done[7:0]};

   assign 	 s0 = buf_addrb[0];
   assign 	 s1 = buf_addrb[1];
   assign 	 s2 = buf_addrb[2];
   assign 	 s3 = buf_addrb[3];
   assign 	 s4 = buf_addrb[4];
   assign 	 s5 = buf_addrb[5];
   assign 	 s6 = buf_addrb[6];
   assign 	 s7 = buf_addrb[7];
   
   wire [31:0] 	 fifo_ctrl;
   setting_reg #(.my_addr(SET_ADDR)) 
     sreg(.clk(stream_clk),.rst(stream_rst),.strobe(set_stb),.addr(set_addr),.in(set_data),
	  .out(fifo_ctrl),.changed(go));

   integer 	 k;
   always @(posedge stream_clk)
     if(stream_rst)
       for(k=0;k<8;k=k+1)
	 port[k] <= 4;
     else
       for(k=0;k<8;k=k+1)
	 if(go & (fifo_ctrl[31:28]==k))
	   port[k] <= fifo_ctrl[27:25];

   always @(posedge stream_clk)
     if(stream_rst)
       for(k=0;k<4;k=k+1)
	 read_src[k] <= 8;
     else
       for(k=0;k<4;k=k+1)
	 if(go & fifo_ctrl[22] & (fifo_ctrl[27:25]==k))
	   read_src[k] <= fifo_ctrl[31:28];
   
   always @(posedge stream_clk)
     if(stream_rst)
       for(k=0;k<4;k=k+1)
	 write_src[k] <= 8;
     else
       for(k=0;k<4;k=k+1)
	 if(go & fifo_ctrl[23] & (fifo_ctrl[27:25]==k))
	   write_src[k] <= fifo_ctrl[31:28];
   
   generate
      for(i=0;i<8;i=i+1)
	begin : gen_buffer
	   RAMB16_S36_S36 dpram
	     (.DOA(buf_doa[i]),.ADDRA(buf_addra),.CLKA(wb_clk_i),.DIA(wb_dat_i),.DIPA(4'h0),
	      .ENA(wb_stb_i & sel_a[i]),.SSRA(0),.WEA(wb_we_i),
	      .DOB(buf_dob[i]),.ADDRB(buf_addrb[i]),.CLKB(stream_clk),.DIB(buf_dib[i]),.DIPB(4'h0),
	      .ENB(buf_enb[i]),.SSRB(0),.WEB(buf_web[i]) );
	   

	   
	   buffer_int #(.BUF_NUM(i),.BUF_SIZE(BUF_SIZE)) buffer_int
	     (.clk(stream_clk),.rst(stream_rst),
	      .ctrl_word(fifo_ctrl),.go(go & (fifo_ctrl[31:28]==i)),
	      .done(done[i]),.error(error[i]),.idle(idle[i]),
	      .en_o(buf_enb[i]),
	      .we_o(buf_web[i]),
	      .addr_o(buf_addrb[i]),
	      .dat_to_buf(buf_dib[i]),
	      .dat_from_buf(buf_dob[i]),
	      .wr_data_i(wr_data_i[i]),
	      .wr_flags_i(wr_flags_i[i]),
	      .wr_ready_i(wr_ready_i[i]),
	      .wr_ready_o(wr_ready_o[i]),
	      .rd_data_o(rd_data_o[i]),
	      .rd_flags_o(rd_flags_o[i]),
	      .rd_ready_o(rd_ready_o[i]),
	      .rd_ready_i(rd_ready_i[i]) );
	   mux4 #(.WIDTH(37))
	     mux4_wr (.en(~port[i][2]),.sel(port[i][1:0]),
		      .i0({wr0_data_i,wr0_flags_i,wr0_ready_i}),
		      .i1({wr1_data_i,wr1_flags_i,wr1_ready_i}),
		      .i2({wr2_data_i,wr2_flags_i,wr2_ready_i}),
		      .i3({wr3_data_i,wr3_flags_i,wr3_ready_i}),
		      .o({wr_data_i[i],wr_flags_i[i],wr_ready_i[i]}) );
	   mux4 #(.WIDTH(1))
	     mux4_rd (.en(~port[i][2]),.sel(port[i][1:0]),
		      .i0(rd0_ready_i),.i1(rd1_ready_i),.i2(rd2_ready_i),.i3(rd3_ready_i),
		      .o(rd_ready_i[i]));
	end
   endgenerate






   assign wb_err_o = 1'b0;
   assign wb_rty_o = 1'b0;
   
   always @(posedge wb_clk_i)
     wb_ack_o <= wb_stb_i & ~wb_ack_o;
   assign wb_dat_o = buf_doa[which_buf];












   
   mux8 #(.WIDTH(1)) 
     mux8_wr0(.en(~write_src[0][3]),.sel(write_src[0][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr0_ready_o));

   mux8 #(.WIDTH(1)) 
     mux8_wr1(.en(~write_src[1][3]),.sel(write_src[1][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr1_ready_o));

   mux8 #(.WIDTH(1)) 
     mux8_wr2(.en(~write_src[2][3]),.sel(write_src[2][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr2_ready_o));

   mux8 #(.WIDTH(1)) 
     mux8_wr3(.en(~write_src[3][3]),.sel(write_src[3][2:0]), 
	      .i0(wr_ready_o[0]), .i1(wr_ready_o[1]), .i2(wr_ready_o[2]), .i3(wr_ready_o[3]),
	      .i4(wr_ready_o[4]), .i5(wr_ready_o[5]), .i6(wr_ready_o[6]), .i7(wr_ready_o[7]),
	      .o(wr3_ready_o));

   mux8 #(.WIDTH(37)) 
     mux8_rd0(.en(~read_src[0][3]),.sel(read_src[0][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd0_data_o,rd0_flags_o,rd0_ready_o}));
   
   mux8 #(.WIDTH(37)) 
     mux8_rd1(.en(~read_src[1][3]),.sel(read_src[1][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd1_data_o,rd1_flags_o,rd1_ready_o}));
   
   mux8 #(.WIDTH(37)) 
     mux8_rd2(.en(~read_src[2][3]),.sel(read_src[2][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd2_data_o,rd2_flags_o,rd2_ready_o}));
   
   mux8 #(.WIDTH(37)) 
     mux8_rd3(.en(~read_src[3][3]),.sel(read_src[3][2:0]), 
	      .i0({rd_data_o[0],rd_flags_o[0],rd_ready_o[0]}),
	      .i1({rd_data_o[1],rd_flags_o[1],rd_ready_o[1]}),
	      .i2({rd_data_o[2],rd_flags_o[2],rd_ready_o[2]}),
	      .i3({rd_data_o[3],rd_flags_o[3],rd_ready_o[3]}),
	      .i4({rd_data_o[4],rd_flags_o[4],rd_ready_o[4]}),
	      .i5({rd_data_o[5],rd_flags_o[5],rd_ready_o[5]}),
	      .i6({rd_data_o[6],rd_flags_o[6],rd_ready_o[6]}),
	      .i7({rd_data_o[7],rd_flags_o[7],rd_ready_o[7]}),
	      .o({rd3_data_o,rd3_flags_o,rd3_ready_o}));
   
   assign sys_int_o = (|error) | (|done);
   
endmodule