mirror of
https://github.com/MPSU/APS.git
synced 2025-09-18 02:10:40 +00:00
ЛР10. Обновление tb_irq
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
module tb_irq();
|
module tb_irq();
|
||||||
logic clk_i;
|
logic clk_i;
|
||||||
logic rst_i;
|
logic rst_i;
|
||||||
@@ -22,14 +21,17 @@ module tb_irq();
|
|||||||
logic [31:0] irq_cause_o;
|
logic [31:0] irq_cause_o;
|
||||||
logic irq_o;
|
logic irq_o;
|
||||||
|
|
||||||
|
string str;
|
||||||
|
|
||||||
interrupt_controller dut(.*);
|
interrupt_controller dut(.*);
|
||||||
|
int err_count;
|
||||||
|
|
||||||
always #5 clk_i <= ~clk_i;
|
always #5 clk_i <= ~clk_i;
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
$display("\n\n===========================\n\nPress button 'Run All' (F3)\n\n===========================\n\n");
|
$display("\n\n===========================\n\nPress button 'Run All' (F3)\n\n===========================\n\n", $time);
|
||||||
$stop();
|
$stop();
|
||||||
clk_i <= 0;
|
clk_i = '0;
|
||||||
exception_i = '0;
|
exception_i = '0;
|
||||||
mret_i = '0;
|
mret_i = '0;
|
||||||
irq_req_i = '0;
|
irq_req_i = '0;
|
||||||
@@ -47,6 +49,9 @@ initial begin
|
|||||||
t10();
|
t10();
|
||||||
t11();
|
t11();
|
||||||
t12();
|
t12();
|
||||||
|
t13();
|
||||||
|
t14();
|
||||||
|
$display("Simulation finished. Number of errors: %d", err_count);
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -63,6 +68,7 @@ endtask
|
|||||||
logic [1:0] k;
|
logic [1:0] k;
|
||||||
|
|
||||||
task t1();
|
task t1();
|
||||||
|
$display("TEST 01. Granted request.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
@@ -70,13 +76,12 @@ task t1();
|
|||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=1) $display("Error: irq_o != 1");
|
eror_info(1,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t2();
|
task t2();
|
||||||
|
$display("TEST 02. Forbidden request.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
@@ -84,13 +89,12 @@ task t2();
|
|||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 0;
|
mie_i = 0;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t3();
|
task t3();
|
||||||
|
$display("TEST 03. Another request while handling previous.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
@@ -103,22 +107,19 @@ task t3();
|
|||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t4();
|
task t4();
|
||||||
|
$display("TEST 04. Request while unhandled exception.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
@@ -128,284 +129,264 @@ task t4();
|
|||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
mret_i = 0;
|
||||||
@(posedge clk_i);
|
exception_i = 1;
|
||||||
|
irq_req_i = 0;
|
||||||
|
mie_i = 1;
|
||||||
|
#1
|
||||||
|
eror_info(0,0);
|
||||||
|
@(posedge clk_i);
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t5();
|
task t5();
|
||||||
|
$display("TEST 05. MRET while handling interrupt only.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,1);
|
||||||
if (irq_ret_o!=1) $display("Error: irq_ret_o != 1");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t6();
|
task t6();
|
||||||
|
$display("TEST 06. MRET while handling exception only.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 1;
|
exception_i = 1;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
eror_info(0,0);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t7();
|
task t7();
|
||||||
|
$display("TEST 07. MRET while handling interrupt and exception.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 1;
|
exception_i = 1;
|
||||||
irq_req_i = 1;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i)
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
eror_info(0,0);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 0;
|
|
||||||
exception_i = 0;
|
|
||||||
irq_req_i = 0;
|
|
||||||
mie_i = 1;
|
|
||||||
#1
|
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t8();
|
task t8();
|
||||||
|
$display("TEST 08. Two MRETs while handling interrupt and exception.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 1;
|
exception_i = 1;
|
||||||
irq_req_i = 1;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
@(posedge clk_i);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
@(posedge clk_i);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,1);
|
||||||
if (irq_ret_o!=1) $display("Error: irq_ret_o != 1");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t9();
|
task t9();
|
||||||
|
$display("TEST 09. MRET while unhandled interrupt and subsequent request.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
@(posedge clk_i);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=1) $display("Error: irq_ret_o != 1");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=1) $display("Error: irq_o != 1");
|
eror_info(1,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t10();
|
task t10();
|
||||||
|
$display("TEST 10. MRET while unhandled exception and subsequent request.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 1;
|
exception_i = 1;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
@(posedge clk_i);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=1) $display("Error: irq_o != 1");
|
eror_info(1,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t11();
|
task t11();
|
||||||
|
$display("TEST 11. MRET while unhandled interrupt and exception and subsequent request.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i <= 0;
|
||||||
exception_i = 0;
|
exception_i <= 0;
|
||||||
irq_req_i = 1;
|
irq_req_i <= 1;
|
||||||
mie_i = 1;
|
mie_i <= 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i <= 0;
|
||||||
exception_i = 1;
|
exception_i <= 1;
|
||||||
irq_req_i = 1;
|
irq_req_i <= 0;
|
||||||
mie_i = 1;
|
mie_i <= 1;
|
||||||
#1
|
@(posedge clk_i);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
mret_i <= 1;
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
exception_i <= 0;
|
||||||
@(posedge clk_i);
|
irq_req_i <= 0;
|
||||||
mret_i = 1;
|
mie_i <= 1;
|
||||||
exception_i = 0;
|
|
||||||
irq_req_i = 0;
|
|
||||||
mie_i = 1;
|
|
||||||
#1
|
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 0;
|
|
||||||
exception_i = 0;
|
|
||||||
irq_req_i = 0;
|
|
||||||
mie_i = 1;
|
|
||||||
#1
|
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
eror_info(0,0);
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
@(posedge clk_i);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
task t12();
|
task t12();
|
||||||
|
$display("TEST 12. Two MRETs while unhandled interrupt and exception and susbsequent request.");
|
||||||
reset();
|
reset();
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 1;
|
exception_i = 1;
|
||||||
irq_req_i = 1;
|
|
||||||
mie_i = 1;
|
|
||||||
#1
|
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 1;
|
|
||||||
exception_i = 0;
|
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
|
||||||
mret_i = 0;
|
|
||||||
exception_i = 0;
|
|
||||||
irq_req_i = 0;
|
|
||||||
mie_i = 1;
|
|
||||||
#1
|
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
|
||||||
@(posedge clk_i);
|
@(posedge clk_i);
|
||||||
mret_i = 1;
|
mret_i = 1;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 0;
|
irq_req_i = 0;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
@(posedge clk_i);
|
||||||
if (irq_o!=0) $display("Error: irq_o != 0");
|
mret_i = 0;
|
||||||
if (irq_ret_o!=1) $display("Error: irq_ret_o != 1");
|
exception_i = 0;
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
irq_req_i = 0;
|
||||||
@(posedge clk_i);
|
mie_i = 1;
|
||||||
|
@(posedge clk_i);
|
||||||
|
mret_i = 1;
|
||||||
|
exception_i = 0;
|
||||||
|
irq_req_i = 0;
|
||||||
|
mie_i = 1;
|
||||||
|
@(posedge clk_i);
|
||||||
mret_i = 0;
|
mret_i = 0;
|
||||||
exception_i = 0;
|
exception_i = 0;
|
||||||
irq_req_i = 1;
|
irq_req_i = 1;
|
||||||
mie_i = 1;
|
mie_i = 1;
|
||||||
#1
|
#1
|
||||||
if (irq_o!=1) $display("Error: irq_o != 1");
|
str = "request interrupt after 2 mret for interrupt and exception";
|
||||||
if (irq_ret_o!=0) $display("Error: irq_ret_o != 0");
|
eror_info(1,0);
|
||||||
if (irq_cause_o!=32'h1000_0010) $display("Error: irq_o != 32'h1000_0010");
|
@(posedge clk_i);
|
||||||
|
endtask
|
||||||
|
|
||||||
|
task t13();
|
||||||
|
$display("TEST 13. Request next cycle after excetion.");
|
||||||
|
reset();
|
||||||
|
@(posedge clk_i);
|
||||||
|
mret_i = 0;
|
||||||
|
exception_i = 1;
|
||||||
|
irq_req_i = 0;
|
||||||
|
mie_i = 1;
|
||||||
|
@(posedge clk_i);
|
||||||
|
mret_i = 0;
|
||||||
|
exception_i = 0;
|
||||||
|
irq_req_i = 1;
|
||||||
|
mie_i = 1;
|
||||||
|
#1
|
||||||
|
eror_info(0,0);
|
||||||
|
@(posedge clk_i);
|
||||||
|
endtask
|
||||||
|
|
||||||
|
task t14();
|
||||||
|
$display("TEST 14. Request same cycle with the exception.");
|
||||||
|
reset();
|
||||||
|
@(posedge clk_i);
|
||||||
|
mret_i = 0;
|
||||||
|
exception_i = 1;
|
||||||
|
irq_req_i = 1;
|
||||||
|
mie_i = 1;
|
||||||
|
#1
|
||||||
|
eror_info(0,0);
|
||||||
|
@(posedge clk_i);
|
||||||
|
endtask
|
||||||
|
|
||||||
|
//logic irq, irq_ret;
|
||||||
|
|
||||||
|
task eror_info(irq, irq_ret);
|
||||||
|
if (irq_o!=irq) begin $error("invalid irq_o = %b, expected value %b." , irq_o, irq ); err_count++; end
|
||||||
|
if (irq_ret_o!=irq_ret) begin $error("invalid irq_ret_o = %b, expected value %b." , irq_ret_o, irq_ret); err_count++; end
|
||||||
|
if (irq_cause_o!=32'h1000_0010) begin $error("invalid irq_cause_o = %h, expected value 32'h1000_0010.", irq_cause_o ); err_count++; end
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
Reference in New Issue
Block a user