This commit is contained in:
2026-06-12 07:53:32 +02:00
commit 59e71f3297
259 changed files with 29010 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// Library: calc1
// Module: ALU Input Stage
// Author: Naseer SIddique
module alu_input_stage (alu_data1, alu_data2, hold1_data1, hold1_data2, hold2_data1, hold2_data2, hold3_data1, hold3_data2, hold4_data1, hold4_data2, prio_alu_in_cmd, prio_alu_in_req_id);
output [0:63] alu_data1, alu_data2;
wire [0:63] alu_data1, alu_data2;
input [0:31] hold1_data1, hold1_data2,
hold2_data1, hold2_data2,
hold3_data1, hold3_data2,
hold4_data1, hold4_data2;
input [0:3] prio_alu_in_cmd;
input [0:1] prio_alu_in_req_id;
assign alu_data1[32:63] =
prio_alu_in_req_id[0:1] == 2'b00 ? hold1_data1[0:31] :
prio_alu_in_req_id[0:1] == 2'b01 ? hold2_data1[0:31] :
prio_alu_in_req_id[0:1] == 2'b10 ? hold3_data1[0:31] :
prio_alu_in_req_id[0:1] == 2'b11 ? hold4_data1[0:31] :
32'b0;
assign alu_data2[32:63] =
prio_alu_in_req_id[0:1] == 2'b00 ? hold1_data2[0:31] :
prio_alu_in_req_id[0:1] == 2'b01 ? hold2_data2[0:31] :
prio_alu_in_req_id[0:1] == 2'b10 ? hold3_data2[0:31] :
prio_alu_in_req_id[0:1] == 2'b11 ? hold4_data2[0:31] :
32'b0;
assign alu_data1[0:31] = 32'b0;
assign alu_data2[0:31] = 32'b0;
endmodule // alu_input_stage

View File

