-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidador_tb.v
172 lines (125 loc) · 3.03 KB
/
Validador_tb.v
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
module Validador_tb;
reg enable,clk,direcao,jogador;
reg [2:0] tipo;
reg [2:0] orientacao;
reg [3:0] x1;
reg [3:0] y1;
reg [63:0] vetor_leitura;
reg [63:0] memoriaVectorJogadorUm[10:0]; // Memoria para jogador Um
reg [63:0] memoriaVectorJogadorDois[10:0]; //Memoria para jogador Dois
wire conflitoMemoria_out;
wire conflitoBorda_out;
wire conflito;
wire wrep1;
wire wrep2;
wire [63:0]vetor;
wire [4:0] write_addr; //Endereco para armazenar na memoria
wire [4:0] read_addr; // contaria as 11 posicoes verificando se ha conlfito de posições na memoria
wire ready;
Validador validador(
//input
.enable(enable),
.tipo(tipo),
.direcao(direcao),
.orientacao(orientacao),
.x1(x1),
.y1(y1),
.clk(clk),
.jogador(jogador),
.vetor_leitura(vetor_leitura),
//output
.ready(ready),
.conflitoMemoria_out(conflitoMemoria_out),
.conflitoBorda_out(conflitoBorda_out),
.wrep1(wrep1),
.wrep2(wrep2),
.vetor(vetor),
.read_addr(read_addr),
.write_addr(write_addr),
.conflito(conflito)
);
initial
begin
clk =0;
enable =0;
forever #10 clk = !clk;
end
initial
begin
//***** _Primeiro Teste de Bordas) *******
$display("Iserção do porta avião em 7,0");
tipo = 1'b0;
direcao = 1'b0;
orientacao = 1'b0;
x1 = 4'd7;
y1 = 4'b0;
jogador = 1'b0;
vetor_leitura = 64'b0;
#100 enable = 1;
//***** _Primeiro Teste de Memoria) *******
#200 enable = 0;
$display("Iserção do porta avião em 0,0");
tipo = 1'b0;
direcao = 1'b0;
orientacao = 1'b0;
x1 = 4'b1;
y1 = 4'b1;
jogador = 1'b0;
vetor_leitura = 64'b0;
#500 enable = 1;
//simulando conflito de memoria com a peça anterior
#500 enable = 0;
$display("Iserção do porta avião em 0,0");
tipo = 1'b1;
direcao = 1'b0;
orientacao = 1'b0;
x1 = 4'b1;
y1 = 4'b1;
jogador = 1'b0;
//vetor_leitura = 64'b0000000000000000001010001010100010100000100110001001000010001000;
//simulação de sisercao das 12 posicoes
#500 enable = 1;
#500 enable = 0;
$display("Iserção do porta avião em 0,0");
tipo = 2'b10;
direcao = 1'b0;
orientacao = 1'b0;
x1 = 4'd3;
y1 = 4'd3;
jogador = 1'b0;
//vetor_leitura = 64'b0000000000000000001010001010100010100000100110001001000010001000;
#500 enable = 1;
//simulação de sisercao das 12 posicoes
if (validador.auxGravou == 1) begin
$display("Teste essa aquiiiddddi");
end
#100 enable = 1;
//comentea
end
/*
***************************************************
* Always que simula a escrita na memoria *
***************************************************
*/
always
begin
#10
if(wrep1)
begin
memoriaVectorJogadorUm[write_addr] = vetor;
end
if (wrep2) begin
memoriaVectorJogadorDois[write_addr] = vetor;
end
end
/*
***************************************************
* Always que simula a leitura da memoria *
***************************************************
*/
always
begin
#10
vetor_leitura = memoriaVectorJogadorUm[read_addr];
end
endmodule