Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use work.pkg_corr_matrixpi_version.all;
architecture basic of TestCtrl is
------------------------
-- SIGNAL DECLARATION --
------------------------
signal ConfigDone : integer_barrier := 1 ;
signal TestDone : integer_barrier := 1 ;
--------------------------
-- FUNCTION DECLARATION --
--------------------------
function f_addr(addr:natural) return std_logic_vector is
begin
return std_logic_vector(to_unsigned(addr, AXI_ADDR_WIDTH));
end function;
function f_sdata(data:integer) return std_logic_vector is
begin
return std_logic_vector(to_signed(data, AXI_DATA_WIDTH));
end function;
function f_bpmpkt(id:natural; x:integer; y:integer) return std_logic_vector is
begin
return std_logic_vector(to_unsigned(id, C_W_BPMID)) & std_logic_vector(to_signed(x, C_W_BPMPOS)) & std_logic_vector(to_signed(y, C_W_BPMPOS));
end function;
begin
------------------------------------------------------------
-- ControlProc
-- Set up AlertLog and wait for end of test
------------------------------------------------------------
ControlProc : process
begin
-- Initialization of test
SetAlertLogName("BasicTest");
SetLogEnable(PASSED, TRUE); -- Enable PASSED logs
SetLogEnable(INFO, TRUE); -- Enable INFO logs
-- Wait for testbench initialization
wait for 0 ns ; wait for 0 ns;
TranscriptOpen(OSVVM_RESULTS_DIR & "BasicTestTr.txt");
SetTranscriptMirror(TRUE);
-- Wait for Design Reset
wait until nReset = '1';
ClearAlerts;
-- Wait for test to finish
WaitForBarrier(TestDone, 35 ms);
AlertIf(now >= 35 ms, "Test finished due to timeout");
AlertIf(GetAffirmCount < 1, "Test is not Self-Checking");
TranscriptClose;
EndOfTestReports;
std.env.stop;
wait;
end process ControlProc;
------------------------------------------------------------
-- ManagerProc
-- Generate transactions for AxiManager
------------------------------------------------------------
ManagerProc : process
variable Data : std_logic_vector(AXI_DATA_WIDTH-1 downto 0) ;
begin
wait until nReset = '1';
WaitForClock(ManagerRec, 2);
log("Read version", INFO) ;
Read(ManagerRec, f_addr(0), Data) ;
AffirmIfEqual(Data, C_VERSION, "Manager Read Data: ") ;
log("==--- Configure the DUT ---==", INFO);
log("+-- Global Config", INFO);
-- Correction coefficients
Write(ManagerRec, f_addr(12), f_sdata(2387));
Write(ManagerRec, f_addr(16), f_sdata(7353));
-- Set all orbit reference to 0
for I in 0 to C_N_MM_BPM-1 loop
Write(ManagerRec, f_addr(20+I*4), f_sdata(0));
end loop;
WaitForBarrier(ConfigDone);
-- Global Enable
WaitForClock(ManagerRec, 10) ;
--Write(ManagerRec, std_logic_vector(C_REGISTER_INFO(C_CONFIG_ID).address), X"00000001") ;
-- Wait for outputs to propagate and signal TestDone
WaitForClock(ManagerRec, 2000) ;
WaitForBarrier(TestDone) ;
wait ;
end process ManagerProc ;
------------------------------------------------------------
-- AxiTransmitterProc
-- Generate transactions for AxiTransmitter
------------------------------------------------------------
TransmitterProc : process
variable Data : std_logic_vector(DATA_TX_WIDTH-1 downto 0);
variable OffSet : integer ;
variable TransactionCount : integer;
variable ErrorCount : integer;
variable CurTime : time ;
variable TxAlertLogID : AlertLogIDType ;
begin
wait until nReset = '1' ;
WaitForClock(StreamTxRec, 2) ;
WaitForBarrier(ConfigDone) ;
log("Sending bpm packets", INFO);
for I in 3 to 124 loop
Send(StreamTxRec, f_bpmpkt(I, -7874+333*I, 5679-1098*I));
end loop;
-- Wait for outputs to propagate and signal TestDone
WaitForClock(StreamTxRec, 2) ;
WaitForBarrier(TestDone) ;
wait ;
end process TransmitterProc ;
end basic;
Configuration tc_basic of tb_corr_matrixpi is
for TestHarness
for TestCtrl_1 : TestCtrl
use entity work.TestCtrl(basic);
end for;
end for;
end tc_basic;