driver basic test and demo test refactoring
This commit is contained in:
@@ -17,112 +17,105 @@ module VX_divide #(
|
||||
output reg [WIDTHD-1:0] remainder
|
||||
);
|
||||
|
||||
// synthesis read_comments_as_HDL on
|
||||
// localparam IMPL = "quartus";
|
||||
// synthesis read_comments_as_HDL off
|
||||
|
||||
// altera translate_off
|
||||
localparam IMPL="fallback";
|
||||
// altera translate_on
|
||||
|
||||
generate
|
||||
|
||||
if (NREP != DREP) begin
|
||||
different_nrep_drep_not_yet_supported non_existing_module();
|
||||
end
|
||||
|
||||
if (IMPL == "quartus") begin
|
||||
`ifdef QUARTUS
|
||||
|
||||
localparam lpm_speed=SPEED == "HIGHEST" ? 9:5;
|
||||
localparam lpm_speed=SPEED == "HIGHEST" ? 9 : 5;
|
||||
|
||||
lpm_divide #(
|
||||
.LPM_WIDTHN(WIDTHN),
|
||||
.LPM_WIDTHD(WIDTHD),
|
||||
.LPM_NREPRESENTATION(NREP),
|
||||
.LPM_DREPRESENTATION(DREP),
|
||||
.LPM_PIPELINE(PIPELINE),
|
||||
.LPM_REMAINDERPOSITIVE("FALSE"), // emulate verilog % operator
|
||||
.MAXIMIZE_SPEED(lpm_speed)
|
||||
) quartus_divider (
|
||||
.clock(clock),
|
||||
.aclr(aclr),
|
||||
.clken(clken),
|
||||
.numer(numer),
|
||||
.denom(denom),
|
||||
.quotient(quotient),
|
||||
.remain(remainder)
|
||||
);
|
||||
end
|
||||
else begin
|
||||
lpm_divide #(
|
||||
.LPM_WIDTHN(WIDTHN),
|
||||
.LPM_WIDTHD(WIDTHD),
|
||||
.LPM_NREPRESENTATION(NREP),
|
||||
.LPM_DREPRESENTATION(DREP),
|
||||
.LPM_PIPELINE(PIPELINE),
|
||||
.LPM_REMAINDERPOSITIVE("FALSE"), // emulate verilog % operator
|
||||
.MAXIMIZE_SPEED(lpm_speed)
|
||||
) quartus_divider (
|
||||
.clock(clock),
|
||||
.aclr(aclr),
|
||||
.clken(clken),
|
||||
.numer(numer),
|
||||
.denom(denom),
|
||||
.quotient(quotient),
|
||||
.remain(remainder)
|
||||
);
|
||||
|
||||
wire [WIDTHN-1:0] numer_pipe_end;
|
||||
wire [WIDTHD-1:0] denom_pipe_end;
|
||||
`else
|
||||
|
||||
if (PIPELINE == 0) begin
|
||||
assign numer_pipe_end = numer;
|
||||
assign denom_pipe_end = denom;
|
||||
end else begin
|
||||
reg [WIDTHN-1:0] numer_pipe [0:PIPELINE-1];
|
||||
reg [WIDTHD-1:0] denom_pipe [0:PIPELINE-1];
|
||||
wire [WIDTHN-1:0] numer_pipe_end;
|
||||
wire [WIDTHD-1:0] denom_pipe_end;
|
||||
|
||||
genvar i;
|
||||
for (i = 0; i < PIPELINE-1; i++) begin : pipe_stages
|
||||
always @(posedge clock or posedge aclr) begin
|
||||
if (aclr) begin
|
||||
numer_pipe[i+1] <= 0;
|
||||
denom_pipe[i+1] <= 0;
|
||||
end
|
||||
else if (clken) begin
|
||||
numer_pipe[i+1] <= numer_pipe[i];
|
||||
denom_pipe[i+1] <= denom_pipe[i];
|
||||
end
|
||||
end
|
||||
end
|
||||
if (PIPELINE == 0) begin
|
||||
assign numer_pipe_end = numer;
|
||||
assign denom_pipe_end = denom;
|
||||
end else begin
|
||||
reg [WIDTHN-1:0] numer_pipe [0:PIPELINE-1];
|
||||
reg [WIDTHD-1:0] denom_pipe [0:PIPELINE-1];
|
||||
|
||||
genvar i;
|
||||
for (i = 0; i < PIPELINE-1; i++) begin : pipe_stages
|
||||
always @(posedge clock or posedge aclr) begin
|
||||
if (aclr) begin
|
||||
numer_pipe[0] <= 0;
|
||||
denom_pipe[0] <= 0;
|
||||
numer_pipe[i+1] <= 0;
|
||||
denom_pipe[i+1] <= 0;
|
||||
end
|
||||
else if (clken) begin
|
||||
numer_pipe[0] <= numer;
|
||||
denom_pipe[0] <= denom;
|
||||
numer_pipe[i+1] <= numer_pipe[i];
|
||||
denom_pipe[i+1] <= denom_pipe[i];
|
||||
end
|
||||
end
|
||||
|
||||
assign numer_pipe_end = numer_pipe[PIPELINE-1];
|
||||
assign denom_pipe_end = denom_pipe[PIPELINE-1];
|
||||
end
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Do the actual fallback computation here */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
if (NREP == "SIGNED") begin
|
||||
|
||||
always @(*) begin
|
||||
if (denom_pipe_end == 0) begin
|
||||
quotient = 32'hffffffff;
|
||||
remainder = numer_pipe_end;
|
||||
end
|
||||
else if (denom_pipe_end == 32'hffffffff && numer_pipe_end == 32'h80000000) begin
|
||||
// this edge case kills verilator in some cases by causing a division
|
||||
// overflow exception. INT_MIN / -1 (on x86)
|
||||
quotient = 0;
|
||||
remainder = 0;
|
||||
end
|
||||
else begin
|
||||
quotient = $signed($signed(numer_pipe_end) / $signed(denom_pipe_end));
|
||||
remainder = $signed($signed(numer_pipe_end) % $signed(denom_pipe_end));
|
||||
end
|
||||
always @(posedge clock or posedge aclr) begin
|
||||
if (aclr) begin
|
||||
numer_pipe[0] <= 0;
|
||||
denom_pipe[0] <= 0;
|
||||
end
|
||||
else if (clken) begin
|
||||
numer_pipe[0] <= numer;
|
||||
denom_pipe[0] <= denom;
|
||||
end
|
||||
|
||||
end
|
||||
else begin
|
||||
assign quotient = (denom_pipe_end == 0) ? 32'hffffffff : numer_pipe_end/denom_pipe_end;
|
||||
assign remainder = (denom_pipe_end == 0) ? numer_pipe_end : numer_pipe_end%denom_pipe_end;
|
||||
end
|
||||
|
||||
assign numer_pipe_end = numer_pipe[PIPELINE-1];
|
||||
assign denom_pipe_end = denom_pipe[PIPELINE-1];
|
||||
end
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Do the actual fallback computation here */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
if (NREP == "SIGNED") begin
|
||||
always @(*) begin
|
||||
if (denom_pipe_end == 0) begin
|
||||
quotient = 32'hffffffff;
|
||||
remainder = numer_pipe_end;
|
||||
end
|
||||
else if (denom_pipe_end == 32'hffffffff
|
||||
&& numer_pipe_end == 32'h80000000) begin
|
||||
// this edge case kills verilator in some cases by causing a division
|
||||
// overflow exception. INT_MIN / -1 (on x86)
|
||||
quotient = 0;
|
||||
remainder = 0;
|
||||
end
|
||||
else begin
|
||||
quotient = $signed($signed(numer_pipe_end) / $signed(denom_pipe_end));
|
||||
remainder = $signed($signed(numer_pipe_end) % $signed(denom_pipe_end));
|
||||
end
|
||||
end
|
||||
end
|
||||
else begin
|
||||
assign quotient = (denom_pipe_end == 0) ? 32'hffffffff : numer_pipe_end/denom_pipe_end;
|
||||
assign remainder = (denom_pipe_end == 0) ? numer_pipe_end : numer_pipe_end%denom_pipe_end;
|
||||
end
|
||||
|
||||
`endif
|
||||
|
||||
endgenerate
|
||||
|
||||
endmodule : VX_divide
|
||||
|
||||
@@ -2,21 +2,17 @@
|
||||
|
||||
module VX_generic_priority_encoder #(
|
||||
parameter N = 1
|
||||
) (
|
||||
input wire[N-1:0] valids,
|
||||
//output reg[$clog2(N)-1:0] index,
|
||||
output reg[(`LOG2UP(N))-1:0] index,
|
||||
//output reg[`LOG2UP(N):0] index, // eh
|
||||
output reg found
|
||||
);
|
||||
|
||||
) (
|
||||
input wire[N-1:0] valids,
|
||||
output reg[(`LOG2UP(N))-1:0] index,
|
||||
output reg found
|
||||
);
|
||||
integer i;
|
||||
always @(*) begin
|
||||
index = 0;
|
||||
found = 0;
|
||||
for (i = N-1; i >= 0; i = i - 1) begin
|
||||
if (valids[i]) begin
|
||||
//index = i[$clog2(N)-1:0];
|
||||
index = i[(`LOG2UP(N))-1:0];
|
||||
found = 1;
|
||||
end
|
||||
|
||||
@@ -132,7 +132,7 @@ module VX_generic_queue #(
|
||||
rd_ptr_r <= rd_ptr_next_r;
|
||||
|
||||
if (SIZE > 2) begin
|
||||
rd_ptr_next_r <= rd_ptr_r + 2;
|
||||
rd_ptr_next_r <= rd_ptr_r + $bits(rd_ptr_r)'(2);
|
||||
end else begin // (SIZE == 2);
|
||||
rd_ptr_next_r <= ~rd_ptr_next_r;
|
||||
end
|
||||
|
||||
@@ -19,110 +19,102 @@ module VX_mult #(
|
||||
output reg [WIDTHP-1:0] result
|
||||
);
|
||||
|
||||
// synthesis read_comments_as_HDL on
|
||||
// localparam IMPL = "quartus";
|
||||
// synthesis read_comments_as_HDL off
|
||||
|
||||
// altera translate_off
|
||||
localparam IMPL="fallback";
|
||||
// altera translate_on
|
||||
|
||||
generate
|
||||
|
||||
if (IMPL == "quartus") begin
|
||||
`ifdef QUARTUS
|
||||
|
||||
localparam lpm_speed = (SPEED == "HIGHEST") ? 10 : 5;
|
||||
|
||||
if (FORCE_LE == "YES") begin
|
||||
lpm_mult #(
|
||||
.LPM_WIDTHA(WIDTHA),
|
||||
.LPM_WIDTHB(WIDTHB),
|
||||
.LPM_WIDTHP(WIDTHP),
|
||||
.LPM_REPRESENTATION(REP),
|
||||
.LPM_PIPELINE(PIPELINE),
|
||||
.DSP_BLOCK_BALANCING("LOGIC ELEMENTS"),
|
||||
.MAXIMIZE_SPEED(lpm_speed)
|
||||
) quartus_mult (
|
||||
.clock(clock),
|
||||
.aclr(aclr),
|
||||
.clken(clken),
|
||||
.dataa(dataa),
|
||||
.datab(datab),
|
||||
.result(result)
|
||||
);
|
||||
end
|
||||
else begin
|
||||
lpm_mult#(
|
||||
.LPM_WIDTHA(WIDTHA),
|
||||
.LPM_WIDTHB(WIDTHB),
|
||||
.LPM_WIDTHP(WIDTHP),
|
||||
.LPM_REPRESENTATION(REP),
|
||||
.LPM_PIPELINE(PIPELINE),
|
||||
.MAXIMIZE_SPEED(lpm_speed)
|
||||
) quartus_mult(
|
||||
.clock(clock),
|
||||
.aclr(aclr),
|
||||
.clken(clken),
|
||||
.dataa(dataa),
|
||||
.datab(datab),
|
||||
.result(result)
|
||||
);
|
||||
end
|
||||
localparam lpm_speed = (SPEED == "HIGHEST") ? 10 : 5;
|
||||
|
||||
if (FORCE_LE == "YES") begin
|
||||
lpm_mult #(
|
||||
.LPM_WIDTHA(WIDTHA),
|
||||
.LPM_WIDTHB(WIDTHB),
|
||||
.LPM_WIDTHP(WIDTHP),
|
||||
.LPM_REPRESENTATION(REP),
|
||||
.LPM_PIPELINE(PIPELINE),
|
||||
.DSP_BLOCK_BALANCING("LOGIC ELEMENTS"),
|
||||
.MAXIMIZE_SPEED(lpm_speed)
|
||||
) quartus_mult (
|
||||
.clock(clock),
|
||||
.aclr(aclr),
|
||||
.clken(clken),
|
||||
.dataa(dataa),
|
||||
.datab(datab),
|
||||
.result(result)
|
||||
);
|
||||
end
|
||||
else begin
|
||||
lpm_mult#(
|
||||
.LPM_WIDTHA(WIDTHA),
|
||||
.LPM_WIDTHB(WIDTHB),
|
||||
.LPM_WIDTHP(WIDTHP),
|
||||
.LPM_REPRESENTATION(REP),
|
||||
.LPM_PIPELINE(PIPELINE),
|
||||
.MAXIMIZE_SPEED(lpm_speed)
|
||||
) quartus_mult(
|
||||
.clock(clock),
|
||||
.aclr(aclr),
|
||||
.clken(clken),
|
||||
.dataa(dataa),
|
||||
.datab(datab),
|
||||
.result(result)
|
||||
);
|
||||
end
|
||||
|
||||
wire [WIDTHA-1:0] dataa_pipe_end;
|
||||
wire [WIDTHB-1:0] datab_pipe_end;
|
||||
`else
|
||||
|
||||
wire [WIDTHA-1:0] dataa_pipe_end;
|
||||
wire [WIDTHB-1:0] datab_pipe_end;
|
||||
|
||||
if (PIPELINE == 0) begin
|
||||
assign dataa_pipe_end = dataa;
|
||||
assign datab_pipe_end = datab;
|
||||
end else begin
|
||||
reg [WIDTHA-1:0] dataa_pipe [0:PIPELINE-1];
|
||||
reg [WIDTHB-1:0] datab_pipe [0:PIPELINE-1];
|
||||
|
||||
genvar i;
|
||||
for (i = 0; i < PIPELINE-1; i++) begin : pipe_stages
|
||||
always @(posedge clock or posedge aclr) begin
|
||||
if (aclr) begin
|
||||
dataa_pipe[i+1] <= 0;
|
||||
datab_pipe[i+1] <= 0;
|
||||
end
|
||||
else if (clken) begin
|
||||
dataa_pipe[i+1] <= dataa_pipe[i];
|
||||
datab_pipe[i+1] <= datab_pipe[i];
|
||||
end
|
||||
end
|
||||
end
|
||||
if (PIPELINE == 0) begin
|
||||
assign dataa_pipe_end = dataa;
|
||||
assign datab_pipe_end = datab;
|
||||
end else begin
|
||||
reg [WIDTHA-1:0] dataa_pipe [0:PIPELINE-1];
|
||||
reg [WIDTHB-1:0] datab_pipe [0:PIPELINE-1];
|
||||
|
||||
genvar i;
|
||||
for (i = 0; i < PIPELINE-1; i++) begin : pipe_stages
|
||||
always @(posedge clock or posedge aclr) begin
|
||||
if (aclr) begin
|
||||
dataa_pipe[0] <= 0;
|
||||
datab_pipe[0] <= 0;
|
||||
dataa_pipe[i+1] <= 0;
|
||||
datab_pipe[i+1] <= 0;
|
||||
end
|
||||
else if (clken) begin
|
||||
dataa_pipe[0] <= dataa;
|
||||
datab_pipe[0] <= datab;
|
||||
dataa_pipe[i+1] <= dataa_pipe[i];
|
||||
datab_pipe[i+1] <= datab_pipe[i];
|
||||
end
|
||||
end
|
||||
|
||||
assign dataa_pipe_end = dataa_pipe[PIPELINE-1];
|
||||
assign datab_pipe_end = datab_pipe[PIPELINE-1];
|
||||
end
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Do the actual fallback computation here */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
if (REP == "SIGNED") begin
|
||||
assign result = $signed($signed(dataa_pipe_end)*$signed(datab_pipe_end));
|
||||
end
|
||||
else begin
|
||||
assign result = dataa_pipe_end*datab_pipe_end;
|
||||
always @(posedge clock or posedge aclr) begin
|
||||
if (aclr) begin
|
||||
dataa_pipe[0] <= 0;
|
||||
datab_pipe[0] <= 0;
|
||||
end
|
||||
else if (clken) begin
|
||||
dataa_pipe[0] <= dataa;
|
||||
datab_pipe[0] <= datab;
|
||||
end
|
||||
end
|
||||
|
||||
assign dataa_pipe_end = dataa_pipe[PIPELINE-1];
|
||||
assign datab_pipe_end = datab_pipe[PIPELINE-1];
|
||||
end
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* Do the actual fallback computation here */
|
||||
/* * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
if (REP == "SIGNED") begin
|
||||
assign result = $signed($signed(dataa_pipe_end)*$signed(datab_pipe_end));
|
||||
end
|
||||
else begin
|
||||
assign result = dataa_pipe_end * datab_pipe_end;
|
||||
end
|
||||
|
||||
`endif
|
||||
|
||||
endgenerate
|
||||
|
||||
endmodule: VX_mult
|
||||
|
||||
@@ -18,26 +18,22 @@ module VX_scope #(
|
||||
input wire bus_write,
|
||||
input wire bus_read
|
||||
);
|
||||
localparam DELTA_ENABLE = (UPDW != 0);
|
||||
localparam MAX_DELTA = (2 ** DELTAW) - 1;
|
||||
localparam DELTA_ENABLE = (UPDW != 0);
|
||||
localparam MAX_DELTA = (2 ** DELTAW) - 1;
|
||||
|
||||
typedef enum logic[2:0] {
|
||||
CMD_GET_VALID,
|
||||
CMD_GET_DATA,
|
||||
CMD_GET_WIDTH,
|
||||
CMD_GET_COUNT,
|
||||
CMD_SET_DELAY,
|
||||
CMD_SET_STOP,
|
||||
CMD_RESERVED1,
|
||||
CMD_RESERVED2
|
||||
} cmd_t;
|
||||
localparam CMD_GET_VALID = 3'd0;
|
||||
localparam CMD_GET_DATA = 3'd1;
|
||||
localparam CMD_GET_WIDTH = 3'd2;
|
||||
localparam CMD_GET_COUNT = 3'd3;
|
||||
localparam CMD_SET_DELAY = 3'd4;
|
||||
localparam CMD_SET_STOP = 3'd5;
|
||||
localparam CMD_RESERVED1 = 3'd6;
|
||||
localparam CMD_RESERVED2 = 3'd7;
|
||||
|
||||
typedef enum logic[1:0] {
|
||||
GET_VALID,
|
||||
GET_DATA,
|
||||
GET_WIDTH,
|
||||
GET_COUNT
|
||||
} cmd_get_t;
|
||||
localparam GET_VALID = 2'd0;
|
||||
localparam GET_DATA = 2'd1;
|
||||
localparam GET_WIDTH = 2'd2;
|
||||
localparam GET_COUNT = 2'd3;
|
||||
|
||||
reg [DATAW-1:0] data_store [SIZE-1:0];
|
||||
reg [DELTAW-1:0] delta_store [SIZE-1:0];
|
||||
@@ -84,10 +80,10 @@ module VX_scope #(
|
||||
CMD_GET_VALID,
|
||||
CMD_GET_DATA,
|
||||
CMD_GET_WIDTH,
|
||||
CMD_GET_COUNT: out_cmd <= $bits(out_cmd)'(cmd_type);
|
||||
CMD_SET_DELAY: delay_val <= $bits(delay_val)'(cmd_data);
|
||||
CMD_SET_STOP: waddr_end <= $bits(waddr)'(cmd_data);
|
||||
default:;
|
||||
CMD_GET_COUNT: out_cmd <= $bits(out_cmd)'(cmd_type);
|
||||
CMD_SET_DELAY: delay_val <= $bits(delay_val)'(cmd_data);
|
||||
CMD_SET_STOP: waddr_end <= $bits(waddr)'(cmd_data);
|
||||
default:;
|
||||
endcase
|
||||
end
|
||||
|
||||
@@ -183,7 +179,7 @@ module VX_scope #(
|
||||
end
|
||||
|
||||
`ifdef DBG_PRINT_SCOPE
|
||||
always_ff @(posedge clk) begin
|
||||
always @(posedge clk) begin
|
||||
if (bus_read) begin
|
||||
$display("%t: scope-read: cmd=%0d, out=0x%0h, addr=%0d", $time, out_cmd, bus_out, raddr);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user