📄 cordic_par_seq_apb_test_master.v
字号:
// This version uses task calls into interface via modports
`timescale 1ns/1ns
module CORDIC_par_seq_bus_test_master
#(parameter
period = 10,
IObase = 16'hFE00
)
(
APB.TF_master apb,
output logic async_reset
);
localparam
adr_cmd = IObase+0,
adr_status = IObase+0,
adr_angle = IObase+1,
adr_x = IObase+2,
adr_y = IObase+3;
T_sdata
input_angle, input_x, input_y,
exp_angle, exp_x, exp_y,
result_angle, result_x, result_y;
initial
$timeformat (-9, 0, "ns", 8);
always begin: ClockGenerator
apb.PCLK = 0;
apb.PCLK <= #(period/2) 1;
#period;
end // ClockGenerator
initial begin: TestSequence
// Reset
async_reset = 1;
apb.idle(4);
@(negedge apb.PCLK) async_reset = 0;
// Wait for a few rising clocks
apb.idle(3);
// Do some writes to registers
loadInputs(0, 16'hF000, 0, 2000);
await(2);
readResults(result_angle, result_x, result_y);
apb.idle(3);
loadInputs(1, 16'hF000, 0, 2000);
await(0);
readResults(result_angle, result_x, result_y);
apb.idle(3);
$display("");
$stop;
end // TestSequence
function poisson(int n);
int seed = 0;
return $dist_poisson(seed, n);
endfunction
// Tasks to encapsulate parts of the test sequence
task readResults (
output T_sdata angle, x, y
);
apb.read ( adr_angle, angle );
apb.idle(poisson(2));
apb.read ( adr_x, x );
apb.idle(poisson(2));
apb.read ( adr_y, y );
apb.idle(poisson(2));
$display("Hardware: a=%X, x=%X, y=%x, time=%t",
angle, x, y, $time);
$display("---------------------------------------------------------");
endtask
task loadInputs (
input logic reduce,
input T_sdata angle, x, y
);
apb.write ( adr_angle, angle );
apb.idle(poisson(2));
apb.write ( adr_x, x );
apb.idle(poisson(2));
apb.write ( adr_y, y );
apb.idle(poisson(2));
start ( reduce );
apb.idle(poisson(2));
// Take copies for later checking
input_angle = angle;
input_x = x;
input_y = y;
// Evaluate expected result
vlog_CORDIC_model(reduce, angle, x, y, exp_angle, exp_x, exp_y);
$display("Started: a=%X, x=%X, y=%x, reduce=%b, time=%t",
angle, x, y, reduce, $time);
$display("Expected: a=%X, x=%X, y=%x",
exp_angle,exp_x,exp_y);
endtask
task start (
input bit reduceNotRotate
);
apb.write ( adr_cmd, {15'b0, reduceNotRotate} );
endtask
task await;
input int poll_interval;
reg busy;
do begin
apb.idle ( poisson(poll_interval) );
apb.read ( adr_status, busy );
end while (busy);
endtask
endmodule // CORDIC_par_seq_bus_test_master
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -