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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
| --------------------marchC- algorithm code and test bench-------------
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity marchcfor2elements is
Port ( test_h,clk,rst_l : in STD_LOGIC;
data_in_ora:in std_logic_vector(3 downto 0);
ta : out STD_LOGIC_VECTOR (5 downto 0);
td : out STD_LOGIC_VECTOR (3 downto 0);
twen,tcen,compare_q,test_done,test_phase : out std_logic);
end marchcfor2elements;
architecture Behavioral of marchcfor2elements is
signal s:std_logic_vector(5 downto 0):=(others=>'0');
signal march:std_logic_vector(2 downto 0):="001";
signal op:std_logic;
begin
process(clk)
begin
if (rst_l='0')then
ta<="000000";
td<="0000";
tcen<='0';
twen<='0';
elsif(clk'event and clk='1')then
if(test_h='1')then
test_phase<='1';
if(march="001")then --march element1 up(w0)
ta<=s;
td<="0000";
twen<='1';
tcen<='1';
if(s="111111") then
march<="010";
s<="000000";
op<='0';
else
s<=s+'1';
end if;
elsif(march="010")then --march element2 up(r0,w1)
if(s="111111")then
if(op='0')then
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="1111";
twen<='1';
tcen<='1';
march<="011";
s<="000000";
op<='0';
end if;
else
if(op='0')then
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="1111";
twen<='1';
tcen<='1';
op<='0';
s<=s+'1';
end if;
end if;
elsif(march="011")then --march element3 up(r1,w0)
if(s="111111")then
if(op='0')then
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="0000";
twen<='1';
tcen<='1';
march<="100";
op<='0';
end if;
else
if(op='0')then
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="0000";
twen<='1';
tcen<='1';
op<='0';
s<=s+'1';
end if; -- op
end if; -- s
elsif(march="100")then --march element4 down(r0,w1)
if(s="000000")then
if(op='0')then
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="1111";
twen<='1';
tcen<='1';
op<='0';
march<="101";
s<="111111";
op<='0';
end if;
end if;
if(op='0')then
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="1111";
twen<='1';
tcen<='1';
op<='0';
s<=s-'1';
end if;
elsif(march="101")then --march element5 down(r1,w0)
if(s="000000")then
if(op='0')then --some doubt elsif or if?
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="0000";
twen<='1';
tcen<='1';
march<="110";
s<="111111";
op<='0';
end if;
end if;
if(op='0')then --some doubt elsif or if?
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
elsif(op='1')then
ta<=s;
td<="0000";
twen<='1';
tcen<='1';
op<='0';
s<=s-'1';
end if;
elsif(march="110")then --march element6 down(r0)
if(s="000000")then
march<="111";
end if;
ta<=s;
td<="XXXX";
twen<='0';
tcen<='1';
op<='1';
s<=s-'1';
elsif(march="111")then
test_done<='1';
else
test_done<='0';
end if; --march
end if; --test_h
end if; --rstl
end process;
--comparing :ORA part in BIST
process(data_in_ora,march)
begin
if(march="010")then
if(op='1')then
if(data_in_ora="0000")then
compare_q<='0';
else
compare_q<='1';
end if;
end if;
elsif(march="011")then
if(op='1')then
if(data_in_ora="1111")then
compare_q<='0';
else
compare_q<='1';
end if;
end if;
elsif(march="100")then
if(op='1')then
if(data_in_ora="0000")then
compare_q<='0';
else
compare_q<='1';
end if;
end if;
elsif(march="101")then
if(op='1')then
if(data_in_ora="1111")then
compare_q<='0';
else
compare_q<='1';
end if;
end if;
elsif(march="110")then
if(op='1')then
if(data_in_ora="0000")then
compare_q<='0';
else
compare_q<='1';
end if;
end if;
end if;
end process;
end Behavioral;
------------testbench------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;
ENTITY tb_marchcfor2elements_vhd IS
END tb_marchcfor2elements_vhd;
ARCHITECTURE behavior OF tb_marchcfor2elements_vhd IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT marchcfor2elements
PORT(
test_h : IN std_logic;
clk : IN std_logic;
rst_l : IN std_logic;
data_in_ora : IN std_logic_vector(3 downto 0);
ta : OUT std_logic_vector(5 downto 0);
td : OUT std_logic_vector(3 downto 0);
twen : OUT std_logic;
tcen : OUT std_logic;
compare_q : OUT std_logic;
test_done : OUT std_logic;
test_phase : OUT std_logic
);
END COMPONENT;
--Inputs
SIGNAL test_h : std_logic := '0';
SIGNAL clk : std_logic := '0';
SIGNAL rst_l : std_logic := '0';
SIGNAL data_in_ora : std_logic_vector(3 downto 0) := (others=>'0');
--Outputs
SIGNAL ta : std_logic_vector(5 downto 0);
SIGNAL td : std_logic_vector(3 downto 0);
SIGNAL twen : std_logic;
SIGNAL tcen : std_logic;
SIGNAL compare_q : std_logic;
SIGNAL test_done : std_logic;
SIGNAL test_phase : std_logic;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: marchcfor2elements PORT MAP(
test_h => test_h,
clk => clk,
rst_l => rst_l,
data_in_ora => data_in_ora,
ta => ta,
td => td,
twen => twen,
tcen => tcen,
compare_q => compare_q,
test_done => test_done,
test_phase => test_phase
);
clk<=not clk after 20 ns;
rst_l<='1';
test_h<='1';
tb : PROCESS
BEGIN
data_in_ora<="1010"; -- Wait 100 ns for global reset to finish
wait for 2677.4 ns;
data_in_ora<="0000";
wait for 100 ns;
data_in_ora<="1100";
-- Place stimulus here
wait; -- will wait forever
END PROCESS;
END;
-----------------biaa code and testbench-------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity biaa is
Port ( compare_q,test_phase,bisr_h,test_h : in STD_LOGIC;
ta,bisr_a : in STD_LOGIC_VECTOR (5 downto 0);
over_h_reg,fail: out STD_LOGIC;
biaa_out_ad : out STD_LOGIC_VECTOR (5 downto 0));
end biaa;
architecture Behavioral of biaa is
type fault_a_mem is array(0 to 5)of std_logic_vector(5 downto 0);
signal fa_ptr:fault_a_mem;
type repair_mem is array(0 to 5)of std_logic_vector(5 downto 0);
signal rep_ptr:repair_mem;
signal address:std_logic_vector(2 downto 0):=(others=>'0');
signal count:std_logic_vector(2 downto 0):="000";
signal c:std_logic;
begin
rep_ptr(0)<=conv_std_logic_vector(63,6);
rep_ptr(1)<=conv_std_logic_vector(62,6);
rep_ptr(2)<=conv_std_logic_vector(61,6);
rep_ptr(3)<=conv_std_logic_vector(60,6);
rep_ptr(4)<=conv_std_logic_vector(59,6);
rep_ptr(5)<=conv_std_logic_vector(58,6);
process(compare_q,test_h,bisr_h)
begin
if(compare_q='1')then
fa_ptr(conv_integer(address))<=ta;
address<=address+'1';
if(address="000101")then
fa_ptr(conv_integer(address))<=ta;
address<="000";
over_h_reg<='1';
end if;
end if;
--if(commpare_q='0')then
if(test_h='0')then --normal operation without testing and repairing
if(bisr_h='0')then
biaa_out_ad<=bisr_a;
elsif(bisr_h='1')then --repairing operation
for i in 0 to 5 loop
if(bisr_a=fa_ptr(i))then
biaa_out_ad<=rep_ptr(i);
else
biaa_out_ad<=bisr_a;
end if;
end loop;
end if;
end if;
if(test_h='1')then --testing without repairing
if(bisr_h='0')then
for i in 0 to 5 loop
if (bisr_a=fa_ptr(i))then
biaa_out_ad<=fa_ptr(i);
else
biaa_out_ad<=bisr_a;
end if;
end loop;
elsif(bisr_h='1')then --testing redundancy locations
for i in 0 to 5 loop
if(bisr_a=rep_ptr(i))then
fail<='1';
else
fail<='0';
end if;
end loop;
end if;
end if;
--end if;
--end if;
end process;
end Behavioral;
----testbench-------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;
USE ieee.std_logic_arith.ALL;
ENTITY tb_biaa_vhd IS
END tb_biaa_vhd;
ARCHITECTURE behavior OF tb_biaa_vhd IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT biaa
PORT(
compare_q : IN std_logic;
test_phase : IN std_logic;
bisr_h : IN std_logic;
test_h : IN std_logic;
ta : IN std_logic_vector(5 downto 0);
bisr_a : IN std_logic_vector(5 downto 0);
over_h_reg : OUT std_logic;
fail : OUT std_logic;
biaa_out_ad : OUT std_logic_vector(5 downto 0)
);
END COMPONENT;
--Inputs
SIGNAL compare_q : std_logic := '0';
SIGNAL test_phase : std_logic := '0';
SIGNAL bisr_h : std_logic := '0';
SIGNAL test_h : std_logic := '0';
SIGNAL ta : std_logic_vector(5 downto 0) := (others=>'0');
SIGNAL bisr_a : std_logic_vector(5 downto 0) := (others=>'0');
--Outputs
SIGNAL over_h_reg : std_logic;
SIGNAL fail : std_logic;
SIGNAL biaa_out_ad : std_logic_vector(5 downto 0);
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: biaa PORT MAP(
compare_q => compare_q,
test_phase => test_phase,
bisr_h => bisr_h,
test_h => test_h,
ta => ta,
bisr_a => bisr_a,
over_h_reg => over_h_reg,
fail => fail,
biaa_out_ad => biaa_out_ad
);
--compare_q<=not compare_q after 10 ns;
--compare_q<='1';
tb : PROCESS
BEGIN
compare_q<='1';
ta<=conv_std_logic_vector(50,6);
wait for 10 ns;
ta<=conv_std_logic_vector(30,6);
wait for 10 ns;
ta<=conv_std_logic_vector(20,6);
wait for 10 ns;
ta<=conv_std_logic_vector(10,6);
wait for 10 ns;
ta<=conv_std_logic_vector(11,6);
wait for 10 ns;
ta<=conv_std_logic_vector(12,6);
wait for 10 ns;
compare_q<='0';
test_h<='0';
bisr_h<='0';
bisr_a<=conv_std_logic_vector(12,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(22,6);
wait for 10 ns;
bisr_h<='1';
bisr_a<=conv_std_logic_vector(50,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(30,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(19,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(11,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(18,6);
wait for 10 ns;
test_h<='1';
bisr_h<='0';
bisr_a<=conv_std_logic_vector(25,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(35,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(50,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(30,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(29,6);
wait for 10 ns;
bisr_h<='1';
bisr_a<=conv_std_logic_vector(62,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(57,6);
wait for 10 ns;
bisr_a<=conv_std_logic_vector(53,6);
wait for 10 ns;
----end if;
END PROCESS;
END;
----------main module--------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity interfacing1 is
Port ( test_h,clk,rst_l : in STD_LOGIC;
na : in STD_LOGIC_VECTOR (5 downto 0);
nd : in STD_LOGIC_VECTOR (3 downto 0);
nwen : in STD_LOGIC;
ncen : in STD_LOGIC;
data_out_q : out STD_LOGIC_VECTOR (3 downto 0);
compare_q ,test_done: out STD_LOGIC);
end interfacing1;
architecture Behavioral of interfacing1 is
signal bm_ta,mm_ad :std_logic_vector(5 downto 0);
signal bm_td,mm_data,mb_data :std_logic_vector(3 downto 0);
signal bm_twen,bm_tcen,mm_wen,mm_cen: std_logic;
component mux_main
Port ( NA,TA : in STD_LOGIC_VECTOR (5 downto 0);
ND,TD : in STD_LOGIC_VECTOR (3 downto 0);
NWEN,TWEN,NCEN,TCEN,test_h : in STD_LOGIC;
address_out : out STD_LOGIC_VECTOR (5 downto 0);
data_out : out STD_LOGIC_VECTOR (3 downto 0);
wen_out,cen_out : out STD_LOGIC);
end component;
component memory
Port ( address : in STD_LOGIC_VECTOR (5 downto 0);
data_in : in STD_LOGIC_VECTOR (3 downto 0);
wen,cen,clk : in STD_LOGIC;
data_out_q : out STD_LOGIC_VECTOR (3 downto 0));
end component;
component march_c_1
Port ( test_h,clk,rst_l : in STD_LOGIC;
data_in_ora:in std_logic_vector(3 downto 0);
ta : out STD_LOGIC_VECTOR (5 downto 0);
td : out STD_LOGIC_VECTOR (3 downto 0);
twen,tcen,compare_q,test_done : out STD_LOGIC);
end component;
begin
m1:mux_main port map(na=>na,nd=>nd,nwen=>nwen,ncen=>ncen,
ta=>bm_ta,td=>bm_td,twen=>bm_twen,tcen=>bm_tcen,
test_h=>test_h,
address_out=>mm_ad,data_out=>mm_data,
wen_out=>mm_wen,cen_out=>mm_cen);
--m1:mux_main port map(na,bm_ta,nd,bm_td,nwen,bm_twen,ncen,bm_tcen,test_h,mm_ad,mm_data,mm_wen,mm_cen);
--mem:memory port map(mm_ad,mm_data,mm_wen,mm_cen,clk,mb_data);
--mar:march_c_1 port map(test_h,clk,rst_l,mb_data,bm_ta,bm_td,bm_twen,bm_tcen,compare_q);
mem:memory port map(address=>mm_ad,data_in=>mm_data,wen=>mm_wen,cen=>mm_cen,
clk=>clk,data_out_q=>mb_data);
mar:march_c_1 port map(test_h=>test_h,clk=>clk,rst_l=>rst_l,
data_in_ora=> mb_data,
compare_q=>compare_q,test_done=>test_done,
ta=>bm_ta,td=>bm_td,twen=>bm_twen,tcen=>bm_tcen);
end Behavioral;
-testbench------------to test only test_h=1,bisr_h=0
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
USE ieee.numeric_std.ALL;
USE ieee.std_logic_arith.ALL;
ENTITY tb_interfacing1_vhd IS
END tb_interfacing1_vhd;
ARCHITECTURE behavior OF tb_interfacing1_vhd IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT interfacing1
PORT(
test_h : IN std_logic;
clk : IN std_logic;
rst_l : IN std_logic;
na : IN std_logic_vector(5 downto 0);
nd : IN std_logic_vector(3 downto 0);
nwen : IN std_logic;
ncen : IN std_logic;
data_out_q : OUT std_logic_vector(3 downto 0);
compare_q : OUT std_logic;
test_done:out std_logic
);
END COMPONENT;
--Inputs
SIGNAL test_h : std_logic := '0';
SIGNAL clk : std_logic := '0';
SIGNAL rst_l : std_logic := '0';
SIGNAL nwen : std_logic := '0';
SIGNAL ncen : std_logic := '0';
SIGNAL na : std_logic_vector(5 downto 0) := (others=>'0');
SIGNAL nd : std_logic_vector(3 downto 0) := (others=>'0');
--Outputs
SIGNAL data_out_q : std_logic_vector(3 downto 0);
SIGNAL compare_q : std_logic;
SIGNAL test_done : std_logic;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: interfacing1 PORT MAP(
test_h => test_h,
clk => clk,
rst_l => rst_l,
na => na,
nd => nd,
nwen => nwen,
ncen => ncen,
data_out_q => data_out_q,
compare_q => compare_q,
test_done=>test_done
);
clk<=not clk after 10 ns;
tb : PROCESS
BEGIN
--rst_l<='0';
--wait for 10 ns;
test_h<='1';
rst_l<='1';
wait for 10 ns;
if(test_done='1')then
test_h<='0';
na<=conv_std_logic_vector(15,6);
nd<="0100";
nwen<='1';
ncen<='1';
wait for 20 ns;
nwen<='0';
na<=conv_std_logic_vector(3,6);
wait for 20 ns;
na<=conv_std_logic_vector(15,6);
wait for 20 ns;
na<=conv_std_logic_vector(6,6);
wait for 20 ns;
end if;
END PROCESS;
END; |