OpenCores
URL https://opencores.org/ocsvn/mjpeg-decoder/mjpeg-decoder/trunk

Subversion Repositories mjpeg-decoder

[/] [mjpeg-decoder/] [trunk/] [mjpeg/] [pcores/] [myipif/] [hdl/] [vhdl/] [myipif.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 smanz
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
 
6
 
7
entity myipif is
8
  generic
9
    (
10
      C_BASEADDR   : std_logic_vector := X"50000000";
11
      C_HIGHADDR   : std_logic_vector := X"5000FFFF";
12
      C_OPB_AWIDTH : integer          := 32;
13
      C_OPB_DWIDTH : integer          := 32;
14
      C_FAMILY     : string           := "virtex2p";
15
      C_SDRAM_ADDR : std_logic_vector := X"00000000"
16
    );
17
  port
18
    (
19
      OPB_Clk      : in  std_logic;
20
      OPB_Rst      : in  std_logic;
21
      -- slave
22
      Sl_DBus      : out std_logic_vector(0 to C_OPB_DWIDTH-1);
23
      Sl_errAck    : out std_logic;
24
      Sl_retry     : out std_logic;
25
      Sl_toutSup   : out std_logic;
26
      Sl_xferAck   : out std_logic;
27
      OPB_ABus     : in  std_logic_vector(0 to C_OPB_AWIDTH-1);
28
      OPB_BE       : in  std_logic_vector(0 to C_OPB_DWIDTH/8-1);
29
      OPB_DBus     : in  std_logic_vector(0 to C_OPB_DWIDTH-1);
30
      OPB_RNW      : in  std_logic;
31
      OPB_select   : in  std_logic;
32
      OPB_seqAddr  : in  std_logic;
33
      -- master
34
      M_ABus       : out std_logic_vector(0 to C_OPB_AWIDTH-1);
35
      M_BE         : out std_logic_vector(0 to C_OPB_DWIDTH/8-1);
36
      M_busLock    : out std_logic;
37
      M_request    : out std_logic;
38
      M_RNW        : out std_logic;
39
      M_select     : out std_logic;
40
      M_seqAddr    : out std_logic;
41
      OPB_errAck   : in  std_logic;
42
      OPB_MGrant   : in  std_logic;
43
      OPB_retry    : in  std_logic;
44
      OPB_timeout  : in  std_logic;
45
      OPB_xferAck  : in  std_logic;
46
 
47
      LEDs         : out std_logic_vector(3 downto 0);
48
                BUTTONs      : in std_logic_vector(4 downto 0); -- 0:left, 1:right, 2:up, 3:down, 4:center
49
                SWITCHEs     : in std_logic_vector(3 downto 0);
50
 
51
                VGA_OUT_PIXEL_CLOCK:    out STD_LOGIC;
52
                VGA_COMP_SYNCH:                         out STD_LOGIC;
53
                VGA_OUT_BLANK_Z:                        out STD_LOGIC;
54
                VGA_HSYNCH:                             out STD_LOGIC;
55
                VGA_VSYNCH:                             out STD_LOGIC;
56
                VGA_OUT_RED:                            out STD_LOGIC_VECTOR (7 downto 0);
57
                VGA_OUT_GREEN:                  out STD_LOGIC_VECTOR (7 downto 0);
58
                VGA_OUT_BLUE:                           out STD_LOGIC_VECTOR (7 downto 0)
59
    );
60
end entity myipif;
61
 
62
 
63
 
64
architecture IMP of myipif is
65
 
66
 
67
-- **********************************************************************************************
68
-- * Components
69
-- **********************************************************************************************
70
 
71
--------------------------------------------------------------
72
---- Chipscope Stuff
73
--------------------------------------------------------------
74
--      component icon
75
--      port (
76
--              control0    :   out std_logic_vector(35 downto 0));
77
--      end component;
78
--      
79
--      component ila
80
--      port(
81
--              control     : in    std_logic_vector(35 downto 0);
82
--              clk         : in    std_logic;
83
--              trig0       : in    std_logic_vector(127 downto 0));
84
--      end component;
85
--  
86
--      signal control0 : std_logic_vector(35 downto 0);
87
--      signal trig0            : std_logic_vector(127 downto 0);
88
------------------------------------------------------------
89
 
90
 
91
 
92
--------------------------------------------------------------
93
-- JPEG - Decoder
94
--------------------------------------------------------------
95
component jpeg is
96
  port(
97
        Clk                     :  in std_logic;
98
                data_i          :  in std_logic_vector(31 downto 0);
99
                reset_i         :  in std_logic;
100
 
101
                eoi_o                   : out std_logic;
102
                error_o         : out std_logic;
103
 
104
                context_o       : out std_logic_vector (3 downto 0);
105
                red_o                   : out STD_LOGIC_VECTOR (7 downto 0);
106
                green_o         : out STD_LOGIC_VECTOR (7 downto 0);
107
                blue_o          : out STD_LOGIC_VECTOR (7 downto 0);
108
                width_o         : out std_logic_vector(15 downto 0);
109
                height_o                : out std_logic_vector(15 downto 0);
110
                sampling_o      : out std_logic_vector( 1 downto 0);
111
 
112
--              -- debug
113
--      LEDs                    : out std_logic_vector(3 downto 0);
114
--              BUTTONs         :  in std_logic_vector(4 downto 0); -- 0:left, 1:right, 2:up, 3:down, 4:center
115
--              SWITCHEs                :  in std_logic_vector(3 downto 0);
116
--              -- chipscope-debugging
117
--              chipscope_o     : out std_logic_vector(127 downto 0);
118
--
119
                -- flow controll
120
                datavalid_i :  in std_logic;
121
                datavalid_o : out std_logic;
122
                ready_i         :  in std_logic;
123
                ready_o         : out std_logic
124
    );
125
end component jpeg;
126
------------------------------------------------------------
127
 
128
 
129
 
130
------------------------------------------------------------
131
-- VGA-handling
132
------------------------------------------------------------
133
component vga is
134
        port(
135
                Clk                     : in std_logic;
136
                reset_i         : in std_logic;
137
                eoi_i                   : in std_logic;
138
 
139
                red_i           : in STD_LOGIC_VECTOR (7 downto 0);
140
                green_i         : in  STD_LOGIC_VECTOR (7 downto 0);
141
                blue_i          : in  STD_LOGIC_VECTOR (7 downto 0);
142
                width_i         : in  std_logic_vector(15 downto 0);
143
                height_i                : in  std_logic_vector(15 downto 0);
144
                sampling_i      : in  std_logic_vector( 1 downto 0);
145
 
146
                VGA_OUT_PIXEL_CLOCK:    out STD_LOGIC;
147
                VGA_COMP_SYNCH:                         out STD_LOGIC;
148
                VGA_OUT_BLANK_Z:                        out STD_LOGIC;
149
                VGA_HSYNCH:                             out STD_LOGIC;
150
                VGA_VSYNCH:                             out STD_LOGIC;
151
                VGA_OUT_RED:                            out STD_LOGIC_VECTOR (7 downto 0);
152
                VGA_OUT_GREEN:                  out STD_LOGIC_VECTOR (7 downto 0);
153
                VGA_OUT_BLUE:                           out STD_LOGIC_VECTOR (7 downto 0);
154
 
155
--              -- chipscope-debugging
156
--              chipscope_o     : out std_logic_vector(127 downto 0);
157
 
158
                -- flow controll
159
                datavalid_i :  in std_logic;
160
                ready_o         : out std_logic
161
        );
162
end component vga;
163
------------------------------------------------------------
164
 
165
 
166
-- **********************************************************************************************
167
-- * Signals
168
-- ********************************************************************************************** 
169
  type OPB_states is (idle, MasterRead1, MasterRead2);
170
  signal OPB_state, OPB_next_state: OPB_states := idle;
171
 
172
  signal Sl_DBus_D      : std_logic_vector(0 to C_OPB_DWIDTH-1);
173
  signal Sl_toutSup_D   : std_logic;
174
  signal Sl_xferAck_D   : std_logic;
175
  signal Sl_retry_D     : std_logic;
176
  signal Sl_errAck_D    : std_logic;
177
  signal M_ABus_D       : std_logic_vector(0 to C_OPB_AWIDTH-1);
178
  signal M_BE_D         : std_logic_vector(0 to C_OPB_DWIDTH/8-1);
179
  signal M_busLock_D    : std_logic;
180
  signal M_request_D    : std_logic;
181
  signal M_RNW_D        : std_logic;
182
  signal M_select_D     : std_logic;
183
  signal M_seqAddr_D    : std_logic;
184
 
185
  signal SLAVE_MEM : std_logic_vector (0 to 31);
186
  signal MASTER_MEM : std_logic_vector (0 to 31);
187
  signal MASTER_MEM_SET : std_logic;
188
 
189
  signal ddr_address: std_logic_vector(31 downto 0) :=X"00000000";
190
  signal we: std_logic :='0';
191
  signal go, go_D : std_logic :='0';
192
  signal burst, burst_D : std_logic :='1';
193
  signal reset, reset_D, last_reset : std_logic :='1';
194
 
195
        -- jpeg
196
        signal jpeg_OPB_datavalid : std_logic :='0';
197
        signal jpeg_width, jpeg_height : std_logic_vector(15 downto 0) :=(others=>'0');
198
        signal jpeg_sampling : std_logic_vector(1 downto 0) :=(others=>'0');
199
        signal jpeg_red, jpeg_green, jpeg_blue : std_logic_vector(7 downto 0) :=(others=>'0');
200
        signal jpeg_error, jpeg_eoi, jpeg_datavalid, jpeg_ready : std_logic :='0';
201
        signal jpeg_context : std_logic_vector(3 downto 0) :=(others=>'0');
202
 
203
        -- vga
204
        signal vga_ready : std_logic :='0';
205
 
206
--      -- debug
207
--      signal jpeg_chipscope : std_logic_vector(127 downto 0) :=(others=>'0');
208
--      signal vga_chipscope : std_logic_vector(127 downto 0) :=(others=>'0');
209
--      signal BUTTONs_deb : std_logic_vector(4 downto 0) :=(others=>'1'); 
210
--      signal SWITCHEs_deb, SWITCHEs_deb_D : std_logic_vector(3 downto 0) :=(others=>'1'); 
211
--      signal LEDs_intern : std_logic_vector(3 downto 0) := "1111";
212
 
213
        -- quick n dirty
214
        type address_states is (repeat_frame, continue);
215
        signal address_state, address_state_D : address_states := repeat_frame;
216
 
217
        signal eoi_counter, eoi_counter_D : std_logic_vector(3 downto 0) :=(others=>'0');
218
        signal eoi_counter_threshold, eoi_counter_threshold_D : std_logic_vector(3 downto 0) :="0001";
219
        signal old_ddr_address, old_ddr_address_D : std_logic_vector(31 downto 0) :=X"00000000";
220
        signal soi, soi_D, eoi, eoi_D, eoi_hold, eoi_hold_D : std_logic :='0';
221
        signal received_ff, received_ff_D : std_logic :='0';
222
 
223
        signal pause, pause_D : std_logic :='1';
224
        signal slower, slower_D, last_slower : std_logic :='1';
225
        signal faster, faster_D, last_faster : std_logic :='1';
226
        signal next_frame, next_frame_D : std_logic :='0';
227
 
228
 
229
 
230
begin
231
 
232
-- **********************************************************************************************
233
-- * Debugging
234
-- **********************************************************************************************
235
 
236
--------------------------------------------------------------
237
---- Chipscope Stuff
238
--------------------------------------------------------------
239
--i_icon : icon
240
--port map( 
241
--      control0    => control0 
242
--);
243
--
244
--i_ila : ila
245
--port map(
246
--      control   => control0,
247
--      clk       => OPB_Clk,
248
--      trig0     => trig0 
249
--);
250
 
251
 
252
--process(SWITCHES_deb)
253
--begin
254
--      case SWITCHES_deb is
255
--              when "1111" =>
256
--                      trig0 <= ddr_address & 
257
----                                            jpeg_width & jpeg_height &
258
--                                              old_ddr_address &
259
----                                            jpeg_red & jpeg_green & jpeg_blue & jpeg_error & jpeg_eoi & jpeg_datavalid & jpeg_ready & jpeg_context &
260
--                                              OPB_DBus &
261
--                                              vga_ready & go & burst & reset & "000" & address_state_cs_flag  & we & jpeg_ready & jpeg_context & jpeg_error & received_ff & jpeg_eoi & pause & next_frame & slower & faster & eoi_hold & eoi & soi & eoi_counter_threshold & eoi_counter;
262
--              when "1110" =>
263
--                      trig0 <= vga_chipscope;
264
--              when "1101" =>  
265
--                      trig0 <= jpeg_chipscope;
266
------          when "0011" =>
267
----            when "0100" =>
268
----            when "0101" =>
269
----            when "0110" =>
270
----            when "0111" =>
271
----            when "1000" =>
272
----            when "1001" =>
273
----            when "1010" =>
274
----            when "1011" =>
275
----            when "1100" =>
276
----            when "1101" =>
277
----            when "1110" =>
278
--              when others =>
279
--      end case;
280
--end process;
281
--------------------------------------------------------------
282
 
283
 
284
------------------------------------------------------------------
285
---- LEDs debugging
286
------------------------------------------------------------------
287
--process(LEDs_intern, SWITCHEs_deb)
288
--begin
289
--      case SWITCHEs_deb is
290
--      when "1111" => 
291
--              LEDs <= LEDs_intern;
292
--      when "1110" => 
293
--              LEDs <= not jpeg_sampling & not jpeg_error & not go;
294
--      when "1101" =>
295
--              LEDs <= eoi_counter_threshold;
296
--      when "1100" =>
297
--              LEDs <= not OPB_retry & not OPB_xferAck & not OPB_timeout & not jpeg_error;
298
--      when "1001" =>
299
--              LEDs <= not OPB_retry_hold & not OPB_xferAck_hold & not OPB_timeout_hold & not jpeg_error;
300
--      when others =>
301
--              LEDs <= go & burst & burst & go;
302
--      end case;
303
--end process;
304
------------------------------------------------------------------
305
 
306
-- **********************************************************************************************
307
-- * debounce buttons and switches 
308
-- **********************************************************************************************
309
--process(OPB_Clk)
310
--begin
311
--      if rising_edge(OPB_Clk) then
312
--              counter <= counter + 1;
313
--              last_counter <= counter(8);
314
--
315
--              if counter(8)='1' and last_counter='0' then
316
--                      BUTTONs_deb <= BUTTONs;
317
----                    SWITCHEs_deb <= SWITCHEs;
318
--              end if;
319
--
320
--      end if; 
321
--end process;
322
 
323
 
324
 
325
-- **********************************************************************************************
326
-- * Port Maps
327
-- **********************************************************************************************
328
 
329
--------------------------------------------------------------
330
-- JPEG - Decoder
331
--------------------------------------------------------------
332
jpeg_decoder:jpeg
333
  port map(
334
        Clk                     => OPB_Clk,
335
                data_i          => OPB_DBus,
336
                reset_i         => reset,
337
 
338
                eoi_o                   => jpeg_eoi,
339
                error_o         => jpeg_error,
340
 
341
--              -- debug
342
--      LEDs                    => LEDs_intern,
343
--              BUTTONs         => BUTTONs_deb,
344
--              SWITCHEs                => SWITCHEs_deb,
345
--              chipscope_o     => jpeg_chipscope,
346
--
347
                context_o       => jpeg_context,
348
                red_o                   => jpeg_red,
349
                green_o         => jpeg_green,
350
                blue_o          => jpeg_blue,
351
                width_o         => jpeg_width,
352
                height_o                => jpeg_height,
353
                sampling_o      => jpeg_sampling,
354
 
355
                datavalid_i => jpeg_OPB_datavalid,
356
           datavalid_o  => jpeg_datavalid,
357
                ready_i         => vga_ready,
358
                ready_o         => jpeg_ready
359
    );
360
--------------------------------------------------------------
361
jpeg_OPB_datavalid <= we;
362
we              <= MASTER_MEM_SET and OPB_xferAck;
363
 
364
 
365
 
366
vga_core:vga
367
        port map(
368
                Clk                     => OPB_Clk,
369
                reset_i         => reset,
370
                eoi_i                   => jpeg_context(3),
371
 
372
                red_i           => jpeg_red,
373
                green_i         => jpeg_green,
374
                blue_i          => jpeg_blue,
375
                width_i         => jpeg_width,
376
                height_i                => jpeg_height,
377
                sampling_i      => jpeg_sampling,
378
 
379
                VGA_OUT_PIXEL_CLOCK     => VGA_OUT_PIXEL_CLOCK,
380
                VGA_COMP_SYNCH                  => VGA_COMP_SYNCH,
381
                VGA_OUT_BLANK_Z         => VGA_OUT_BLANK_Z,
382
                VGA_HSYNCH                              => VGA_HSYNCH,
383
                VGA_VSYNCH                              => VGA_VSYNCH,
384
                VGA_OUT_RED                             => VGA_OUT_RED,
385
                VGA_OUT_GREEN                   => VGA_OUT_GREEN,
386
                VGA_OUT_BLUE                    => VGA_OUT_BLUE,
387
 
388
--              -- chipscope-debugging
389
--              chipscope_o     => vga_chipscope,       
390
 
391
                -- flow controll
392
                datavalid_i => jpeg_datavalid,
393
                ready_o         => vga_ready
394
        );
395
 
396
 
397
 
398
 
399
 
400
 
401
-- **********************************************************************************************
402
-- * Processes
403
-- **********************************************************************************************
404
 
405
 
406
------------------------------------------------------------
407
-- eoi and soi detection 
408
------------------------------------------------------------
409
process(OPB_DBus, received_ff)
410
begin
411
 
412
        soi_D                           <= '0';
413
        eoi_D                           <= '0';
414
        received_ff_D   <= '0';
415
 
416
        if(OPB_DBus(0  to 15)=X"FFD9" or
417
                OPB_DBus(8  to 23)=X"FFD9" or
418
                OPB_DBus(16 to 31)=X"FFD9" or
419
                (OPB_Dbus(0 to 7) =X"D9" and received_ff='1') ) then
420
                eoi_D <='1';
421
        end if;
422
 
423
        if(OPB_DBus(0  to 15)=X"FFD8" or
424
                OPB_DBus(8  to 23)=X"FFD8" or
425
                OPB_DBus(16 to 31)=X"FFD8" or
426
                (OPB_Dbus(0 to 7) =X"D8" and received_ff='1') ) then
427
                soi_D <='1';
428
        end if;
429
 
430
        if (OPB_DBus(24 to 31)=X"FF") then
431
                received_ff_D <= '1';
432
        end if;
433
end process;
434
 
435
process(OPB_Clk)
436
begin
437
        if rising_edge(OPB_Clk) then
438
                if reset='1' then
439
                        soi                     <= '0';
440
                        eoi                     <= '0';
441
                        received_ff     <= '0';
442
                elsif(we='1') then
443
                        soi                     <= soi_D;
444
                        eoi                     <= eoi_D;
445
                        received_ff     <= received_ff_D;
446
                end if;
447
        end if;
448
end process;
449
------------------------------------------------------------
450
 
451
 
452
 
453
 
454
 
455
 
456
 
457
------------------------------------------------------------
458
-- keep address in sync with data 
459
------------------------------------------------------------
460
process(OPB_Clk)
461
begin
462
        if rising_edge(OPB_Clk) then
463
                if reset='1' or OPB_DBus=X"454e4445" then               -- OPB_DBus=X"454e4445" ("ENDE" in ASCII) is a very ugly proof of concept hack
464
                        ddr_address <= X"00000000";
465
                elsif (jpeg_eoi='1' and eoi_hold='0') then
466
                        ddr_address <= old_ddr_address;
467
                elsif we ='1' and jpeg_ready='1' then
468
                        ddr_address <= ddr_address+4;
469
                end if;
470
        end if;
471
end process;
472
------------------------------------------------------------
473
 
474
 
475
 
476
 
477
 
478
------------------------------------------------------------
479
-- decide whether this or following frame to be displayed
480
------------------------------------------------------------
481
process(        eoi_hold, old_ddr_address, eoi_counter, address_state, soi, ddr_address, jpeg_eoi,
482
                        eoi_counter_threshold, pause, next_frame)
483
begin
484
        eoi_hold_D <= eoi_hold;
485
        old_ddr_address_D <= old_ddr_address;
486
        eoi_counter_D <= eoi_counter;
487
        address_state_D <= address_state;
488
 
489
 
490
        if jpeg_eoi='1' then
491
                eoi_counter_D <= eoi_counter+1;
492
        end if;
493
 
494
 
495
        case address_state is
496
        when repeat_frame =>
497
                if (jpeg_eoi='1' and ((eoi_counter=eoi_counter_threshold and pause='0') or next_frame='1')) then
498
                        eoi_counter_D <= (others=>'0');
499
                        address_state_D <= continue;
500
                end if;
501
        when continue =>
502
                if eoi='1' then
503
                        eoi_hold_D<='1';
504
                end if;
505
                if jpeg_eoi='1' and eoi_counter_threshold/="0000"  then
506
                        address_state_D <= repeat_frame;
507
                end if;
508
        end case;
509
 
510
 
511
        -- independant from state because it is not certain whether jpeg_eoi or soi comes first 
512
        if eoi_hold='1' and soi='1' then
513
                old_ddr_address_D <= ddr_address-4;
514
                eoi_hold_D<='0';
515
        end if;
516
 
517
end process;
518
 
519
 
520
 
521
process(OPB_Clk)
522
begin
523
        if rising_edge(OPB_Clk) then
524
        if reset='1' then
525
                eoi_hold                        <= '0';
526
                old_ddr_address<= X"00000000";
527
                eoi_counter             <= (others=>'0');
528
                address_state   <= repeat_frame;
529
        else
530
                eoi_hold                <= eoi_hold_D;
531
                old_ddr_address<= old_ddr_address_D;
532
                eoi_counter             <= eoi_counter_D;
533
                address_state   <= address_state_D;
534
        end if;
535
        end if;
536
end process;
537
 
538
------------------------------------------------------------
539
 
540
 
541
--------------------------------------------------------------
542
-- adjust the framerate
543
--------------------------------------------------------------
544
process(faster, slower, eoi_counter_threshold)
545
begin
546
        eoi_counter_threshold_D <= eoi_counter_threshold;
547
        if faster='1' and last_faster='0' and eoi_counter_threshold/="0000" then
548
                eoi_counter_threshold_D <= eoi_counter_threshold-1;
549
        end if;
550
        if slower='1' and last_slower='0' and eoi_counter_threshold/="1111" then
551
                eoi_counter_threshold_D <= eoi_counter_threshold+1;
552
        end if;
553
end process;
554
 
555
process(OPB_Clk)
556
begin
557
        if rising_edge(OPB_Clk) then
558
        if reset='1' then
559
                eoi_counter_threshold<="0001";
560
        else
561
                eoi_counter_threshold<=eoi_counter_threshold_D;
562
        end if;
563
        end if;
564
end process;
565
--------------------------------------------------------------
566
 
567
 
568
 
569
 
570
 
571
 
572
 
573
 
574
 
575
--------------------------------------------------------------
576
---- configure bus transfer
577
--------------------------------------------------------------
578
process(OPB_CLK)
579
begin
580
  if rising_edge(OPB_CLK) then
581
 
582
        faster          <= faster_D;
583
        slower          <= slower_D;
584
        last_faster     <= faster;
585
        last_slower     <= slower;
586
 
587
        if reset='1' then
588
                 go                     <= '0';
589
                 burst          <= '1';
590
                 reset          <= '0';
591
--               SWITCHEs_deb <= (others=>'1');
592
                 pause          <= '1';
593
                 next_frame <= '0';
594
        else
595
                 go                     <= go_D;
596
                 burst          <= burst_D;
597
                 reset          <= reset_D;
598
--               SWITCHEs_deb <= SWITCHEs_deb_D;
599
                 pause <= pause_D;
600
                 next_frame <= next_frame_D;
601
        end if;
602
 
603
  end if;
604
end process;
605
------------------------------------------------------------
606
 
607
 
608
 
609
 
610
------------------------------------------------------------
611
-- Myipif: communicate over the OPB-Bus
612
------------------------------------------------------------
613
process (OPB_state, OPB_ABus, OPB_DBus, OPB_RNW, OPB_select, OPB_Rst, OPB_xferAck, OPB_MGrant,
614
                        ddr_address, go, burst, pause, next_frame, jpeg_eoi,   --SWITCHEs_deb,
615
                        jpeg_ready, jpeg_error, reset)
616
begin
617
  Sl_toutSup_D  <= '0';
618
  Sl_xferAck_D  <= '0';
619
  Sl_errAck_D   <= '0';
620
  Sl_retry_D    <= '0';
621
  Sl_DBus_D             <= X"00000000";
622
  M_ABus_D              <= X"00000000";
623
  M_BE_D                        <= (others => '1');
624
  M_busLock_D   <= '0';
625
  M_request_D   <= '0';
626
  M_RNW_D               <= '0';
627
  M_select_D    <= '0';
628
  M_seqAddr_D   <= '0';
629
 
630
  go_D                  <= go;
631
  burst_D               <= burst;
632
  reset_D               <= '0';
633
--  SWITCHEs_deb_D <= SWITCHEs_deb;
634
  pause_D               <= pause;
635
 
636
  next_frame_D  <= next_frame;
637
  if jpeg_eoi='1' then
638
        next_frame_D <= '0';
639
  end if;
640
 
641
  faster_D <= '0';
642
  slower_D <= '0';
643
 
644
 
645
  MASTER_MEM_SET <= '0';
646
 
647
  case OPB_state is
648
 
649
  when idle =>
650
                 OPB_next_state <= idle;
651
 
652
----
653
-- OPB-Bus configuration (via ppc and UART)
654
                 if (OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000001") then
655
                        go_D <= '1';
656
 
657
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000002") then
658
                        go_D <= '0';
659
 
660
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000003") then
661
                        burst_D <= '1';
662
 
663
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000004") then
664
                        burst_D <= '0';
665
 
666
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000005") then
667
                        reset_D <= '1';
668
 
669
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000006") then
670
--                      SWITCHEs_deb_D(0) <= '0';
671
--      
672
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000007") then
673
--                      SWITCHEs_deb_D(0) <= '1';
674
--               
675
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000008") then
676
--                      SWITCHEs_deb_D(1) <= '0';
677
--              
678
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000009") then
679
--                      SWITCHEs_deb_D(1) <= '1';
680
--               
681
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"0000000A") then
682
--                      SWITCHEs_deb_D(2) <= '0';
683
--      
684
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"0000000B") then
685
--                      SWITCHEs_deb_D(2) <= '1';
686
--               
687
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"0000000C") then
688
--                      SWITCHEs_deb_D(3) <= '0';
689
--              
690
--               elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"0000000D") then
691
--                      SWITCHEs_deb_D(3) <= '1';
692
--
693
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"0000000E") then
694
                        pause_D <= '1';
