Subversion Repositories pentevo

Rev

Rev 608 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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        mode_60hz,
  66.  
  67.         // memory synchronization inputs
  68.         input  wire        cbeg,
  69.         input  wire        post_cbeg,
  70.         input  wire        pre_cend,
  71.         input  wire        cend,
  72.  
  73.  
  74.         // memory arbiter video port connection
  75.         input  wire        video_strobe,
  76.         input  wire        video_next,
  77.         output wire [20:0] video_addr,
  78.         input  wire [15:0] video_data,
  79.         output wire [ 1:0] video_bw,
  80.         output wire        video_go,
  81.  
  82.  
  83.         // atm palette write strobe adn data
  84.         input  wire        atm_palwr,
  85.         input  wire [ 5:0] atm_paldata,
  86.  
  87.  
  88.         input  wire        up_ena,
  89.         input  wire        up_palwr,
  90.         input  wire [ 5:0] up_paladdr,
  91.         input  wire [ 7:0] up_paldata,
  92.  
  93.  
  94.  
  95.         output wire        int_start,
  96.  
  97.  
  98.  
  99.         input  wire [10:0] fnt_a,
  100.         input  wire [ 7:0] fnt_d,
  101.         input  wire        fnt_wr,
  102.  
  103.         output wire [ 5:0] palcolor, // for palette readback
  104.  
  105.         output wire [ 7:0] fontrom_readback
  106. );
  107.  
  108.         // these decoded in video_modedecode.v
  109.         wire mode_atm_n_pent;
  110.         wire mode_zx;
  111.         wire mode_p_16c;
  112.         wire mode_p_hmclr;
  113.         wire mode_a_hmclr;
  114.         wire mode_a_16c;
  115.         wire mode_a_text;
  116.         wire mode_a_txt_1page;
  117.         wire mode_pixf_14;
  118.  
  119.  
  120.  
  121.         // synchronization
  122.         wire hsync_start;
  123.         wire line_start;
  124.         wire hint_start;
  125.  
  126.  
  127.         wire vblank;
  128.         wire hblank;
  129.  
  130.         wire vpix;
  131.         wire hpix;
  132.  
  133.         wire vsync;
  134.         wire hsync;
  135.  
  136.         wire vga_hsync;
  137.  
  138.         wire scanin_start;
  139.         wire scanout_start;
  140.  
  141.  
  142.  
  143.         wire fetch_start;
  144.         wire fetch_end;
  145.         wire fetch_sync;
  146.  
  147.  
  148.         wire [63:0] pic_bits;
  149.  
  150.  
  151.         wire [3:0] pixels;
  152.  
  153.  
  154.         wire [5:0] color;
  155.         wire [5:0] vga_color;
  156.  
  157.  
  158.         wire [2:0] typos;
  159.  
  160.        
  161.         // ulaplus related
  162.         wire [ 1:0] up_palsel;
  163.         wire [ 2:0] up_paper;
  164.         wire [ 2:0] up_ink;
  165.         wire        up_pixel;
  166.  
  167.  
  168.         // decode video modes
  169.         video_modedecode video_modedecode(
  170.  
  171.                 .clk(clk),
  172.  
  173.                 .pent_vmode(pent_vmode),
  174.                 .atm_vmode (atm_vmode),
  175.  
  176.                 .mode_atm_n_pent (mode_atm_n_pent ),
  177.                 .mode_zx         (mode_zx         ),
  178.                 .mode_p_16c      (mode_p_16c      ),
  179.                 .mode_p_hmclr    (mode_p_hmclr    ),
  180.                 .mode_a_hmclr    (mode_a_hmclr    ),
  181.                 .mode_a_16c      (mode_a_16c      ),
  182.                 .mode_a_text     (mode_a_text     ),
  183.                 .mode_a_txt_1page(mode_a_txt_1page),
  184.  
  185.                 .mode_pixf_14(mode_pixf_14),
  186.  
  187.                 .mode_bw(video_bw)
  188.         );
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.         // vertical sync generator
  196.         video_sync_v video_sync_v(
  197.  
  198.                 .clk(clk),
  199.  
  200.                 .mode_atm_n_pent(mode_atm_n_pent),
  201.                 .mode_60hz(mode_60hz),
  202.  
  203.                 .hsync_start(hsync_start),
  204.                 .line_start(line_start),
  205.                 .hint_start(hint_start),
  206.  
  207.                 .vblank(vblank),
  208.                 .vsync(vsync),
  209.                 .vpix(vpix),
  210.  
  211.                 .int_start(int_start)
  212.         );
  213.  
  214.  
  215.         // horizontal sync generator
  216.         video_sync_h video_sync_h(
  217.  
  218.                 .clk(clk),
  219.  
  220.                 .mode_atm_n_pent(mode_atm_n_pent),
  221.                 .mode_a_text    (mode_a_text),
  222.  
  223.  
  224.                 .init(1'b0),
  225.  
  226.                 .pre_cend(pre_cend),
  227.                 .cend    (cend    ),
  228.  
  229.  
  230.                 .hblank(hblank),
  231.                 .hsync(hsync),
  232.                 .hpix(hpix),
  233.  
  234.                 .line_start(line_start),
  235.                 .hsync_start(hsync_start),
  236.  
  237.                 .hint_start(hint_start),
  238.  
  239.                 .scanin_start(scanin_start),
  240.  
  241.                 .fetch_start(fetch_start),
  242.                 .fetch_end  (fetch_end  )
  243.  
  244.         );
  245.  
  246.  
  247.         // address generation
  248.         video_addrgen video_addrgen(
  249.  
  250.                 .clk(clk),
  251.  
  252.                 .video_addr(video_addr),
  253.                 .video_next(video_next),
  254.  
  255.                 .line_start(hsync_start),
  256.                 .int_start (int_start ),
  257.                 .vpix      (vpix      ),
  258.  
  259.                 .scr_page(scr_page),
  260.  
  261.                 .typos(typos),
  262.  
  263.                 .mode_atm_n_pent (mode_atm_n_pent ),
  264.                 .mode_zx         (mode_zx         ),
  265.                 .mode_p_16c      (mode_p_16c      ),
  266.                 .mode_p_hmclr    (mode_p_hmclr    ),
  267.                 .mode_a_hmclr    (mode_a_hmclr    ),
  268.                 .mode_a_16c      (mode_a_16c      ),
  269.                 .mode_a_text     (mode_a_text     ),
  270.                 .mode_a_txt_1page(mode_a_txt_1page)
  271.         );
  272.  
  273.  
  274.         // data fetch
  275.         video_fetch video_fetch(
  276.  
  277.                 .clk(clk),
  278.  
  279.                 .pre_cend (pre_cend),
  280.                 .cend     (cend    ),
  281.  
  282.                 .vpix(vpix),
  283.  
  284.                 .fetch_start(fetch_start),
  285.                 .fetch_end  (fetch_end  ),
  286.  
  287.                 .fetch_sync (fetch_sync ),
  288.  
  289.                 .video_data  (video_data  ),
  290.                 .video_strobe(video_strobe),
  291.                 .video_go    (video_go    ),
  292.  
  293.                 .pic_bits(pic_bits)
  294.         );
  295.  
  296.  
  297.         // render fetched data to pixels
  298.         video_render video_render(
  299.  
  300.                 .clk(clk),
  301.  
  302.                 .pic_bits(pic_bits),
  303.  
  304.                 .fetch_sync(fetch_sync),
  305.  
  306.                 .cbeg     (cbeg     ),
  307.                 .post_cbeg(post_cbeg),
  308.                 .pre_cend (pre_cend ),
  309.                 .cend     (cend     ),
  310.  
  311.                 .int_start(int_start),
  312.  
  313.                 .mode_atm_n_pent(mode_atm_n_pent),
  314.                 .mode_zx        (mode_zx        ),
  315.                 .mode_p_16c     (mode_p_16c     ),
  316.                 .mode_p_hmclr   (mode_p_hmclr   ),
  317.                 .mode_a_hmclr   (mode_a_hmclr   ),
  318.                 .mode_a_16c     (mode_a_16c     ),
  319.                 .mode_a_text    (mode_a_text    ),
  320.                 .mode_pixf_14   (mode_pixf_14   ),
  321.  
  322.                 .typos(typos),
  323.  
  324.                 .pixels(pixels),
  325.  
  326.                 .up_palsel(up_palsel),
  327.                 .up_paper (up_paper ),
  328.                 .up_ink   (up_ink   ),
  329.                 .up_pixel (up_pixel ),
  330.  
  331.  
  332.                 .fnt_a (fnt_a ),
  333.                 .fnt_d (fnt_d ),
  334.                 .fnt_wr(fnt_wr),
  335.  
  336.                 .fontrom_readback(fontrom_readback)
  337.         );
  338.  
  339.  
  340.         // combine border and pixels, apply palette
  341.         video_palframe video_palframe(
  342.  
  343.                 .clk(clk),
  344.  
  345.                 .hblank(hblank),
  346.                 .vblank(vblank),
  347.  
  348.                 .hsync_start(hsync_start),
  349.                 .vsync      (vsync      ),
  350.  
  351.                 .hpix(hpix),
  352.                 .vpix(vpix),
  353.  
  354.                 .pixels(pixels),
  355.                 .border(zxborder),
  356.  
  357.                 .atm_palwr  (atm_palwr  ),
  358.                 .atm_paldata(atm_paldata),
  359.                
  360.                 .up_palsel(up_palsel),
  361.                 .up_paper (up_paper ),
  362.                 .up_ink   (up_ink   ),
  363.                 .up_pixel (up_pixel ),
  364.                
  365.                 .up_ena    (up_ena    ),
  366.                 .up_paladdr(up_paladdr),
  367.                 .up_paldata(up_paldata),
  368.                 .up_palwr  (up_palwr  ),
  369.  
  370.                 .color(color),
  371.  
  372.                 .palcolor(palcolor) // palette readback
  373.         );
  374.  
  375.  
  376.         // VGA hsync doubling
  377.         video_vga_sync_h video_vga_sync_h(
  378.  
  379.                 .clk(clk),
  380.  
  381.                 .hsync_start(hsync_start),
  382.  
  383.                 .scanout_start(scanout_start),
  384.  
  385.                 .vga_hsync(vga_hsync)
  386.         );
  387.  
  388.  
  389.         // VGA scandoubling
  390.         video_vga_double video_vga_double(
  391.  
  392.                 .clk(clk),
  393.  
  394.                 .hsync_start  (hsync_start  ),
  395.                 .scanout_start(scanout_start),
  396.                 .scanin_start (scanin_start ),
  397.  
  398.                 .pix_in(color),
  399.  
  400.                 .pix_out(vga_color)
  401.         );
  402.  
  403.  
  404.         // final MUXing of VGA and TV signals
  405.         video_outmux video_outmux(
  406.  
  407.                 .clk(clk),
  408.  
  409.                 .vga_on(vga_on),
  410.  
  411.  
  412.                 .tvcolor(color),
  413.                 .vgacolor(vga_color),
  414.  
  415.                 .vga_hsync(vga_hsync),
  416.                 .hsync    (hsync    ),
  417.                 .vsync    (vsync    ),
  418.  
  419.                 .vred(vred),
  420.                 .vgrn(vgrn),
  421.                 .vblu(vblu),
  422.  
  423.                 .vhsync(vhsync),
  424.                 .vvsync(vvsync),
  425.                 .vcsync(vcsync)
  426.         );
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433. endmodule
  434.  
  435.