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

Subversion Repositories aoocs

[/] [aoocs/] [trunk/] [tests/] [tb_ocs_floppy.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
`timescale 10ns / 1ns
2
 
3
module tb_ocs_floppy();
4
 
5
reg clk_30;
6
reg reset_n;
7
 
8
reg [31:0] master_DAT_I;
9
reg ACK_I;
10
wire CYC_O;
11
wire STB_O;
12
wire WE_O;
13
wire [31:2] ADR_O;
14
wire [3:0] SEL_O;
15
wire [31:0] master_DAT_O;
16
 
17
reg CYC_I;
18
reg STB_I;
19
reg WE_I;
20
reg [8:2] ADR_I;
21
reg [3:0] SEL_I;
22
reg [31:0] slave_DAT_I;
23
wire ACK_O;
24
 
25
reg na_dskbytr_read;
26
wire [15:0] na_dskbytr;
27
 
28
reg fl_mtr_n;
29
reg [3:0] fl_sel_n;
30
reg fl_side_n;
31
reg fl_dir;
32
reg fl_step_n;
33
 
34
wire floppy_blk_irq;
35
 
36
reg buffer_CYC_I;
37
reg buffer_STB_I;
38
reg buffer_WE_I;
39
reg [13:2] buffer_ADR_I;
40
reg [3:0] buffer_SEL_I;
41
reg [31:0] buffer_DAT_I;
42
wire buffer_ACK_O;
43
 
44
reg line_start;
45
 
46
ocs_floppy ocs_floppy_inst(
47
    .clk_30(clk_30),
48
    .reset_n(reset_n),
49
 
50
    // line counter
51
    .line_start(line_start),
52
 
53
    // management
54
    .floppy_inserted(1'b1),
55
    .floppy_sector(32'd600),
56
    .floppy_error(),
57
 
58
    // WISHBONE master
59
    .CYC_O(CYC_O),
60
    .STB_O(STB_O),
61
    .WE_O(WE_O),
62
    .ADR_O(ADR_O),
63
    .SEL_O(SEL_O),
64
    .master_DAT_O(master_DAT_O),
65
    .master_DAT_I(master_DAT_I),
66
    .ACK_I(ACK_I),
67
 
68
    // WISHBONE slave
69
    .CYC_I(CYC_I),
70
    .STB_I(STB_I),
71
    .WE_I(WE_I),
72
    .ADR_I(ADR_I),
73
    .SEL_I(SEL_I),
74
    .slave_DAT_I(slave_DAT_I),
75
    .ACK_O(ACK_O),
76
 
77
    // WISHBONE slave floppy buffer
78
    .buffer_CYC_I(buffer_CYC_I),
79
    .buffer_STB_I(buffer_STB_I),
80
    .buffer_WE_I(buffer_WE_I),
81
    .buffer_ADR_I(buffer_ADR_I),
82
    .buffer_SEL_I(buffer_SEL_I),
83
    .buffer_DAT_I(buffer_DAT_I),
84
    .buffer_DAT_O(),
85
    .buffer_ACK_O(buffer_ACK_O),
86
 
87
    // dma enable
88
    .dma_con(16'hFFFF),
89
    .adk_con(16'hFFFF),
90
 
91
    .floppy_syn_irq(),
92
    .floppy_blk_irq(floppy_blk_irq),
93
 
94
    // Not Aligned address support
95
        // DSKBYTR read not implemented here
96
    .na_dskbytr_read(na_dskbytr_read),
97
    .na_dskbytr(na_dskbytr),
98
 
99
    // floppy CIA interface
100
    .fl_rdy_n(),
101
    .fl_tk0_n(),
102
    .fl_wpro_n(),
103
    .fl_chng_n(),
104
    .fl_index_n(),
105
 
106
    .fl_mtr_n(fl_mtr_n),
107
    .fl_sel_n(fl_sel_n),
108
    .fl_side_n(fl_side_n),
109
    .fl_dir(fl_dir),
110
    .fl_step_n(fl_step_n),
111
 
112
    .floppy_debug(),
113
    .track_debug()
114
);
115
 
116
initial begin
117
    clk_30 = 1'b0;
118
    forever #5 clk_30 = ~clk_30;
119
end
120
 
121
initial begin
122
    line_start = 1'b0;
123
    forever begin
124
        #500 line_start = 1'b1;
125
        #10 line_start = 1'b0;
126
    end
127
end
128
 
129
integer start_sd;
130
integer f,cnt,res;
131
reg [31:0] mfm_contents [0:1023];
132
initial begin
133
        f = $fopenr("/home/alek/1.txt");
134
        for(cnt=0; cnt<543; cnt=cnt+1) begin
135
                res = $fscanf(f, "%x", mfm_contents[cnt]);
136
        end
137
        $fclose(f);
138
 
139
        $display("%x", mfm_contents[0]);
140
        $display("%x", mfm_contents[1]);
141
 
142
 
143
    ACK_I <= 1'b0;
144
    master_DAT_I <= 32'd3;
145
    start_sd = 0;
146
 
147
    forever begin
148
        #20
149
        if(CYC_O == 1'b1 && STB_O == 1'b1) begin
150
            if(ADR_O == 30'h04000403) start_sd = 1;
151
 
152
                        if(ADR_O == 30'h04000400 && WE_O == 1'b0) begin
153
                                master_DAT_I <= 32'd2;
154
                        end
155
                        else if(WE_O == 1'b0) begin
156
                                master_DAT_I <= mfm_contents[ADR_O[11:2]];
157
                        end
158
            ACK_I <= 1'b1;
159
            #10
160
            ACK_I <= 1'b0;
161
        end
162
    end
163
end
164
 
165
//buffer_ACK_O
166
integer bi;
167
//integer f,res;
168
initial begin
169
 
170
    //f = $fopenr("tb_ocs_floppy_sector.txt");
171
    //res = $fscanf(f, "%x", buffer_DAT_I);
172
 
173
    buffer_CYC_I = 0;
174
    buffer_STB_I = 0;
175
    buffer_WE_I = 1;
176
    buffer_ADR_I = 0;
177
    buffer_SEL_I = 4'b1111;
178
    buffer_DAT_I = 0;
179
    bi = 0;
180
 
181
    while(start_sd == 1'b0) begin
182
        #10;
183
    end
184
    #5
185
    #100
186
    for(bi=0; bi<1408; bi=bi+1) begin
187
        #250
188
                buffer_CYC_I = 1;
189
        buffer_STB_I = 1;
190
        buffer_ADR_I = bi;
191
 
192
        while(buffer_ACK_O == 1'b0) begin
193
            #10;
194
        end
195
        buffer_CYC_I = 0;
196
        buffer_STB_I = 0;
197
    end
198
end
199
 
200
initial begin
201
    $dumpfile("tb_ocs_floppy.vcd");
202
    $dumpvars(0);
203
    $dumpon();
204
 
205
    reset_n = 1'b0;
206
    ACK_I = 1'b0;
207
    #10 reset_n = 1'b1;
208
 
209
    #10
210
    fl_mtr_n = 1'b0;
211
    fl_sel_n = 4'b1111;
212
    fl_side_n = 1'b1;
213
    fl_dir = 1'b1;
214
    fl_step_n = 1'b1;
215
 
216
    #10
217
    fl_sel_n = 4'b1110;
218
 
219
    #500000
220
 
221
    CYC_I = 1;
222
    STB_I = 1;
223
    WE_I = 1;
224
    ADR_I = 31;
225
    SEL_I = 4'b1111;
226
    slave_DAT_I = 32'h00004489;
227
 
228
    while(ACK_O == 1'b0) #10;
229
 
230
    CYC_I = 0;
231
    STB_I = 0;
232
 
233
    #30
234
 
235
    CYC_I = 1;
236
    STB_I = 1;
237
    WE_I = 1;
238
    ADR_I = 9;
239
    SEL_I = 4'b1111;
240
    slave_DAT_I = 32'hD7790000;
241
 
242
    while(ACK_O == 1'b0) #10;
243
 
244
    CYC_I = 0;
245
    STB_I = 0;
246
 
247
    #30
248
 
249
    CYC_I = 1;
250
    STB_I = 1;
251
    WE_I = 1;
252
    ADR_I = 9;
253
    SEL_I = 4'b1111;
254
    slave_DAT_I = 32'hD7790000;
255
 
256
    while(ACK_O == 1'b0) #10;
257
 
258
    CYC_I = 0;
259
    STB_I = 0;
260
 
261
    #200000
262
 
263
 
264
    $finish();
265
end
266
 
267
endmodule
268
 

powered by: WebSVN 2.1.0

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