Subversion Repositories pentevo

Rev

Rev 668 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. // ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014
  2. //
  3. // top module for video output.
  4.  
  5. /*
  6.     This file is part of ZX-Evo Base Configuration firmware.
  7.  
  8.     ZX-Evo Base Configuration firmware is free software:
  9.     you can redistribute it and/or modify it under the terms of
  10.     the GNU General Public License as published by
  11.     the Free Software Foundation, either version 3 of the License, or
  12.     (at your option) any later version.
  13.  
  14.     ZX-Evo Base Configuration firmware is distributed in the hope that
  15.     it will be useful, but WITHOUT ANY WARRANTY; without even
  16.     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17.     See the GNU General Public License for more details.
  18.  
  19.     You should have received a copy of the GNU General Public License
  20.     along with ZX-Evo Base Configuration firmware.
  21.     If not, see <http://www.gnu.org/licenses/>.
  22. */
  23.  
  24.  
  25.  
  26. // note: the only bandwidths currently in use are 1/8 and 1/4.
  27.  
  28. `include "../include/tune.v"
  29.  
  30. module video_top(
  31.  
  32.         input  wire        clk, // 28 MHz clock
  33.  
  34.  
  35.         // external video outputs
  36.         output wire [ 1:0] vred,
  37.         output wire [ 1:0] vgrn,
  38.         output wire [ 1:0] vblu,
  39.         output wire        vhsync,
  40.         output wire        vvsync,
  41.         output wire        vcsync,
  42.  
  43.  
  44.         // aux video inputs
  45.         input  wire [ 3:0] zxborder, // border zxcolor
  46.  
  47.  
  48.         // config inputs
  49.         input  wire [ 1:0] pent_vmode, // 2'b00 - standard ZX
  50.                                        // 2'b01 - hardware multicolor
  51.                                        // 2'b10 - pentagon 16 colors
  52.                                        // 2'b11 - not defined yet
  53.  
  54.         input  wire [ 2:0] atm_vmode,  // 3'b011 - zx modes (pent_vmode is active)
  55.                                        // 3'b010 - 640x200 hardware multicolor
  56.                                        // 3'b000 - 320x200 16 colors
  57.                                        // 3'b110 - 80x25 text mode
  58.                                        // 3'b??? (others) - not defined yet
  59.        
  60.  
  61.         input  wire        scr_page,   // screen page (bit 3 of 7FFD)
  62.  
  63.         input  wire        vga_on,     // vga mode ON - scandoubler activated
  64.  
  65.         input  wire [ 1:0] modes_raster, // 2'b00 - pentagon raster (71680 clocks)
  66.                                          // 2'b01 - 60Hz raster
  67.                                          // 2'b10 - 48k raster (69888 clocks)
  68.                                          // 2'b11 - 128k raster (70908 clocks)
  69.        
  70.         input  wire        mode_contend_type, // 2'b0 - 48k/128k/+2 contend type (6 5 4 3 2 1 0 0)
  71.                                               // 2'b1 - +2a/+3 contend type (1 0 7 6 5 4 3 2)
  72.  
  73.         // memory synchronization inputs
  74.         input  wire        cbeg,
  75.         input  wire        post_cbeg,
  76.         input  wire        pre_cend,
  77.         input  wire        cend,
  78.  
  79.  
  80.         // memory arbiter video port connection
  81.         input  wire        video_strobe,
  82.         input  wire        video_next,
  83.         output wire [20:0] video_addr,
  84.         input  wire [15:0] video_data,
  85.         output wire [ 1:0] video_bw,
  86.         output wire        video_go,
  87.  
  88.  
  89.         // atm palette write strobe adn data
  90.         input  wire        atm_palwr,
  91.         input  wire [ 5:0] atm_paldata,
  92.  
  93.  
  94.         input  wire        up_ena,
  95.         input  wire        up_palwr,
  96.         input  wire [ 5:0] up_paladdr,
  97.         input  wire [ 7:0] up_paldata,
  98.  
  99.  
  100.  
  101.         output wire        int_start,
  102.  
  103.  
  104.  
  105.         input  wire [10:0] fnt_a,
  106.         input  wire [ 7:0] fnt_d,
  107.         input  wire        fnt_wr,
  108.  
  109.         output wire [ 5:0] palcolor, // for palette readback
  110.  
  111.         output wire [ 7:0] fontrom_readback,
  112.  
  113.         output wire        contend // for 48k/128k contended memory emulation
  114. );
  115.  
  116.         // these decoded in video_modedecode.v
  117.         wire mode_atm_n_pent;
  118.         wire mode_zx;
  119.         wire mode_p_16c;
  120.         wire mode_p_hmclr;
  121.         wire mode_a_hmclr;
  122.         wire mode_a_16c;
  123.         wire mode_a_text;
  124.         wire mode_a_txt_1page;
  125.         wire mode_pixf_14;
  126.  
  127.  
  128.  
  129.         // synchronization
  130.         wire hsync_start;
  131.         wire line_start;
  132.         wire hint_start;
  133.  
  134.  
  135.         wire vblank;
  136.         wire hblank;
  137.  
  138.         wire vpix;
  139.         wire hpix;
  140.  
  141.         wire vsync;
  142.         wire hsync;
  143.  
  144.         wire vga_hsync;
  145.  
  146.         wire scanin_start;
  147.         wire scanout_start;
  148.  
  149.  
  150.  
  151.         wire fetch_start;
  152.         wire fetch_end;
  153.         wire fetch_sync;
  154.  
  155.  
  156.         wire [63:0] pic_bits;
  157.  
  158.  
  159.         wire [3:0] pixels;
  160.  
  161.  
  162.         wire [5:0] color;
  163.         wire [5:0] vga_color;
  164.  
  165.  
  166.         wire [2:0] typos;
  167.  
  168.        
  169.         // ulaplus related
  170.         wire [ 1:0] up_palsel;
  171.         wire [ 2:0] up_paper;
  172.         wire [ 2:0] up_ink;
  173.         wire        up_pixel;
  174.  
  175.  
  176.         // border sync for 48k/128k emulation
  177.         wire border_sync;
  178.  
  179.  
  180.  
  181.         // decode video modes
  182.         video_modedecode video_modedecode(
  183.  
  184.                 .clk(clk),
  185.  
  186.                 .pent_vmode(pent_vmode),
  187.                 .atm_vmode (atm_vmode),
  188.  
  189.                 .mode_atm_n_pent (mode_atm_n_pent ),
  190.                 .mode_zx         (mode_zx         ),
  191.                 .mode_p_16c      (mode_p_16c      ),
  192.                 .mode_p_hmclr    (mode_p_hmclr    ),
  193.                 .mode_a_hmclr    (mode_a_hmclr    ),
  194.                 .mode_a_16c      (mode_a_16c      ),
  195.                 .mode_a_text     (mode_a_text     ),
  196.                 .mode_a_txt_1page(mode_a_txt_1page),
  197.  
  198.                 .mode_pixf_14(mode_pixf_14),
  199.  
  200.                 .mode_bw(video_bw)
  201.         );
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.         // vertical sync generator
  209.         video_sync_v video_sync_v(
  210.  
  211.                 .clk(clk),
  212.  
  213.                 .mode_atm_n_pent(mode_atm_n_pent),
  214.                 .modes_raster(modes_raster),
  215.  
  216.                 .hsync_start(hsync_start),
  217.                 .line_start(line_start),
  218.                 .hint_start(hint_start),
  219.  
  220.                 .vblank(vblank),
  221.                 .vsync(vsync),
  222.                 .vpix(vpix),
  223.  
  224.                 .int_start(int_start)
  225.         );
  226.  
  227.  
  228.         // horizontal sync generator
  229.         video_sync_h video_sync_h(
  230.  
  231.                 .clk(clk),
  232.  
  233.                 .mode_atm_n_pent(mode_atm_n_pent),
  234.                 .mode_a_text    (mode_a_text),
  235.  
  236.                 .modes_raster     (modes_raster     ),
  237.                 .mode_contend_type(mode_contend_type),
  238.  
  239.                 .init(1'b0),
  240.  
  241.                 .pre_cend(pre_cend),
  242.                 .cend    (cend    ),
  243.  
  244.  
  245.                 .hblank(hblank),
  246.                 .hsync(hsync),
  247.                 .vpix(vpix),
  248.                 .hpix(hpix),
  249.  
  250.                 .line_start(line_start),
  251.                 .hsync_start(hsync_start),
  252.  
  253.                 .hint_start(hint_start),
  254.  
  255.                 .scanin_start(scanin_start),
  256.  
  257.                 .fetch_start(fetch_start),
  258.                 .fetch_end  (fetch_end  ),
  259.  
  260.                 .contend(contend),
  261.  
  262.                 .border_sync(border_sync)
  263.         );
  264.  
  265.  
  266.         // address generation
  267.         video_addrgen video_addrgen(
  268.  
  269.                 .clk(clk),
  270.  
  271.                 .video_addr(video_addr),
  272.                 .video_next(video_next),
  273.  
  274.                 .line_start(hsync_start),
  275.                 .int_start (int_start ),
  276.                 .vpix      (vpix      ),
  277.  
  278.                 .scr_page(scr_page),
  279.  
  280.                 .typos(typos),
  281.  
  282.                 .mode_atm_n_pent (mode_atm_n_pent ),
  283.                 .mode_zx         (mode_zx         ),
  284.                 .mode_p_16c      (mode_p_16c      ),
  285.                 .mode_p_hmclr    (mode_p_hmclr    ),
  286.                 .mode_a_hmclr    (mode_a_hmclr    ),
  287.                 .mode_a_16c      (mode_a_16c      ),
  288.                 .mode_a_text     (mode_a_text     ),
  289.                 .mode_a_txt_1page(mode_a_txt_1page)
  290.         );
  291.  
  292.  
  293.         // data fetch
  294.         video_fetch video_fetch(
  295.  
  296.                 .clk(clk),
  297.  
  298.                 .pre_cend (pre_cend),
  299.                 .cend     (cend    ),
  300.  
  301.                 .vpix(vpix),
  302.  
  303.                 .fetch_start(fetch_start),
  304.                 .fetch_end  (fetch_end  ),
  305.  
  306.                 .fetch_sync (fetch_sync ),
  307.  
  308.                 .video_data  (video_data  ),
  309.                 .video_strobe(video_strobe),
  310.                 .video_go    (video_go    ),
  311.  
  312.                 .pic_bits(pic_bits)
  313.         );
  314.  
  315.  
  316.         // render fetched data to pixels
  317.         video_render video_render(
  318.  
  319.                 .clk(clk),
  320.  
  321.                 .pic_bits(pic_bits),
  322.  
  323.                 .fetch_sync(fetch_sync),
  324.  
  325.                 .cbeg     (cbeg     ),
  326.                 .post_cbeg(post_cbeg),
  327.                 .pre_cend (pre_cend ),
  328.                 .cend     (cend     ),
  329.  
  330.                 .int_start(int_start),
  331.  
  332.                 .mode_atm_n_pent(mode_atm_n_pent),
  333.                 .mode_zx        (mode_zx        ),
  334.                 .mode_p_16c     (mode_p_16c     ),
  335.                 .mode_p_hmclr   (mode_p_hmclr   ),
  336.                 .mode_a_hmclr   (mode_a_hmclr   ),
  337.                 .mode_a_16c     (mode_a_16c     ),
  338.                 .mode_a_text    (mode_a_text    ),
  339.                 .mode_pixf_14   (mode_pixf_14   ),
  340.  
  341.                 .typos(typos),
  342.  
  343.                 .pixels(pixels),
  344.  
  345.                 .up_palsel(up_palsel),
  346.                 .up_paper (up_paper ),
  347.                 .up_ink   (up_ink   ),
  348.                 .up_pixel (up_pixel ),
  349.  
  350.  
  351.                 .fnt_a (fnt_a ),
  352.                 .fnt_d (fnt_d ),
  353.                 .fnt_wr(fnt_wr),
  354.  
  355.                 .fontrom_readback(fontrom_readback)
  356.         );
  357.  
  358.  
  359.         // combine border and pixels, apply palette
  360.         video_palframe video_palframe(
  361.  
  362.                 .clk(clk),
  363.  
  364.                 .hblank(hblank),
  365.                 .vblank(vblank),
  366.  
  367.                 .hsync_start(hsync_start),
  368.                 .vsync      (vsync      ),
  369.  
  370.                 .hpix(hpix),
  371.                 .vpix(vpix),
  372.  
  373.                 .pixels(pixels),
  374.                 .border(zxborder),
  375.  
  376.                 .border_sync    (border_sync    ),
  377.                 .border_sync_ena(modes_raster[1]),
  378.  
  379.                 .atm_palwr  (atm_palwr  ),
  380.                 .atm_paldata(atm_paldata),
  381.                
  382.                 .up_palsel(up_palsel),
  383.                 .up_paper (up_paper ),
  384.                 .up_ink   (up_ink   ),
  385.                 .up_pixel (up_pixel ),
  386.                
  387.                 .up_ena    (up_ena    ),
  388.                 .up_paladdr(up_paladdr),
  389.                 .up_paldata(up_paldata),
  390.                 .up_palwr  (up_palwr  ),
  391.  
  392.                 .color(color),
  393.  
  394.                 .palcolor(palcolor) // palette readback
  395.         );
  396.  
  397.  
  398.         // VGA hsync doubling
  399.         video_vga_sync_h video_vga_sync_h(
  400.  
  401.                 .clk(clk),
  402.  
  403.                 .hsync_start(hsync_start),
  404.                
  405.                 .modes_raster(modes_raster),
  406.  
  407.                 .scanout_start(scanout_start),
  408.  
  409.                 .vga_hsync(vga_hsync)
  410.         );
  411.  
  412.  
  413.         // VGA scandoubling
  414.         video_vga_double video_vga_double(
  415.  
  416.                 .clk(clk),
  417.  
  418.                 .hsync_start  (hsync_start  ),
  419.                 .scanout_start(scanout_start),
  420.                 .scanin_start (scanin_start ),
  421.  
  422.                 .pix_in(color),
  423.  
  424.                 .pix_out(vga_color)
  425.         );
  426.  
  427.  
  428.         // final MUXing of VGA and TV signals
  429.         video_outmux video_outmux(
  430.  
  431.                 .clk(clk),
  432.  
  433.                 .vga_on(vga_on),
  434.  
  435.  
  436.                 .tvcolor(color),
  437.                 .vgacolor(vga_color),
  438.  
  439.                 .vga_hsync(vga_hsync),
  440.                 .hsync    (hsync    ),
  441.                 .vsync    (vsync    ),
  442.  
  443.                 .vred(vred),
  444.                 .vgrn(vgrn),
  445.                 .vblu(vblu),
  446.  
  447.                 .vhsync(vhsync),
  448.                 .vvsync(vvsync),
  449.                 .vcsync(vcsync)
  450.         );
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. endmodule
  458.  
  459.