assign eq = in1_d == in2_d;
assign cout = sum[`WORDWIDTH];
+ reg out_draining;
+
assign out_d_[`WORDWIDTH] =
(inOp_d_trunc==0) ? 1'b0 :
(inOp_d_trunc==1) ? 1'b0 :
always @(posedge clk) begin
if (!rst) begin
`reset
+ out_draining <= 0;
end else begin
`flush
`cleanup
- if (`out_draining) begin
+ if (out_draining && `out_empty) begin
`drain_inOp
+ out_draining <= 0;
if (inOp_d_trunc==0) `drain_in1
else if (inOp_d_trunc==1) `drain_in2
else if (inOp_d_trunc==9 && both_negative) begin `drain_in1 `drain_in2 end
`drain_in2
end
end
- if (`out_empty && `in1_full && `in2_full && `inOp_full) begin
+ if (!out_draining && `out_empty && `in1_full && `in2_full && `inOp_full) begin
`fill_out
+ out_draining <= 1;
end
end
end
reg [`WORDWIDTH-1:0] temp;
initial temp = {`WORDWIDTH{1'b1}};
+ reg out_draining;
reg full;
initial full = 0;
wire op_count; assign op_count = inOp_d_trunc==12;
if (!rst) begin
`reset
full <= 0;
+ out_draining <= 0;
end else begin
`flush
`cleanup
if (`inOp_empty) full <= 0;
- if (`out_draining) begin
+ if (out_draining && `out_empty) begin
if (op_count) temp <= temp - in2_d;
else temp <= temp - 1;
if (op_pass && op_v1) `drain_in1
if (op_pass && op_v2) `drain_in2
+ out_draining <= 0;
end else if (`inOp_full) begin
if (!full) begin
if (op_count && `in1_full && `in2_full) begin
end else if (`out_empty) begin
if (op_count) begin
`fill_out
+ out_draining <= 1;
end else if (op_v1 && `in1_full) begin
if (op_drop) begin `drain_in1 temp <= temp-1; end
- else `fill_out
+ else begin `fill_out out_draining <= 1; end
end else if (op_v2 && `in2_full) begin
if (op_drop) begin `drain_in2 temp <= temp-1; end
- else `fill_out
+ else begin `fill_out out_draining <= 1; end
end
end
end
== FleetSim ==============================================================
== FPGA ==============================================================
+ reg out_draining;
wire [7:0] lut;
genvar i;
always @(posedge clk) begin
if (!rst) begin
`reset
+ out_draining <= 0;
end else begin
`flush
`cleanup
- if (`out_draining) begin
+ if (out_draining && `out_empty) begin
`drain_in1
`drain_in2
`drain_in3
`drain_inLut
+ out_draining <= 0;
end
- if (`in1_full && `in2_full && `in3_full && `inLut_full && `out_empty) begin
+ if (!out_draining && `in1_full && `in2_full && `in3_full && `inLut_full && `out_empty) begin
`fill_out
+ out_draining <= 1;
end
end
end