Subversion Repositories pentevo

Rev

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