Subversion Repositories pentevo

Rev

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