@@ -0,0 +1,47 @@
// Library: calc1
// Module: ALU Output Stage
// Author: Naseer Siddique
module alu_output_stage(out_data1, out_data2, out_data3, out_data4, out_resp1, out_resp2, out_resp3, out_resp4, c_clk,alu_overflow, alu_result, local_error_found, prio_alu_out_req_id, prio_alu_out_vld, reset);
output [0:31] out_data1, out_data2, out_data3, out_data4;
output [0:1] out_resp1, out_resp2, out_resp3, out_resp4;
input [0:63] alu_result;
input [0:1] prio_alu_out_req_id;
input [1:7] reset;
input c_clk,
alu_overflow,
local_error_found,
prio_alu_out_vld;
wire [0:31] hold_data;
wire [0:1] hold_resp, hold_id;
assign hold_id[0:1] = prio_alu_out_req_id[0:1];
assign hold_resp[0:1] =
(~prio_alu_out_vld) ? 2'b00 :
(~local_error_found) ? 2'b01 :
(alu_result[31]) ? 2'b10 :
2'b01;
assign hold_data[0:31] = (prio_alu_out_vld) ? alu_result[32:63] : 32'b0;
assign out_resp1[0:1] = (hold_id[0:1] == 2'b00) ? hold_resp[0:1] : 2'b00;
assign out_resp2[0:1] = (hold_id[0:1] == 2'b01) ? hold_resp[0:1] : 2'b00;
assign out_resp3[0:1] = (hold_id[0:1] == 2'b10) ? hold_resp[0:1] : 2'b00;
assign out_resp4[0:1] = (hold_id[0:1] == 2'b11) ? hold_resp[0:1] : 2'b00;
assign out_data1[0:31] = (hold_id[0:1] == 2'b00) ? hold_data[0:31] : 32'b0;
assign out_data2[0:31] = (hold_id[0:1] == 2'b01) ? hold_data[0:31] : 32'b0;
assign out_data3[0:31] = (hold_id[0:1] == 2'b10) ? hold_data[0:31] : 32'b0;
assign out_data4[0:31] = (hold_id[0:1] == 2'b11) ? hold_data[0:31] : 32'b0;
endmodule

278
code/vezba9/dut/calc_top.v Normal file
View File

@@ -0,0 +1,278 @@
// Library: calc1
// Module: Top-level wiring
// Author: Naseer Siddique
//`include "alu_input_stage.v"
//`include "alu_output_stage.v"
//`include "exdbin_mac.v"
//`include "holdreg.v"
//`include "mux_out.v"
//`include "shifter.v"
//`include "priority.v"
module calc_top (out_data1, out_data2, out_data3, out_data4, out_resp1, out_resp2, out_resp3, out_resp4, c_clk, req1_cmd_in, req1_data_in, req2_cmd_in, req2_data_in, req3_cmd_in, req3_data_in, req4_cmd_in, req4_data_in, reset);
output [0:31] out_data1,
out_data2,
out_data3,
out_data4;
output [0:1] out_resp1,
out_resp2,
out_resp3,
out_resp4;
input c_clk;
input [0:3] req1_cmd_in,
req2_cmd_in,
req3_cmd_in,
req4_cmd_in;
input [0:31] req1_data_in,
req2_data_in,
req3_data_in,
req4_data_in;
input [1:7] reset;
wire [0:63] add_sum,
fxu_areg_q,
fxu_breg_q,
shift_out,
shift_places,
shift_val;
wire [0:31] hold1_data1,
hold1_data2,
hold2_data1,
hold2_data2,
hold3_data1,
hold3_data2,
hold4_data1,
hold4_data2,
mux1_req_data1,
mux1_req_data2,
mux2_req_data1,
mux2_req_data2,
mux3_req_data1,
mux3_req_data2,
mux4_req_data1,
mux4_req_data2;
wire [0:3] hold1_prio_req,
hold2_prio_req,
hold3_prio_req,
hold4_prio_req,
prio_alu1_in_cmd,
prio_alu2_in_cmd;
wire [0:1] mux1_req_resp1,
mux1_req_resp2,
mux2_req_resp1,
mux2_req_resp2,
mux3_req_resp1,
mux3_req_resp2,
mux4_req_resp1,
mux4_req_resp2,
prio_alu1_in_req_id,
prio_alu1_out_req_id,
prio_alu2_in_req_id,
prio_alu2_out_req_id;
wire prio_alu1_out_vld,
prio_alu2_out_vld,
add_ovfl,
shift_ovfl;
wire [0:3] error_found;
assign error_found = 4'b0000;
exdbin_mac adder (
.alu_cmd ( prio_alu1_in_cmd[0:3] ),
.bin_ovfl ( add_ovfl ),
.bin_sum ( add_sum[0:63] ),
.fxu_areg_q ( fxu_areg_q[0:63] ),
.fxu_breg_q ( fxu_breg_q[0:63] ),
.local_error_found ( error_found[0] )
);
holdreg holdreg1(
.c_clk ( c_clk ),
.hold_data1 ( hold1_data1[0:31] ),
.hold_data2 ( hold1_data2[0:31] ),
.hold_prio_req ( hold1_prio_req[0:3] ),
.req_cmd_in ( req1_cmd_in[0:3] ),
.req_data_in ( req1_data_in[0:31] ),
.reset ( reset [1: 7] )
);
holdreg holdreg2(
.c_clk ( c_clk ),
.hold_data1 ( hold2_data1[0:31] ),
.hold_data2 ( hold2_data2[0:31] ),
.hold_prio_req ( hold2_prio_req[0:3] ),
.req_cmd_in ( req2_cmd_in[0:3] ),
.req_data_in ( req2_data_in[0:31] ),
.reset ( reset [1: 7] )
);
holdreg holdreg3(
.c_clk ( c_clk ),
.hold_data1 ( hold3_data1[0:31] ),
.hold_data2 ( hold3_data2[0:31] ),
.hold_prio_req ( hold3_prio_req[0:3] ),
.req_cmd_in ( req3_cmd_in[0:3] ),
.req_data_in ( req3_data_in[0:31] ),
.reset ( reset [1: 7] )
);
holdreg holdreg4(
.c_clk ( c_clk ),
.hold_data1 ( hold4_data1[0:31] ),
.hold_data2 ( hold4_data2[0:31] ),
.hold_prio_req ( hold4_prio_req[0:3] ),
.req_cmd_in ( req4_cmd_in[0:3] ),
.req_data_in ( req4_data_in[0:31] ),
.reset ( reset [1: 7] )
);
alu_input_stage in_stage1(
.alu_data1 ( fxu_areg_q[0:63]),
.alu_data2 ( fxu_breg_q[0:63]),
.hold1_data1 ( hold1_data1[0:31]),
.hold1_data2 ( hold1_data2[0:31]),
.hold2_data1 ( hold2_data1[0:31]),
.hold2_data2 ( hold2_data2[0:31]),
.hold3_data1 ( hold3_data1[0:31]),
.hold3_data2 ( hold3_data2[0:31]),
.hold4_data1 ( hold4_data1[0:31]),
.hold4_data2 ( hold4_data2[0:31]),
.prio_alu_in_cmd ( prio_alu1_in_cmd[0:3]),
.prio_alu_in_req_id ( prio_alu1_in_req_id[0:1])
);
alu_input_stage in_stage2(
.alu_data1 ( shift_val[0:63]),
.alu_data2 ( shift_places[0:63]),
.hold1_data1 ( hold1_data1[0:31]),
.hold1_data2 ( hold1_data2[0:31]),
.hold2_data1 ( hold2_data1[0:31]),
.hold2_data2 ( hold2_data2[0:31]),
.hold3_data1 ( hold3_data1[0:31]),
.hold3_data2 ( hold3_data2[0:31]),
.hold4_data1 ( hold4_data1[0:31]),
.hold4_data2 ( hold4_data2[0:31]),
.prio_alu_in_cmd ( prio_alu2_in_cmd[0:3]),
.prio_alu_in_req_id ( prio_alu2_in_req_id[0:1])
);
mux_out mux_out1(
.req_data1 ( mux1_req_data1[0:31]),
.req_data2 ( mux1_req_data2[0:31]),
.req_data ( out_data1[0:31]),
.req_resp1 ( mux1_req_resp1[0:1]),
.req_resp2 ( mux1_req_resp2[0:1]),
.req_resp ( out_resp1[0:1])
);
mux_out mux_out2(
.req_data1 ( mux2_req_data1[0:31]),
.req_data2 ( mux2_req_data2[0:31]),
.req_data ( out_data2[0:31]),
.req_resp1 ( mux2_req_resp1[0:1]),
.req_resp2 ( mux2_req_resp2[0:1]),
.req_resp ( out_resp2[0:1])
);
mux_out mux_out3(
.req_data1 ( mux3_req_data1[0:31]),
.req_data2 ( mux3_req_data2[0:31]),
.req_data ( out_data3[0:31]),
.req_resp1 ( mux3_req_resp1[0:1]),
.req_resp2 ( mux3_req_resp2[0:1]),
.req_resp ( out_resp3[0:1])
);
mux_out mux_out4(
.req_data1 ( mux4_req_data1[0:31]),
.req_data2 ( mux4_req_data2[0:31]),
.req_data ( out_data4[0:31]),
.req_resp1 ( mux4_req_resp1[0:1]),
.req_resp2 ( mux4_req_resp2[0:1]),
.req_resp ( out_resp4[0:1])
);
alu_output_stage out_stage1(
.alu_overflow ( add_ovfl),
.alu_result ( add_sum[0:63]),
.c_clk ( c_clk),
.local_error_found ( error_found[2]),
.out_data1 ( mux1_req_data1[0:31]),
.out_data2 ( mux2_req_data1[0:31]),
.out_data3 ( mux3_req_data1[0:31]),
.out_data4 ( mux4_req_data1[0:31]),
.out_resp1 ( mux1_req_resp1[0:1]),
.out_resp2 ( mux2_req_resp1[0:1]),
.out_resp3 ( mux3_req_resp1[0:1]),
.out_resp4 ( mux4_req_resp1[0:1]),
.prio_alu_out_req_id ( prio_alu1_out_req_id[0:1]),
.prio_alu_out_vld ( prio_alu1_out_vld ),
.reset ( reset[1:7])
);
alu_output_stage out_stage2(
.alu_overflow ( shift_ovfl),
.alu_result ( shift_out[0:63]),
.c_clk ( c_clk),
.local_error_found ( error_found[2]),
.out_data1 ( mux1_req_data2[0:31]),
.out_data2 ( mux2_req_data2[0:31]),
.out_data3 ( mux3_req_data2[0:31]),
.out_data4 ( mux4_req_data2[0:31]),
.out_resp1 ( mux1_req_resp2[0:1]),
.out_resp2 ( mux2_req_resp2[0:1]),
.out_resp3 ( mux3_req_resp2[0:1]),
.out_resp4 ( mux4_req_resp2[0:1]),
.prio_alu_out_req_id ( prio_alu2_out_req_id[0:1]),
.prio_alu_out_vld ( prio_alu2_out_vld ),
.reset ( reset[1:7])
);
priority1 priority_logic (
.c_clk ( c_clk),
.hold1_prio_req ( hold1_prio_req[0:3]),
.hold2_prio_req ( hold2_prio_req[0:3]),
.hold3_prio_req ( hold3_prio_req[0:3]),
.hold4_prio_req ( hold4_prio_req[0:3]),
.local_error_found ( error_found[3]),
.prio_alu1_in_cmd ( prio_alu1_in_cmd[0:3]),
.prio_alu1_in_req_id ( prio_alu1_in_req_id[0:1]),
.prio_alu1_out_req_id ( prio_alu1_out_req_id[0:1]),
.prio_alu1_out_vld ( prio_alu1_out_vld),
.prio_alu2_in_cmd ( prio_alu2_in_cmd[0:3]),
.prio_alu2_in_req_id ( prio_alu2_in_req_id[0:1]),
.prio_alu2_out_req_id ( prio_alu2_out_req_id[0:1]),
.prio_alu2_out_vld ( prio_alu2_out_vld),
.reset ( reset[1:7])
);
shifter shifter1(
.bin_ovfl ( shift_ovfl),
.local_error_found ( error_found[1]),
.shift_cmd ( prio_alu2_in_cmd[0:3]),
.shift_out ( shift_out[0:63]),
.shift_places ( shift_places[0:63]),
.shift_val ( shift_val[0:63])
);
endmodule // calc1_top

1279
code/vezba9/dut/exdbin_mac.v Normal file

File diff suppressed because it is too large Load Diff

56
code/vezba9/dut/holdreg.v Normal file
View File

@@ -0,0 +1,56 @@
// Library: calc1
// Module: Hold Register
// Author: Naseer Siddique
module holdreg(hold_data1, hold_data2, hold_prio_req, c_clk, req_cmd_in, req_data_in, reset);
input c_clk;
input [0:3] req_cmd_in;
input [1:7] reset;
input [0:31] req_data_in;
output [0:3] hold_prio_req;
output [0:31] hold_data1, hold_data2;
reg [0:3] cmd_hold, hold_prio_reg;
wire [0:3] cmd_hold_q;
reg [0:31] hold_data1_q, hold_data2_q;
always
@ (posedge c_clk) begin
fork
cmd_hold[0:3] <= (reset[1] == 1) ? 4'b0 : req_cmd_in[0:3];
hold_prio_reg[0:3] <= cmd_hold[0:3];
join
end
always
@ (posedge c_clk) begin
fork
hold_data1_q[0:31] <=
(reset[1]) ? 32'b0 :
(req_cmd_in[0:3] != 4'b0) ? req_data_in[0:31] :
hold_data1_q[0:31];
hold_data2_q[0:31] <=
(reset[1]) ? 32'b0 : (cmd_hold[0:3] != 4'b0) ?
req_data_in[0:31] : hold_data2_q[0:31];
join
end
assign hold_data1 = hold_data1_q;
assign hold_data2 = hold_data2_q;
assign hold_prio_req = hold_prio_reg;
endmodule // holdreg

27
code/vezba9/dut/mux_out.v Normal file
View File

@@ -0,0 +1,27 @@
// Library: calc1
// Module: Output Mux
// Author: Naseer Siddique
module mux_out(req_data, req_resp, req_data1, req_data2, req_resp1, req_resp2);
output [0:31] req_data;
output [0:1] req_resp;
input [0:31] req_data1, req_data2;
input [0:1] req_resp1, req_resp2;
assign req_resp[0:1] =
(req_resp1[0:1] != 2'b00) ? req_resp1 :
( req_resp2[0:1] != 2'b00 ) ? req_resp2 :
2'b00;
assign req_data[0:31] =
( req_resp1[0:1] != 2'b00 ) ? req_data1 :
( req_resp2[0:1] != 2'b00 ) ? req_data2 :
32'b0;
endmodule // mux_out

155
code/vezba9/dut/priority.v Normal file
View File

@@ -0,0 +1,155 @@
// Library: calc1
// Priority Logic
// Author: Naseer Siddique
module priority1 ( prio_alu1_in_cmd, prio_alu1_in_req_id, prio_alu1_out_req_id, prio_alu1_out_vld, prio_alu2_in_cmd, prio_alu2_in_req_id, prio_alu2_out_req_id, prio_alu2_out_vld, c_clk, hold1_prio_req, hold2_prio_req, hold3_prio_req, hold4_prio_req, local_error_found, reset);
output [0:3] prio_alu1_in_cmd, prio_alu2_in_cmd;
output [0:1] prio_alu1_out_req_id, prio_alu1_in_req_id, prio_alu2_in_req_id, prio_alu2_out_req_id;
output prio_alu1_out_vld, prio_alu2_out_vld;
input c_clk, local_error_found;
input [0:3] hold1_prio_req, hold2_prio_req, hold3_prio_req, hold4_prio_req;
input [1:7] reset;
reg [0:3] cmd1, cmd2, cmd3, cmd4;
reg delay1, delay2;
wire cmd1_reset, cmd2_reset, cmd3_reset, cmd4_reset;
reg [0:1] prio_req1_id_q, prio_req2_id_q;
reg prio_alu1_out_vld_q, prio_alu2_out_vld_q;
always
@ (posedge c_clk) begin
if (reset[1]) begin
cmd1 <= 0;
cmd2 <= 0;
cmd3 <= 0;
cmd4 <= 0;
end
else begin
fork
delay1 <= prio_alu1_out_vld_q;
delay2 <= prio_alu2_out_vld_q;
cmd1[0:3] <=
(hold1_prio_req[0:3] != 4'b0) ? hold1_prio_req[0:3] :
(cmd1_reset) ? 4'b0 :
cmd1[0:3];
cmd2[0:3] <=
(hold2_prio_req[0:3] != 4'b0) ? hold2_prio_req[0:3] :
(cmd2_reset) ? 4'b0 :
cmd2[0:3];
cmd3[0:3] <=
(hold3_prio_req[0:3] != 4'b0) ? hold3_prio_req[0:3] :
(cmd3_reset) ? 4'b0 :
cmd3[0:3];
cmd4[0:3] <=
(hold4_prio_req[0:3] != 4'b0) ? hold4_prio_req[0:3] :
(cmd4_reset) ? 4'b0 :
cmd4[0:3];
join
end
end // always @ (posedge c_clk)
always
@ (delay1 or delay2 or cmd1 or cmd2 or cmd3 or cmd4) begin
if (delay1)
prio_alu1_out_vld_q <= 1'b0;
else if ( (cmd1 != 4'b0000) && (cmd1 < 4'b0100) )
prio_alu1_out_vld_q <= 1'b1;
else if ( (cmd2 != 4'b0000) && (cmd2 < 4'b0100) )
prio_alu1_out_vld_q <= 1'b1;
else if ( (cmd3 != 4'b0000) && (cmd3 < 4'b0100) )
prio_alu1_out_vld_q <= 1'b1;
else if ( (cmd4 != 4'b0000) && (cmd4 < 4'b0100) && local_error_found )
prio_alu1_out_vld_q <= 1'b1;
else if ( (cmd4 != 4'b0000) && (cmd4 < 4'b0100) )
prio_alu1_out_vld_q <= 1'b0;
else prio_alu1_out_vld_q <= 1'b0;
if (delay2)
prio_alu2_out_vld_q <= 1'b0;
else if (cmd1 > 4'b0011)
prio_alu2_out_vld_q <= 1'b1;
else if (cmd2 > 4'b0011)
prio_alu2_out_vld_q <= 1'b1;
else if (cmd3 > 4'b0011)
prio_alu2_out_vld_q <= 1'b1;
else if (cmd4 > 4'b0011)
prio_alu2_out_vld_q <= 1'b1;
else prio_alu2_out_vld_q <= 1'b0;
if ( (cmd1 != 4'b0000) && (cmd1 < 4'b0100) )
prio_req1_id_q[0:1] <= 2'b00;
else if ( (cmd2 != 4'b0000) && (cmd2 < 4'b0100) )
prio_req1_id_q[0:1] <= 2'b01;
else if ( (cmd3 != 4'b0000) && (cmd3 < 4'b0100) )
prio_req1_id_q[0:1] <= 2'b10;
else if ( (cmd4 != 4'b0000) && (cmd4 < 4'b0100) )
prio_req1_id_q[0:1] <= 2'b11;
else prio_req1_id_q[0:1] <= 2'b00;
if ( cmd1 > 4'b0011 )
prio_req2_id_q <= 2'b00;
else if ( cmd2 > 4'b0011 )
prio_req2_id_q <= 2'b01;
else if ( cmd3 > 4'b0011 )
prio_req2_id_q <= 2'b10;
else if ( cmd4 > 4'b0011 )
prio_req2_id_q <= 2'b11;
else prio_req2_id_q <= 2'b00;
end // always @ (delay1 or or delay2 or cmd1 or cmd2 or cmd3 or cmd4)
assign prio_alu1_in_req_id[0:1] = prio_req1_id_q[0:1];
assign prio_alu2_in_req_id[0:1] = prio_req2_id_q[0:1];
assign prio_alu1_out_req_id[0:1] = prio_req1_id_q[0:1];
assign prio_alu2_out_req_id[0:1] = prio_req2_id_q[0:1];
assign prio_alu1_out_vld = prio_alu1_out_vld_q;
assign prio_alu2_out_vld = prio_alu2_out_vld_q;
assign prio_alu1_in_cmd[0:3] =
(prio_req1_id_q[0:1] == 2'b00) ? cmd1[0:3] :
(prio_req1_id_q[0:1] == 2'b01) ? cmd2[0:3] :
(prio_req1_id_q[0:1] == 2'b10) ? cmd3[0:3] :
(prio_req1_id_q[0:1] == 2'b11) ? cmd4[0:3] :
4'b0;
assign prio_alu2_in_cmd[0:3] =
(prio_req2_id_q[0:1] == 2'b00) ? cmd1[0:3] :
(prio_req2_id_q[0:1] == 2'b01) ? cmd2[0:3] :
(prio_req2_id_q[0:1] == 2'b10) ? cmd3[0:3] :
(prio_req2_id_q[0:1] == 2'b11) ? cmd4[0:3] :
4'b0;
assign cmd1_reset =
(prio_alu1_out_vld_q && (prio_req1_id_q[0:1] == 2'b00) ) ? 1 :
(prio_alu2_out_vld_q && (prio_req2_id_q[0:1] == 2'b00) ) ? 1 :
0;
assign cmd2_reset =
(prio_alu1_out_vld_q && (prio_req1_id_q[0:1] == 2'b01) ) ? 1 :
(prio_alu2_out_vld_q && (prio_req2_id_q[0:1] == 2'b01) ) ? 1 :
0;
assign cmd3_reset =
(prio_alu1_out_vld_q && (prio_req1_id_q[0:1] == 2'b10) ) ? 1 :
(prio_alu2_out_vld_q && (prio_req2_id_q[0:1] == 2'b10) ) ? 1 :
0;
assign cmd4_reset =
(prio_alu1_out_vld_q && (prio_req1_id_q[0:1] == 2'b11) ) ? 1 :
(prio_alu2_out_vld_q && (prio_req2_id_q[0:1] == 2'b11) ) ? 1 :
0;
endmodule // priority

2310
code/vezba9/dut/shifter.v Normal file

File diff suppressed because it is too large Load Diff

33
code/vezba9/v9_run.f Normal file
View File

@@ -0,0 +1,33 @@
-uvmhome "/eda/cadence/2019-20/RHELx86/XCELIUM_19.03.013/tools/methodology/UVM/CDNS-1.2/"
-uvm +UVM_TESTNAME=test_simple
-sv +incdir+./verif
-sv +incdir+./verif/Agent
-sv +incdir+./verif/Sequences
-sv +incdir+./verif/Configurations
./dut/alu_input_stage.v
./dut/alu_output_stage.v
./dut/exdbin_mac.v
./dut/holdreg.v
./dut/mux_out.v
./dut/shifter.v
./dut/priority.v
./dut/calc_top.v
-sv ./verif/Configurations/configurations_pkg.sv
-sv ./verif/Agent/calc_agent_pkg.sv
-sv ./verif/Sequences/calc_seq_pkg.sv
-sv ./verif/calc_test_pkg.sv
-sv ./verif/calc_if.sv
-sv ./verif/calc_verif_top.sv
#-LINEDEBUG
-access +rwc
-disable_sem2009
-nowarn "MEMODR"
-timescale 1ns/10ps

View File

@@ -0,0 +1,47 @@
class calc_agent extends uvm_agent;
// components
calc_driver drv;
calc_sequencer seqr;
calc_monitor mon;
virtual interface calc_if vif;
// configuration
calc_config cfg;
int value;
`uvm_component_utils_begin (calc_agent)
`uvm_field_object(cfg, UVM_DEFAULT)
`uvm_component_utils_end
function new(string name = "calc_agent", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
/************Geting from configuration database*******************/
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
`uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
if(!uvm_config_db#(calc_config)::get(this, "", "calc_config", cfg))
`uvm_fatal("NOCONFIG",{"Config object must be set for: ",get_full_name(),".cfg"})
/*****************************************************************/
/************Setting to configuration database********************/
uvm_config_db#(virtual calc_if)::set(this, "*", "calc_if", vif);
/*****************************************************************/
mon = calc_monitor::type_id::create("mon", this);
if(cfg.is_active == UVM_ACTIVE) begin
drv = calc_driver::type_id::create("drv", this);
seqr = calc_sequencer::type_id::create("seqr", this);
end
endfunction : build_phase
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
if(cfg.is_active == UVM_ACTIVE) begin
drv.seq_item_port.connect(seqr.seq_item_export);
end
endfunction : connect_phase
endclass : calc_agent

View File

@@ -0,0 +1,25 @@
`ifndef CALC_AGENT_PKG
`define CALC_AGENT_PKG
package calc_agent_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
//////////////////////////////////////////////////////////
// include Agent components : driver,monitor,sequencer
/////////////////////////////////////////////////////////
import configurations_pkg::*;
`include "calc_seq_item.sv"
`include "calc_sequencer.sv"
`include "calc_driver.sv"
`include "calc_monitor.sv"
`include "calc_agent.sv"
endpackage
`endif

View File

@@ -0,0 +1,36 @@
`ifndef CALC_DRIVER_SV
`define CALC_DRIVER_SV
class calc_driver extends uvm_driver#(calc_seq_item);
`uvm_component_utils(calc_driver)
virtual interface calc_if vif;
function new(string name = "calc_driver", uvm_component parent = null);
super.new(name,parent);
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
`uvm_fatal("NOVIF",{"virtual interface must be set for: ",get_full_name(),".vif"})
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction : connect_phase
task main_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
`uvm_info(get_type_name(),
$sformatf("Driver sending...\n%s", req.sprint()),
UVM_HIGH)
// do actual driving here
/* TODO */
seq_item_port.item_done();
end
endtask : main_phase
endclass : calc_driver
`endif

View File

@@ -0,0 +1,45 @@
class calc_monitor extends uvm_monitor;
// control fileds
bit checks_enable = 1;
bit coverage_enable = 1;
uvm_analysis_port #(calc_seq_item) item_collected_port;
`uvm_component_utils_begin(calc_monitor)
`uvm_field_int(checks_enable, UVM_DEFAULT)
`uvm_field_int(coverage_enable, UVM_DEFAULT)
`uvm_component_utils_end
// The virtual interface used to drive and view HDL signals.
virtual interface calc_if vif;
// current transaction
calc_seq_item curr_it;
// coverage can go here
// ...
function new(string name = "calc_monitor", uvm_component parent = null);
super.new(name,parent);
item_collected_port = new("item_collected_port", this);
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
`uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction : connect_phase
task main_phase(uvm_phase phase);
// forever begin
// curr_it = calc_seq_item::type_id::create("curr_it", this);
// ...
// collect transactions
// ...
// item_collected_port.write(curr_it);
// end
endtask : main_phase
endclass : calc_monitor

View File

@@ -0,0 +1,21 @@
`ifndef CALC_SEQ_ITEM_SV
`define CALC_SEQ_ITEM_SV
parameter DATA_WIDTH = 32;
parameter RESP_WIDTH = 2;
parameter CMD_WIDTH = 4;
class calc_seq_item extends uvm_sequence_item;
`uvm_object_utils_begin(calc_seq_item)
`uvm_object_utils_end
function new (string name = "calc_seq_item");
super.new(name);
endfunction // new
endclass : calc_seq_item
`endif

View File

@@ -0,0 +1,15 @@
`ifndef CALC_SEQUENCER_SV
`define CALC_SEQUENCER_SV
class calc_sequencer extends uvm_sequencer#(calc_seq_item);
`uvm_component_utils(calc_sequencer)
function new(string name = "calc_sequencer", uvm_component parent = null);
super.new(name,parent);
endfunction
endclass : calc_sequencer
`endif

View File

@@ -0,0 +1,13 @@
class calc_config extends uvm_object;
uvm_active_passive_enum is_active = UVM_ACTIVE;
`uvm_object_utils_begin (calc_config)
`uvm_field_enum(uvm_active_passive_enum, is_active, UVM_DEFAULT)
`uvm_object_utils_end
function new(string name = "calc_config");
super.new(name);
endfunction
endclass : calc_config

View File

@@ -0,0 +1,15 @@
`ifndef CONFIGURATION_PKG_SV
`define CONFIGURATION_PKG_SV
package configurations_pkg;
import uvm_pkg::*; // import the UVM library
`include "uvm_macros.svh" // Include the UVM macros
`include "calc_config.sv"
endpackage : configurations_pkg
`endif

View File

@@ -0,0 +1,30 @@
`ifndef CALC_BASE_SEQ_SV
`define CALC_BASE_SEQ_SV
class calc_base_seq extends uvm_sequence#(calc_seq_item);
`uvm_object_utils(calc_base_seq)
`uvm_declare_p_sequencer(calc_sequencer)
function new(string name = "calc_base_seq");
super.new(name);
endfunction
// objections are raised in pre_body
virtual task pre_body();
uvm_phase phase = get_starting_phase();
if (phase != null)
phase.raise_objection(this, {"Running sequence '", get_full_name(), "'"});
uvm_test_done.set_drain_time(this, 200us);
endtask : pre_body
// objections are dropped in post_body
virtual task post_body();
uvm_phase phase = get_starting_phase();
if (phase != null)
phase.drop_objection(this, {"Completed sequence '", get_full_name(), "'"});
endtask : post_body
endclass : calc_base_seq
`endif

View File

@@ -0,0 +1,11 @@
`ifndef CALC_SEQ_PKG_SV
`define CALC_SEQ_PKG_SV
package calc_seq_pkg;
import uvm_pkg::*; // import the UVM library
`include "uvm_macros.svh" // Include the UVM macros
import calc_agent_pkg::calc_seq_item;
import calc_agent_pkg::calc_sequencer;
`include "calc_base_seq.sv"
`include "calc_simple_seq.sv"
endpackage
`endif

View File

@@ -0,0 +1,19 @@
`ifndef CALC_SIMPLE_SEQ_SV
`define CALC_SIMPLE_SEQ_SV
class calc_simple_seq extends calc_base_seq;
`uvm_object_utils (calc_simple_seq)
function new(string name = "calc_simple_seq");
super.new(name);
endfunction
virtual task body();
// simple example - just send one item
`uvm_do(req);
endtask : body
endclass : calc_simple_seq
`endif

View File

@@ -0,0 +1,36 @@
`ifndef CALC_ENV_SV
`define CALC_ENV_SV
class calc_env extends uvm_env;
calc_agent agent;
calc_config cfg;
virtual interface calc_if vif;
`uvm_component_utils (calc_env)
function new(string name = "calc_env", uvm_component parent = null);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
/************Geting from configuration database*******************/
if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
`uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
if(!uvm_config_db#(calc_config)::get(this, "", "calc_config", cfg))
`uvm_fatal("NOCONFIG",{"Config object must be set for: ",get_full_name(),".cfg"})
/*****************************************************************/
/************Setting to configuration database********************/
uvm_config_db#(calc_config)::set(this, "agent", "calc_config", cfg);
uvm_config_db#(virtual calc_if)::set(this, "agent", "calc_if", vif);
/*****************************************************************/
agent = calc_agent::type_id::create("agent", this);
endfunction : build_phase
endclass : calc_env
`endif

View File

@@ -0,0 +1,29 @@
`ifndef CALC_IF_SV
`define CALC_IF_SV
interface calc_if (input clk, logic [6 : 0] rst);
parameter DATA_WIDTH = 32;
parameter RESP_WIDTH = 2;
parameter CMD_WIDTH = 4;
logic [DATA_WIDTH - 1 : 0] out_data1;
logic [DATA_WIDTH - 1 : 0] out_data2;
logic [DATA_WIDTH - 1 : 0] out_data3;
logic [DATA_WIDTH - 1 : 0] out_data4;
logic [RESP_WIDTH - 1 : 0] out_resp1;
logic [RESP_WIDTH - 1 : 0] out_resp2;
logic [RESP_WIDTH - 1 : 0] out_resp3;
logic [RESP_WIDTH - 1 : 0] out_resp4;
logic [CMD_WIDTH - 1 : 0] req1_cmd_in;
logic [DATA_WIDTH - 1 : 0] req1_data_in;
logic [CMD_WIDTH - 1 : 0] req2_cmd_in;
logic [DATA_WIDTH - 1 : 0] req2_data_in;
logic [CMD_WIDTH - 1 : 0] req3_cmd_in;
logic [DATA_WIDTH - 1 : 0] req3_data_in;
logic [CMD_WIDTH - 1 : 0] req4_cmd_in;
logic [DATA_WIDTH - 1 : 0] req4_data_in;
endinterface : calc_if
`endif

View File

@@ -0,0 +1,23 @@
`ifndef CALC_TEST_PKG_SV
`define CALC_TEST_PKG_SV
package calc_test_pkg;
import uvm_pkg::*; // import the UVM library
`include "uvm_macros.svh" // Include the UVM macros
import calc_agent_pkg::*;
import calc_seq_pkg::*;
import configurations_pkg::*;
`include "calc_env.sv"
`include "test_base.sv"
`include "test_simple.sv"
`include "test_simple_2.sv"
endpackage : calc_test_pkg
`include "calc_if.sv"
`endif

View File

@@ -0,0 +1,52 @@
module calc_verif_top;
import uvm_pkg::*; // import the UVM library
`include "uvm_macros.svh" // Include the UVM macros
import calc_test_pkg::*;
logic clk;
logic [6 : 0] rst;
// interface
calc_if calc_vif(clk, rst);
// DUT
calc_top DUT(
.c_clk ( clk ),
.reset ( rst ),
.out_data1 ( calc_vif.out_data1 ),
.out_data2 ( calc_vif.out_data2 ),
.out_data3 ( calc_vif.out_data3 ),
.out_data4 ( calc_vif.out_data4 ),
.out_resp1 ( calc_vif.out_resp1 ),
.out_resp2 ( calc_vif.out_resp2 ),
.out_resp3 ( calc_vif.out_resp3 ),
.out_resp4 ( calc_vif.out_resp4 ),
.req1_cmd_in ( calc_vif.req1_cmd_in ),
.req1_data_in ( calc_vif.req1_data_in ),
.req2_cmd_in ( calc_vif.req2_cmd_in ),
.req2_data_in ( calc_vif.req2_data_in ),
.req3_cmd_in ( calc_vif.req3_cmd_in ),
.req3_data_in ( calc_vif.req3_data_in ),
.req4_cmd_in ( calc_vif.req4_cmd_in ),
.req4_data_in ( calc_vif.req4_data_in )
);
// run test
initial begin
uvm_config_db#(virtual calc_if)::set(null, "uvm_test_top.env", "calc_if", calc_vif);
run_test();
end
// clock and reset init.
initial begin
clk <= 0;
rst <= 1;
#50 rst <= 0;
end
// clock generation
always #50 clk = ~clk;
endmodule : calc_verif_top

View File

@@ -0,0 +1,29 @@
`ifndef TEST_BASE_SV
`define TEST_BASE_SV
class test_base extends uvm_test;
calc_env env;
calc_config cfg;
`uvm_component_utils(test_base)
function new(string name = "test_base", uvm_component parent = null);
super.new(name,parent);
endfunction : new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
cfg = calc_config::type_id::create("cfg");
uvm_config_db#(calc_config)::set(this, "env", "calc_config", cfg);
env = calc_env::type_id::create("env", this);
endfunction : build_phase
function void end_of_elaboration_phase(uvm_phase phase);
super.end_of_elaboration_phase(phase);
uvm_top.print_topology();
endfunction : end_of_elaboration_phase
endclass : test_base
`endif

View File

@@ -0,0 +1,27 @@
`ifndef TEST_SIMPLE_SV
`define TEST_SIMPLE_SV
class test_simple extends test_base;
`uvm_component_utils(test_simple)
calc_simple_seq simple_seq;
function new(string name = "test_simple", uvm_component parent = null);
super.new(name,parent);
endfunction : new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
simple_seq = calc_simple_seq::type_id::create("simple_seq");
endfunction : build_phase
task main_phase(uvm_phase phase);
phase.raise_objection(this);
simple_seq.start(env.agent.seqr);
phase.drop_objection(this);
endtask : main_phase
endclass
`endif

View File

@@ -0,0 +1,23 @@
`ifndef TEST_SIMPLE_2_SV
`define TEST_SIMPLE_2_SV
class test_simple_2 extends test_base;
`uvm_component_utils(test_simple_2)
function new(string name = "test_simple_2", uvm_component parent = null);
super.new(name,parent);
endfunction : new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(uvm_object_wrapper)::set(this,
"seqr.main_phase",
"default_sequence",
calc_simple_seq::type_id::get());
endfunction : build_phase
endclass
`endif