OpenCores
URL https://opencores.org/ocsvn/ahbmaster/ahbmaster/trunk

Subversion Repositories ahbmaster

[/] [ahbmaster/] [trunk/] [test79_AHBmaster/] [component/] [work/] [top/] [CoreUARTapb_0/] [rtl/] [vhdl/] [amba_bfm/] [bfm_apbslaveext.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 uson
-- Actel Corporation Proprietary and Confidential
2
-- Copyright 2008 Actel Corporation.  All rights reserved.
3
-- ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN 
4
-- ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROVED 
5
-- IN ADVANCE IN WRITING.  
6
-- Revision Information:
7
-- SVN Revision Information:
8
-- SVN $Revision: 6419 $
9
-- SVN $Date: 2009-02-04 04:34:22 -0800 (Wed, 04 Feb 2009) $
10
library ieeE;
11
use Ieee.sTD_logIC_1164.all;
12
use ieeE.numeRIC_std.all;
13
use woRK.BFm_mISC.all;
14
use WOrk.BFM_teXTIo.all;
15
use Work.top_CoreUARTapb_0_bfM_packAGE.all;
16
use sTD.TExtio.all;
17
entity top_CoreUARTapb_0_BFM_APBSLAVEeXT is
18
generic (aWIDth: iNTEGer range 1 to 32;
19
dEPTh: inTEGer := 256;
20
dwidTH: IntegER range 8 to 32 := 32;
21
EXT_sizE: intEGER range 0 to 2 := 2;
22
initFILe: striNG := "";
23
ID: intEGEr := 0;
24
tpD: INTeger range 0 to 1000 := 1;
25
ENfunc: INtegeR := 0;
26
DEBUg: InteGER range 0 to 1 := 0); port (pclK: in STd_loGIC;
27
PREsetn: in stD_LogiC;
28
PEnablE: in Std_lOGIc;
29
pWRITe: in std_LOGic;
30
Psel: in stD_logiC;
31
paDDR: in STD_loGIC_veCTOr(AwidTH-1 downto 0);
32
pWDAta: in std_LOGIc_vECTor(DWIdth-1 downto 0);
33
PRdata: out sTD_logIC_vecTOR(dWIDth-1 downto 0);
34
prEADy: out sTD_logIC;
35
PSLverr: out sTD_logIC;
36
EXt_en: in stD_LogiC;
37
exT_wr: in std_LOGic;
38
ext_Rd: in Std_LOGic;
39
EXT_addR: in std_LOGic_VECtor(AWidth-1 downto 0);
40
ext_Data: inout std_lOGIc_vECTor(dwidTH-1 downto 0));
41
end top_CoreUARTapb_0_BFM_APBSLAVEeXT;
42
 
43
architecture BFMA1io1OL of top_CoreUARTapb_0_BFM_APBSLAVEexT is
44
 
45
type BFMA1o0ILL is array (intEGEr range <> ) of Std_LOGic_vECTor(7 downto 0);
46
 
47
signal BFMA1liiLL: INtegeR := DEbug;
48
 
49
signal BFMA1o0iIL: std_LOGic;
50
 
51
signal BFMA1L0Iil: stD_LogiC;
52
 
53
signal BFMA1i0IIl: std_LOGic;
54
 
55
signal BFMA1o1iiL: std_LOGic;
56
 
57
signal BFMA1l1iIL: std_Logic;
58
 
59
signal BFMA1i1IIl: std_Logic;
60
 
61
signal BFMA1OO0il: Std_lOGIc;
62
 
63
signal BFMA1LO0il: sTD_logIC;
64
 
65
signal BFMA1iO0Il: STd_loGIC;
66
 
67
signal BFMA1OL0il: sTD_logIC_vecTOR(AwidtH-1 downto 0);
68
 
69
signal BFMA1Ll0iL: STD_loGIC_vecTOr(AWidth-1 downto 0);
70
 
71
signal BFMA1iL0Il: Std_lOGIc_veCTor(awiDTH-1 downto 0);
72
 
73
signal BFMA1OI0il: std_LOGic_VECtor(dwidTH-1 downto 0);
74
 
75
signal BFMA1Li0il: sTD_logIC_vecTOR(dwIDTH-1 downto 0);
76
 
77
signal BFMA1ii0IL: sTD_logIC_vecTOR(dwidTH-1 downto 0);
78
 
79
signal BFMA1OOoll: Std_lOGIc_veCTor(31 downto 0);
80
 
81
signal BFMA1o00Il: stD_logiC_VectOR(31 downto 0);
82
 
83
signal BFMA1L00il: STd_loGIC;
84
 
85
signal BFMA1I00iL: sTD_logIC;
86
 
87
signal BFMA1O10il: Std_lOGIC_veCTOr(31 downto 0);
88
 
89
signal BFMA1o0II: std_LOGic_vECtor(31 downto 0);
90
 
91
constant BFMA1OL00: time := tpD*1 ns;
92
 
93
begin
94
BFMA1O0Ii <= ( others => '0');
95
BFMA1i00Ll:
96
process (Pclk,PResetN)
97
file BFMA1LL00: tEXT;
98
file BFMA1il00: TExt;
99
variable BFMA1oO1ll: BFMA1o0ILL(0 to DEPth-1);
100
variable BFMA1LO1ll: iNTEger := 0;
101
variable BFMA1Ol1lL: std_LOGic_vECTor(31 downto 0);
102
variable BFMA1OI1ll: STD_logIC;
103
variable BFMA1oOOIl: IntegER;
104
variable BFMA1LooiL: inteGER;
105
variable BFMA1IOOil: Std_lOGIC_veCTOr(31 downto 0);
106
variable BFMA1lloIL: BOoleaN;
107
variable BFMA1iloiL: INTegeR;
108
variable BFMA1IL1ll: intEGEr := 0;
109
variable BFMA1Ll1ll: inteGER;
110
variable BFMA1O1ii: Std_LOGIc_vECTor(7 downto 0);
111
variable BFMA1i0L1: BOoleAN;
112
variable l: Line;
113
variable BFMA1I000: FILe_opEN_stATUs;
114
variable BFMA1O100: BooleAN := falSE;
115
variable BFMA1o1L1: CHaracTER;
116
variable v: inteGER;
117
variable BFMA1Oioil: inTEGer;
118
variable BFMA1LIOil: integER;
119
variable BFMA1oLL1: STRing(1 to 80);
120
variable BFMA1iol1: STRing(1 to 80);
121
variable BFMA1I1Oil: INtegeR;
122
variable BFMA1l10iL: INTeger;
123
variable BFMA1OOlil: bOOLean;
124
begin
125
if pcLK'EVEnt and pclk = '1'
126
and not BFMA1O100 then
127
if INitfILE'LENGth > 2 then
128
PrinTF("Opening BFM APB Slave %d Initialisation file %s",
129
Fmt(id)&FMt(InitFILE));
130
filE_Open(BFMA1I000,
131
BFMA1LL00,
132
INitfiLE);
133
if not (BFMA1I000 = opeN_ok) then
134
assert FALse report "Failed to open script file "&inITFile severity faILURe;
135
else
136
v := 0;
137
BFMA1I0l1 := falsE;
138
while not BFMA1I0l1
139
loop
140
BFMA1OO1ll(v) := ( others => '0');
141
reaDLIne(BFMA1ll00,
142
L);
143
for BFMA1lL0I in 1 to 8
144
loop
145
reAD(L,
146
BFMA1o1l1);
147
if BFMA1o1l1 = '1' then
148
BFMA1Oo1lL(V)(8-BFMA1Ll0i) := '1';
149
end if;
150
end loop;
151
V := V+1;
152
BFMA1I0L1 := eNDFile(BFMA1lL00);
153
end loop;
154
FIle_cLOSe(BFMA1ll00);
155
priNTF(" Loaded %d Locations",
156
FMT(V));
157
end if;
158
end if;
159
BFMA1o100 := TRUe;
160
end if;
161
if PREsetn = '0' then
162
BFMA1OooiL := 0;
163
BFMA1lOOIl := 256;
164
BFMA1lloIL := falSE;
165
BFMA1iloiL := 0;
166
BFMA1il1lL := 0;
167
BFMA1Oi1ll := '0';
168
BFMA1L00il <= '0';
169
BFMA1i00Il <= '0';
170
BFMA1i1oIL := 69;
171
BFMA1OOlil := FAlse;
172
BFMA1o10IL <= ( others => '0');
173
exT_data <= ( others => 'Z');
174
elsif Pclk'EVent and pclK = '1' then
175
BFMA1OI1ll := '0';
176
BFMA1I00il <= '0';
177
if pseL = '1' then
178
BFMA1LO1ll := to_INTeger(to_uNSIgneD(pADDr(Paddr'Left downto 2)&"00"));
179
if pseL = '1' and PenabLE = '0' then
180
if BFMA1il1LL >= 256 then
181
BFMA1I1Oil := BFMA1o0lI(BFMA1I1oiL);
182
BFMA1L10il := BFMA1I0Li(BFMA1I1Oil,
183
BFMA1il1LL mod 256);
184
else
185
BFMA1L10il := BFMA1iL1Ll;
186
end if;
187
BFMA1ll1LL := BFMA1L10il-1;
188
if BFMA1l10il = 0 then
189
BFMA1oi1LL := '1';
190
BFMA1LL1ll := 0;
191
end if;
192
end if;
193
if PSel = '1' and PENable = '1'
194
and BFMA1IL1ll > 0 then
195
if BFMA1LL1ll > 0 then
196
BFMA1LL1ll := BFMA1ll1lL-1;
197
elsif BFMA1L00il = '0' then
198
BFMA1oi1lL := '1';
199
if BFMA1IL1ll >= 256 then
200
BFMA1I1Oil := BFMA1o0lI(BFMA1i1oIL);
201
BFMA1ll1LL := BFMA1i0LI(BFMA1i1OIl,
202
BFMA1IL1ll mod 256);
203
else
204
BFMA1LL1ll := BFMA1iL1Ll;
205
end if;
206
else
207
BFMA1OI1ll := '0';
208
end if;
209
end if;
210
if psel = '1' and BFMA1OI1ll = '1' then
211
if BFMA1LLOIl then
212
if BFMA1Iloil > 1 then
213
BFMA1ilOIL := BFMA1ILOil-1;
214
else
215
BFMA1lLOIL := FAlse;
216
BFMA1I00il <= '1';
217
end if;
218
end if;
219
end if;
220
if (peNABle = '1' and PWRite = '1'
221
and BFMA1l00Il = '1') or (exT_wr = '1') then
222
if not (enfuNC > 0 and BFMA1LO1ll >= ENfunc
223
and BFMA1lo1LL < enfUNC+256) then
224
BFMA1oO1Ll(BFMA1Lo1lL+0) := BFMA1OOOll(7 downto 0);
225
BFMA1oo1LL(BFMA1LO1ll+1) := BFMA1OOOLl(15 downto 8);
226
BFMA1oo1lL(BFMA1Lo1lL+2) := BFMA1oooLL(23 downto 16);
227
BFMA1oo1lL(BFMA1lo1LL+3) := BFMA1oooLL(31 downto 24);
228
IfprINTF(BFMA1liiLL >= 1,
229
"APBS:%d Write %04x=%04x ",
230
fmt(ID)&Fmt(BFMA1LO1ll)&Fmt(PwdaTA));
231
BFMA1Oioil := BFMA1lo1LL;
232
BFMA1Lioil := BFMA1oioi(pwdaTA);
233
else
234
if (enfuNC > 0 and BFMA1lo1lL >= enfUNC
235
and BFMA1lo1LL < ENfunC+256) then
236
prinTF("APBS:%d Setting ENFUNC %d %d",
237
FMT(id)&fmt(BFMA1lo1lL-ENfunc)&fmT(pWDAta));
238
case BFMA1Lo1lL-ENfunC is
239
when 0 =>
240
BFMA1lloIL := TRUe;
241
BFMA1ILoil := BFMA1oioi(pwdaTA(7 downto 0));
242
PRintf("APBS: PSLVERR  will be set on the %d access",
243
fmt(BFMA1ILoil));
244
when 4 =>
245
BFMA1iL1Ll := to_iNT_unsIGned(PWdatA(9 downto 0));
246
BFMA1oI1Ll := '1';
247
BFMA1ll1LL := 0;
248
if BFMA1il1LL >= 256 then
249
PrintF("APBS:PREADY timing random 0 to %d cycles",
250
fmT(BFMA1il1LL mod 256));
251
else
252
prINTf("APBS:PREADY timing %d cycles ",
253
fMT(BFMA1IL1ll));
254
end if;
255
when 8 =>
256
BFMA1liiLL <= BFMA1OIoi(PWData(7 downto 0));
257
when 12 =>
258
BFMA1Oo1ll := ( others => ( others => '0'));
259
when 16 =>
260
for BFMA1I0Ii in 0 to dEPTh-1
261
loop
262
BFMA1OO1ll(BFMA1i0iI) := not To_sTD_logIC(TO_unsIGNed(BFMA1I0Ii,
263
32))(7 downto 0);
264
end loop;
265
when 28 =>
266
BFMA1IOOil := BFMA1oooLL;
267
BFMA1oooIL := BFMA1LOoil;
268
when 32 =>
269
BFMA1looiL := BFMA1oioi(pwDATa);
270
when 36 =>
271
BFMA1o100 := fALSe;
272
when 40 =>
273
SprinTF(BFMA1olL1,
274
"image%d.txt",
275
fMT(id));
276
File_Open(BFMA1I000,
277
BFMA1iL00,
278
BFMA1oll1,
279
WritE_Mode);
280
if BFMA1I000 = Open_OK then
281
priNTF("APBS:%d: Dumping to %s",
282
fmt(id)&FMt(BFMA1oll1));
283
else
284
assert FALse report "Logfile open failed" severity faILURe;
285
end if;
286
for BFMA1i0ii in 0 to dEPTh-1
287
loop
288
BFMA1o1iI := ( others => '0');
289
for BFMA1II1l in 0 to 7
290
loop
291
if BFMA1oo1LL(BFMA1I0Ii)(BFMA1Ii1l) = '1' then
292
BFMA1o1iI(BFMA1ii1L) := '1';
293
end if;
294
end loop;
295
SPRintf(BFMA1iol1,
296
"%08b",
297
fmt(BFMA1O1ii));
298
WRIte(l,
299
BFMA1iOL1);
300
WRitelINE(BFMA1il00,
301
L);
302
end loop;
303
File_CLOse(BFMA1iL00);
304
when 52 =>
305
BFMA1oolIL := (pwdATA(0) = '1');
306
PRintF("APBS: Special Mode Enables set to %d",
307
fMT(pWDATa(2 downto 0)));
308
if BFMA1OOlil then
309
BFMA1O10il <= ( others => 'X');
310
else
311
BFMA1o10Il <= ( others => '0');
312
end if;
313
when others =>
314
end case;
315
end if;
316
end if;
317
end if;
318
if Psel = '1' and pwRITe = '0'
319
and BFMA1OI1ll = '1' then
320
BFMA1OL1ll := BFMA1OO1ll(BFMA1LO1ll+3)&BFMA1OO1ll(BFMA1lo1lL+2)&BFMA1OO1ll(BFMA1lo1LL+1)&BFMA1oo1LL(BFMA1lo1LL+0);
321
if not (ENfunc > 0 and BFMA1lo1lL >= enfuNC
322
and BFMA1LO1ll < enFUNc+256) then
323
BFMA1oioIL := BFMA1Lo1lL;
324
BFMA1lIOIl := BFMA1OIoi(BFMA1OL1ll);
325
else
326
case BFMA1LO1ll-enFUNc is
327
when 44 =>
328
BFMA1Ol1ll := to_SLV32(BFMA1oiOIL);
329
when 48 =>
330
BFMA1ol1LL := TO_slV32(BFMA1lioiL);
331
when others =>
332
end case;
333
end if;
334
BFMA1O00il <= BFMA1OL1ll;
335
end if;
336
if pSEL = '1' and PwritE = '0'
337
and PEnablE = '1'
338
and BFMA1l00iL = '1' then
339
IfpriNTF(BFMA1Liill >= 1,
340
"APBS:%d Read %04x=%04x ",
341
fmt(id)&FMT(BFMA1lO1Ll)&fMT(BFMA1OL1ll));
342
end if;
343
end if;
344
BFMA1L00il <= BFMA1OI1ll;
345
if BFMA1OOoil > 1 then
346
BFMA1oooiL := BFMA1OOoil-1;
347
elsif BFMA1OOOil = 1 then
348
BFMA1Oo1ll(enFUNC+28+0) := BFMA1IOOil(7 downto 0);
349
BFMA1oo1LL(eNFUnc+28+1) := BFMA1iooIL(15 downto 8);
350
BFMA1Oo1lL(ENFunc+28+2) := BFMA1iOOIl(23 downto 16);
351
BFMA1oO1Ll(EnfunC+28+3) := BFMA1ioOIL(31 downto 24);
352
BFMA1OOOil := 0;
353
end if;
354
exT_Data <= ( others => 'Z');
355
if exT_en = '1' and exT_rd = '1' then
356
case exT_Size is
357
when 0 =>
358
BFMA1LO1ll := to_inTEGer(tO_UnsigNED(eXT_addR(EXt_adDR'lefT downto 0)));
359
BFMA1Ol1lL := BFMA1o0II(31 downto 8)&BFMA1Oo1ll(BFMA1Lo1lL+0);
360
when 1 =>
361
BFMA1LO1ll := to_INtegER(to_UNsigNED(eXT_addR(Ext_aDDR'leFT downto 1)&'0'));
362
BFMA1oL1Ll := BFMA1O0ii(31 downto 16)&BFMA1OO1ll(BFMA1lO1Ll+1)&BFMA1Oo1ll(BFMA1LO1ll+0);
363
when 2 =>
364
BFMA1lo1lL := to_iNTEger(To_unSIGned(Ext_aDDR(exT_Addr'lefT downto 2)&"00"));
365
BFMA1OL1ll := BFMA1OO1ll(BFMA1LO1ll+3)&BFMA1oo1LL(BFMA1LO1ll+2)&BFMA1oo1LL(BFMA1lO1Ll+1)&BFMA1oo1LL(BFMA1lo1lL+0);
366
end case;
367
iFPRintf(BFMA1lIILl >= 1,
368
"APBS:%d Extension Read %04x=%04x ",
369
fmT(id)&fMT(BFMA1LO1ll)&FMT(BFMA1ol1LL));
370
ext_Data <= BFMA1OL1ll;
371
end if;
372
if ext_En = '1' and EXT_wr = '1' then
373
case EXt_siZE is
374
when 0 =>
375
BFMA1lo1LL := to_iNTEger(to_uNSIgned(ext_ADdr(EXt_adDR'left downto 0)));
376
BFMA1oo1LL(BFMA1Lo1lL+0) := EXT_datA(7 downto 0);
377
when 1 =>
378
BFMA1lo1LL := to_INTeger(TO_unsIGNed(EXT_addR(ext_ADDr'leFT downto 1)&'0'));
379
BFMA1oO1Ll(BFMA1LO1ll+0) := Ext_DATa(7 downto 0);
380
BFMA1oo1LL(BFMA1LO1ll+1) := EXT_datA(15 downto 8);
381
when 2 =>
382
BFMA1lo1lL := to_INTeger(to_UNsignED(exT_Addr(Ext_aDDR'LEFt downto 2)&"00"));
383
BFMA1OO1ll(BFMA1LO1ll+0) := ext_DATa(7 downto 0);
384
BFMA1OO1ll(BFMA1lo1LL+1) := ext_DATa(15 downto 8);
385
BFMA1OO1ll(BFMA1LO1ll+2) := EXT_datA(23 downto 16);
386
BFMA1OO1ll(BFMA1lo1LL+3) := Ext_dATA(31 downto 24);
387
end case;
388
IfprINTf(BFMA1liiLL >= 1,
389
"APBS:%d Extension Write %04x=%04x ",
390
Fmt(id)&FMt(BFMA1lO1Ll)&Fmt(eXT_datA));
391
end if;
392
end if;
393
end process;
394
prdATA <= BFMA1o00Il(dwidTH-1 downto 0) when PenabLE = '1' else
395
BFMA1O10il(dWIDth-1 downto 0) after BFMA1Ol00;
396
prEADy <= BFMA1l00Il after BFMA1ol00;
397
PslveRR <= BFMA1i00IL after BFMA1OL00;
398
process (PWData)
399
begin
400
BFMA1oooLL <= ( others => '0');
401
BFMA1Oooll(DwidTH-1 downto 0) <= pwDATa;
402
end process;
403
BFMA1o0IIl <= penaBLE;
404
BFMA1o1iIL <= PwritE;
405
BFMA1OO0il <= PSel;
406
BFMA1ol0iL <= BFMA1i1oI(Paddr);
407
BFMA1oi0iL <= BFMA1I1Oi(PwdatA);
408
process (Pclk)
409
variable BFMA1IIIil: BOOleaN;
410
begin
411
if PCLk'eveNT and pclK = '1'
412
and PreseTN = '1' then
413
BFMA1l0iIL <= BFMA1o0iIL;
414
BFMA1I0Iil <= BFMA1l0IIl;
415
BFMA1L1iil <= BFMA1O1iil;
416
BFMA1I1Iil <= BFMA1l1iIL;
417
BFMA1LO0il <= BFMA1OO0il;
418
BFMA1IO0il <= BFMA1LO0il;
419
BFMA1ll0iL <= BFMA1OL0il;
420
BFMA1iL0Il <= BFMA1LL0il;
421
BFMA1LI0il <= BFMA1oi0IL;
422
BFMA1ii0IL <= BFMA1li0IL;
423
BFMA1IIIil := fALSe;
424
if BFMA1o0IIl = '1' and BFMA1oo0IL = '1' then
425
if BFMA1OL0il /= BFMA1LL0il then
426
pRINtf("APM:%d Address not stable in both cycles",
427
Fmt(id));
428
BFMA1iIIil := true;
429
end if;
430
if BFMA1o1IIL /= BFMA1L1iiL then
431
pRINtf("APM:%d PWRITE not stable in both cycles",
432
fmT(id));
433
BFMA1IIIil := tRUE;
434
end if;
435
if BFMA1Oo0il /= BFMA1lo0IL then
436
PrintF("APM:%d PSEL not stable in both cycles",
437
fmt(Id));
438
BFMA1iiiIL := true;
439
end if;
440
if BFMA1oI0Il /= BFMA1Li0iL and BFMA1o1IIL = '1' then
441
PrinTF("APM:%d PWDATA not stable in both cycles",
442
fMT(iD));
443
BFMA1iiiIL := TRUe;
444
end if;
445
if BFMA1LO0il /= '1' then
446
pRINtf("APM:%d PSEL was not active in cycle before PENABLE",
447
FMT(ID));
448
BFMA1iiiiL := tRUE;
449
end if;
450
end if;
451
if BFMA1IIIil then
452
assert fALSE report "APB Protocol violation" severity ERRor;
453
end if;
454
end if;
455
end process;
456
end BFMA1IO1ol;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.