X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ships%2FMemory.ship;h=416d070f03ab605d62469c918556718e680337be;hb=cd90afdfa51793f9859a3ba67b2c57ebd1edf5a0;hp=7245737bf39714a488c57696994a1b3c6937a5af;hpb=11df380a69fbab49049ac267c9099a01d3370e4a;p=fleet.git diff --git a/ships/Memory.ship b/ships/Memory.ship index 7245737..416d070 100644 --- a/ships/Memory.ship +++ b/ships/Memory.ship @@ -161,23 +161,42 @@ sequence guarantee problem mentioned in the previous paragraph. == FPGA ============================================================== + reg write_flag; + reg [(`BRAM_ADDR_WIDTH-1):0] cursor; + wire [(`BRAM_ADDR_WIDTH-1):0] addr1; + + // bram ////////////////////////////////////////////////////////////////////////////// +`define BRAM_ADDR_WIDTH 14 +`define BRAM_SIZE (1<<(`BRAM_ADDR_WIDTH)) + + reg [(`WORDWIDTH-1):0] ram [((`BRAM_SIZE)-1):0]; + reg [(`BRAM_ADDR_WIDTH-1):0] read_a; + reg [(`BRAM_ADDR_WIDTH-1):0] read_dpra; + always @(posedge clk) begin + if (write_flag) + ram[addr1] <= inDataWrite_d; + read_a <= addr1; + read_dpra <= cursor; + end + + //////////////////////////////////////////////////////////////////////////////// + wire [(`WORDWIDTH-1):0] out1; wire [(`WORDWIDTH-1):0] out2; + assign out1 = ram[read_a]; + assign out2 = ram[read_dpra]; + reg [(`CODEBAG_SIZE_BITS-1):0] counter; - reg [(`BRAM_ADDR_WIDTH-1):0] cursor; initial cursor = 0; initial counter = 0; - reg write_flag; reg out_w; reg dispatching_cbd; initial write_flag = 0; initial dispatching_cbd = 0; - wire [(`BRAM_ADDR_WIDTH-1):0] addr1; assign addr1 = write_flag ? inAddrWrite_d[(`WORDWIDTH-1):0] : inAddrRead_d[(`WORDWIDTH-1):0]; - bram14 mybram(clk, rst, write_flag, addr1, cursor, inDataWrite_d, out1, out2); assign out_d_ = { out_w , (dispatching_cbd ? out2 : out1) }; @@ -205,6 +224,7 @@ sequence guarantee problem mentioned in the previous paragraph. end `fill_out out_w <= 0; + end else if (`inCBD_full && `out_draining) begin if (counter != inCBD_d[(`CODEBAG_SIZE_BITS-1):0]) begin cursor <= cursor + 1; @@ -214,9 +234,11 @@ sequence guarantee problem mentioned in the previous paragraph. counter <= 0; dispatching_cbd <= 0; end + end else if (!dispatching_cbd && `out_empty && `inAddrRead_full) begin `drain_inAddrRead `fill_out + out_w <= 0; end else if (!dispatching_cbd && `out_empty && `inAddrWrite_full && `inDataWrite_full) begin // timing note: it's okay to drain here because *_d will still