695
 
696
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"0000000F") then
697
                        pause_D <= '0';
698
 
699
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000010") then
700
                        next_frame_D <= '1';
701
 
702
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000011") then
703
                        faster_D <= '1';
704
 
705
                 elsif(OPB_ABus(0 to 31)=X"50000004" and OPB_RNW='0' and OPB_DBus=X"00000012") then
706
                        slower_D <= '1';
707
 
708
----------
709
-- get jpeg data from ram
710
                 elsif (jpeg_ready='1' and jpeg_error='0' and go='1' and OPB_DBus/=X"454e4445") then
711
        OPB_next_state <= MasterRead1;
712
                end if;
713
----------
714
 
715
 
716
 
717
  when MasterRead1 =>
718
      M_request_D <= '1';
719
       if (OPB_MGrant = '1') then
720
          M_seqAddr_D           <= burst;
721
                         M_busLock_D            <= '1';
722
                 OPB_next_state <= MasterRead2;
723
       else
724
            OPB_next_state      <= MasterRead1;
725
       end if;
726
 
727
 
728
  when MasterRead2 =>
729
       M_seqAddr_D                <= burst;
730
       M_busLock_D        <= '1';
731
       M_select_D         <= '1';
732
       M_RNW_D            <= '1';
733
       M_ABus_D           <= "000" & ddr_address(28 downto 0);                           -- begin with 3 zeroes to prevent writing to sonething different than DDR-RAM 
