Subversion Repositories pentevo

Rev

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

  1. `include "../include/tune.v"
  2.  
  3. // Pentevo project (c) NedoPC 2010,2011,2012
  4. //
  5. // top module for video output.
  6. //
  7. //
  8. // note: the only bandwidths currently in use are 1/8 and 1/4.
  9.  
  10. module video_top(
  11.  
  12.         input  wire        clk, // 28 MHz clock
  13.  
  14.  
  15.         // external video outputs
  16.         output wire [ 1:0] vred,
  17.         output wire [ 1:0] vgrn,
  18.         output wire [ 1:0] vblu,
  19.         output wire        vhsync,
  20.         output wire        vvsync,
  21.         output wire        vcsync,
  22.  
  23.  
  24.         // aux video inputs
  25.         input  wire [ 3:0] zxborder, // border zxcolor
  26.  
  27.  
  28.         // config inputs
  29.         input  wire [ 1:0] pent_vmode, // 2'b00 - standard ZX
  30.                                        // 2'b01 - hardware multicolor
  31.                                        // 2'b10 - pentagon 16 colors
  32.                                        // 2'b11 - not defined yet
  33.  
  34.         input  wire [ 2:0] atm_vmode,  // 3'b011 - zx modes (pent_vmode is active)
  35.                                        // 3'b010 - 640x200 hardware multicolor
  36.                                        // 3'b000 - 320x200 16 colors
  37.                                        // 3'b110 - 80x25 text mode
  38.                                        // 3'b??? (others) - not defined yet
  39.  
  40.  
  41.  
  42.         input  wire        scr_page,   // screen page (bit 3 of 7FFD)
  43.  
  44.         input  wire        vga_on,     // vga mode ON - scandoubler activated
  45.  
  46.         input  wire        mode_60hz,
  47.  
  48.         // memory synchronization inputs
  49.         input  wire        cbeg,
  50.         input  wire        post_cbeg,
  51.         input  wire        pre_cend,
  52.         input  wire        cend,
  53.  
  54.  
  55.         // memory arbiter video port connection
  56.         input  wire        video_strobe,
  57.         input  wire        video_next,
  58.         output wire [20:0] video_addr,
  59.         input  wire [15:0] video_data,
  60.         output wire [ 1:0] video_bw,
  61.         output wire        video_go,
  62.  
  63.  
  64.         // atm palette write strobe adn data
  65.         input  wire        atm_palwr,
  66.         input  wire [ 5:0] atm_paldata,
  67.  
  68.  
  69.         output wire        int_start,
  70.  
  71.  
  72.  
  73.         input  wire [10:0] fnt_a,
  74.         input  wire [ 7:0] fnt_d,
  75.         input  wire        fnt_wr,
  76.  
  77.         output wire [ 5:0] palcolor, // for palette readback
  78.  
  79.         output wire [ 7:0] fontrom_readback
  80. );
  81.  
  82.         // these decoded in video_modedecode.v
  83.         wire mode_atm_n_pent;
  84.         wire mode_zx;
  85.         wire mode_p_16c;
  86.         wire mode_p_hmclr;
  87.         wire mode_a_hmclr;
  88.         wire mode_a_16c;
  89.         wire mode_a_text;
  90.         wire mode_a_txt_1page;
  91.         wire mode_pixf_14;
  92.  
  93.  
  94.  
  95.         // synchronization
  96.         wire hsync_start;
  97.         wire line_start;
  98.         wire hint_start;
  99.  
  100.  
  101.         wire vblank;
  102.         wire hblank;
  103.  
  104.         wire vpix;
  105.         wire hpix;
  106.  
  107.         wire vsync;
  108.         wire hsync;
  109.  
  110.         wire vga_hsync;
  111.  
  112.         wire scanin_start;
  113.         wire scanout_start;
  114.  
  115.  
  116.  
  117.         wire fetch_start;
  118.         wire fetch_end;
  119.         wire fetch_sync;
  120.  
  121.  
  122.         wire [63:0] pic_bits;
  123.  
  124.  
  125.         wire [3:0] pixels;
  126.  
  127.  
  128.         wire [5:0] color;
  129.         wire [5:0] vga_color;
  130.  
  131.  
  132.         wire [2:0] typos;
  133.  
  134.  
  135.  
  136.         // decode video modes
  137.         video_modedecode video_modedecode(
  138.  
  139.                 .clk(clk),
  140.  
  141.                 .pent_vmode(pent_vmode),
  142.                 .atm_vmode (atm_vmode),
  143.  
  144.                 .mode_atm_n_pent (mode_atm_n_pent ),
  145.                 .mode_zx         (mode_zx         ),
  146.                 .mode_p_16c      (mode_p_16c      ),
  147.                 .mode_p_hmclr    (mode_p_hmclr    ),
  148.                 .mode_a_hmclr    (mode_a_hmclr    ),
  149.                 .mode_a_16c      (mode_a_16c      ),
  150.                 .mode_a_text     (mode_a_text     ),
  151.                 .mode_a_txt_1page(mode_a_txt_1page),
  152.  
  153.                 .mode_pixf_14(mode_pixf_14),
  154.  
  155.                 .mode_bw(video_bw)
  156.         );
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.         // vertical sync generator
  164.         video_sync_v video_sync_v(
  165.  
  166.                 .clk(clk),
  167.  
  168.                 .mode_atm_n_pent(mode_atm_n_pent),
  169.                 .mode_60hz(mode_60hz),
  170.  
  171.                 .hsync_start(hsync_start),
  172.                 .line_start(line_start),
  173.                 .hint_start(hint_start),
  174.  
  175.                 .vblank(vblank),
  176.                 .vsync(vsync),
  177.                 .vpix(vpix),
  178.  
  179.                 .int_start(int_start)
  180.         );
  181.  
  182.  
  183.         // horizontal sync generator
  184.         video_sync_h video_sync_h(
  185.  
  186.                 .clk(clk),
  187.  
  188.                 .mode_atm_n_pent(mode_atm_n_pent),
  189.                 .mode_a_text    (mode_a_text),
  190.  
  191.  
  192.                 .init(1'b0),
  193.  
  194.                 .pre_cend(pre_cend),
  195.                 .cend    (cend    ),
  196.  
  197.  
  198.                 .hblank(hblank),
  199.                 .hsync(hsync),
  200.                 .hpix(hpix),
  201.  
  202.                 .line_start(line_start),
  203.                 .hsync_start(hsync_start),
  204.  
  205.                 .hint_start(hint_start),
  206.  
  207.                 .scanin_start(scanin_start),
  208.  
  209.                 .fetch_start(fetch_start),
  210.                 .fetch_end  (fetch_end  )
  211.  
  212.         );
  213.  
  214.  
  215.         // address generation
  216.         video_addrgen video_addrgen(
  217.  
  218.                 .clk(clk),
  219.  
  220.                 .video_addr(video_addr),
  221.                 .video_next(video_next),
  222.  
  223.                 .line_start(hsync_start),
  224.                 .int_start (int_start ),
  225.                 .vpix      (vpix      ),
  226.  
  227.                 .scr_page(scr_page),
  228.  
  229.                 .typos(typos),
  230.  
  231.                 .mode_atm_n_pent (mode_atm_n_pent ),
  232.                 .mode_zx         (mode_zx         ),
  233.                 .mode_p_16c      (mode_p_16c      ),
  234.                 .mode_p_hmclr    (mode_p_hmclr    ),
  235.                 .mode_a_hmclr    (mode_a_hmclr    ),
  236.                 .mode_a_16c      (mode_a_16c      ),
  237.                 .mode_a_text     (mode_a_text     ),
  238.                 .mode_a_txt_1page(mode_a_txt_1page)
  239.         );
  240.  
  241.  
  242.         // data fetch
  243.         video_fetch video_fetch(
  244.  
  245.                 .clk(clk),
  246.  
  247.                 .pre_cend (pre_cend),
  248.                 .cend     (cend    ),
  249.  
  250.                 .vpix(vpix),
  251.  
  252.                 .fetch_start(fetch_start),
  253.                 .fetch_end  (fetch_end  ),
  254.  
  255.                 .fetch_sync (fetch_sync ),
  256.  
  257.                 .video_data  (video_data  ),
  258.                 .video_strobe(video_strobe),
  259.                 .video_go    (video_go    ),
  260.  
  261.                 .pic_bits(pic_bits)
  262.         );
  263.  
  264.  
  265.         // render fetched data to pixels
  266.         video_render video_render(
  267.  
  268.                 .clk(clk),
  269.  
  270.                 .pic_bits(pic_bits),
  271.  
  272.                 .fetch_sync(fetch_sync),
  273.  
  274.                 .cbeg     (cbeg     ),
  275.                 .post_cbeg(post_cbeg),
  276.                 .pre_cend (pre_cend ),
  277.                 .cend     (cend     ),
  278.  
  279.                 .int_start(int_start),
  280.  
  281.                 .mode_atm_n_pent(mode_atm_n_pent),
  282.                 .mode_zx        (mode_zx        ),
  283.                 .mode_p_16c     (mode_p_16c     ),
  284.                 .mode_p_hmclr   (mode_p_hmclr   ),
  285.                 .mode_a_hmclr   (mode_a_hmclr   ),
  286.                 .mode_a_16c     (mode_a_16c     ),
  287.                 .mode_a_text    (mode_a_text    ),
  288.                 .mode_pixf_14   (mode_pixf_14   ),
  289.  
  290.                 .typos(typos),
  291.  
  292.                 .pixels(pixels),
  293.  
  294.  
  295.                 .fnt_a (fnt_a ),
  296.                 .fnt_d (fnt_d ),
  297.                 .fnt_wr(fnt_wr),
  298.  
  299.                 .fontrom_readback(fontrom_readback)
  300.         );
  301.  
  302.  
  303.         // combine border and pixels, apply palette
  304.         video_palframe video_palframe(
  305.  
  306.                 .clk(clk),
  307.  
  308.                 .hblank(hblank),
  309.                 .vblank(vblank),
  310.  
  311.                 .hpix(hpix),
  312.                 .vpix(vpix),
  313.  
  314.                 .pixels(pixels),
  315.                 .border(zxborder),
  316.  
  317.                 .atm_palwr  (atm_palwr  ),
  318.                 .atm_paldata(atm_paldata),
  319.  
  320.                 .color(color),
  321.  
  322.                 .palcolor(palcolor) // palette readback
  323.         );
  324.  
  325.  
  326.         // VGA hsync doubling
  327.         video_vga_sync_h video_vga_sync_h(
  328.  
  329.                 .clk(clk),
  330.  
  331.                 .hsync_start(hsync_start),
  332.  
  333.                 .scanout_start(scanout_start),
  334.  
  335.                 .vga_hsync(vga_hsync)
  336.         );
  337.  
  338.  
  339.         // VGA scandoubling
  340.         video_vga_double video_vga_double(
  341.  
  342.                 .clk(clk),
  343.  
  344.                 .hsync_start  (hsync_start  ),
  345.                 .scanout_start(scanout_start),
  346.                 .scanin_start (scanin_start ),
  347.  
  348.                 .pix_in(color),
  349.  
  350.                 .pix_out(vga_color)
  351.         );
  352.  
  353.  
  354.         // final MUXing of VGA and TV signals
  355.         video_outmux video_outmux(
  356.  
  357.                 .clk(clk),
  358.  
  359.                 .vga_on(vga_on),
  360.  
  361.  
  362.                 .tvcolor(color),
  363.                 .vgacolor(vga_color),
  364.  
  365.                 .vga_hsync(vga_hsync),
  366.                 .hsync    (hsync    ),
  367.                 .vsync    (vsync    ),
  368.  
  369.                 .vred(vred),
  370.                 .vgrn(vgrn),
  371.                 .vblu(vblu),
  372.  
  373.                 .vhsync(vhsync),
  374.                 .vvsync(vvsync),
  375.                 .vcsync(vcsync)
  376.         );
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383. endmodule
  384.  
  385.