Subversion Repositories pentevo

Rev

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