Guest User

Untitled

a guest
Apr 21st, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //////////////////////////////////////////////////////////////////////////////////
  2. // TOP MODULE
  3. //////////////////////////////////////////////////////////////////////////////////
  4. module finalproject( sysclk, switches, buttons, red, grn, blue, hsync, vsync );
  5. //port declaration
  6. input sysclk;
  7. input [7:0] switches;
  8. input [3:0] buttons;
  9. output [2:0] red;
  10. output [2:0] grn;
  11. output [1:0] blue;
  12. output hsync;
  13. output vsync;
  14. //internal registers
  15. integer cursorx = 6'b0;
  16. integer cursory = 5'b0;
  17. wire kb_int = 1'b0;
  18. wire [6:0] kb_data;
  19. wire [10:0] tiles_addr;
  20. wire [6:0] tiles_dout;
  21.  
  22. //initialize vgacontroller and pass ports
  23. vgacontroller vga1(
  24. .sysclk (sysclk),
  25. .red (red),
  26. .grn (grn),
  27. .blue (blue),
  28. .vsync (vsync),
  29. .hsync (hsync),
  30. .tiles_addr(tiles_addr),
  31. .tiles_dout(tiles_dout)
  32. );
  33.  
  34. TileManager tm1 (
  35. .sysclk(sysclk),
  36. .tiles_addr(tiles_addr),
  37. .tiles_dout(tiles_dout)
  38. );
  39.  
  40. endmodule
  41.  
  42.  
  43. `timescale 1ns / 1ps
  44. //////////////////////////////////////////////////////////////////////////////////
  45. // PixelPipeline - instantiated on same level as TileManager
  46. //////////////////////////////////////////////////////////////////////////////////
  47. module PixelPipeline(sysclk,clk,pix_x,pix_y,pixel_lit, tiles_addr, tiles_dout);
  48. //port declarations
  49. input sysclk;
  50. input clk;
  51. input pix_x;
  52. input pix_y;
  53. output tiles_addr;
  54. input tiles_dout;
  55. output pixel_lit;
  56. //internal registers
  57. wire [9:0] pix_x;
  58. wire [9:0] pix_y;
  59. reg pixel_lit;
  60. wire [4:0] row;
  61. wire [5:0] col;
  62. wire [3:0] row_counter;
  63. wire [3:0] col_counter;
  64. reg [10:0] fm_addr;
  65. wire [15:0] fm_dout;
  66. reg [10:0] tiles_addr;
  67. wire [6:0] tiles_dout;
  68.  
  69. assign row =  pix_y >> 4;
  70. assign col =  pix_x >> 4;
  71. assign row_counter = pix_y;
  72. assign col_counter = pix_x;
  73.  
  74. font_map font (
  75.   .clka(sysclk), // input clka
  76.   .addra(fm_addr), // input [10 : 0] addra
  77.   .douta(fm_dout) // output [15 : 0] douta
  78. );
  79.  
  80. initial begin
  81.     tiles_addr = 0;
  82.     fm_addr = 0;
  83.     pixel_lit = 0;
  84. end
  85.  
  86. always @ (posedge sysclk)
  87. begin
  88.     // needs to notice when col_counter is getting close to rolling over, and prepare new col's data
  89.     if(col_counter == 14)begin
  90.         tiles_addr = row;
  91.         tiles_addr = tiles_addr << 6 | col+1;
  92.     end
  93. end
  94.  
  95. always @ (posedge sysclk)
  96. begin
  97.     fm_addr = tiles_dout - 32;
  98.     fm_addr = fm_addr << 4 | row_counter;
  99. end
  100.  
  101. always @ (posedge sysclk)
  102. begin
  103.     pixel_lit = fm_dout[col_counter];
  104. end
  105.  
  106. endmodule
  107.  
  108.  
  109.  
  110. //////////////////////////////////////////////////////////////////////////////////
  111. // TileManager - RAM WRAPPER
  112. //////////////////////////////////////////////////////////////////////////////////
  113. module TileManager( sysclk, tiles_addr, tiles_dout );
  114. //port declaration
  115. input sysclk;
  116. input tiles_addr;
  117. output tiles_dout;
  118. //internal registers
  119.  
  120. tile_map tilesRAM (
  121.   .clka(sysclk), // input clka
  122.   .wea(wea), // input [0 : 0] wea
  123.   .addra(addra), // input [10 : 0] addra
  124.   .dina(dina), // input [6 : 0] dina
  125.   .clkb(sysclk), // input clkb
  126.   .addrb(tiles_addr), // input [10 : 0] addrb
  127.   .doutb(tiles_dout) // output [6 : 0] doutb
  128. );
  129.  
  130. endmodule
Advertisement
Add Comment
Please, Sign In to add comment