734
       MASTER_MEM_SET     <= '1';
735
       if(jpeg_ready='1' and jpeg_error='0' and burst='1' and OPB_DBus/=X"454e4445") then
736
          OPB_next_state <= MasterRead2;
737
       else
738
          OPB_next_state <= idle;
739
       end if;
740
 
741
  end case;
742
 
743
  -- Reset
744
  if (OPB_Rst = '1' or reset='1' or jpeg_eoi='1') then
745
     OPB_next_state <= idle;
746
     Sl_DBus_D      <= X"00000000";
747
     Sl_xferAck_D   <= '0';
748
     M_ABus_D       <= X"00000000";
749
  end if;
750
end process;
751
------------------------------------------------------------
752
 
753
 
754
------------------------------------------------------------
755
-- OPB_state: Reset and Synchronization
756
------------------------------------------------------------
757
process (OPB_Clk, OPB_Rst)
758
begin
759
  if (OPB_Rst='1') then
760
     OPB_state <= idle;
761
  elsif (OPB_Clk'event and OPB_Clk='1') then
762
     OPB_state <= OPB_next_state;
763
  end if;
764
end process;
765
------------------------------------------------------------
766
 
767
------------------------------------------------------------
768
-- Synchronize other signals
769
------------------------------------------------------------
770
process(OPB_CLK)
771
begin
772
  if rising_edge(OPB_CLK) then
773
    Sl_toutSup <= Sl_toutSup_D;
774
    Sl_xferAck <= Sl_xferAck_D;
775
    Sl_errAck  <= Sl_errAck_D;
776
    Sl_DBus    <= Sl_DBus_D;
777
    Sl_retry   <= Sl_retry_D;
778
 
779
    M_ABus     <= M_ABus_D;
780
    M_BE       <= M_BE_D;
781
    M_busLock  <= M_busLock_D;
782
    M_request  <= M_request_D;
783
    M_RNW      <= M_RNW_D;
784
    M_select   <= M_select_D;
785
    M_seqAddr  <= M_seqAddr_D;
786
  end if;
787
end process;
788
------------------------------------------------------------
789
 
790
end IMP;

powered by: WebSVN 2.1.0

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