Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. module pwm(
  4.     input clk,
  5.     input [3:0] amt,
  6.     output reg out
  7. );
  8.  
  9. reg [3:0] cnt;
  10.  
  11. always @(posedge clk) begin
  12.     {out, cnt} <= cnt + amt;
  13. end
  14.  
  15. endmodule
  16.  
  17.  
  18. module main(
  19.     input hclk,
  20.     output [3:0] vgaRed,
  21.     output [3:0] vgaGreen,
  22.     output [3:0] vgaBlue,
  23.     output Vsync,
  24.     output Hsync,
  25.     input btnC,
  26.     input btnU,
  27.     input btnL,
  28.     input btnR,
  29.     input btnD,
  30.     input [15:0] sw,
  31.     output [15:0] led
  32. );
  33.  
  34. wire feedback, clk, clk_pwm;
  35.  
  36. PLLE2_BASE #(
  37.     .CLKFBOUT_MULT(12), // Multiply value for all CLKOUT, (2-64)
  38.     .CLKIN1_PERIOD(10.0), // Input clock period in ns to ps resolution (i.e. 33.333 is 30 MHz).
  39.     .CLKOUT0_DIVIDE(4),
  40.     .CLKOUT1_DIVIDE(2),
  41.     .DIVCLK_DIVIDE(1),
  42.     .STARTUP_WAIT("TRUE") // Delay DONE until PLL Locks, ("TRUE"/"FALSE")
  43. ) PLLE2_BASE_inst (
  44.     .CLKOUT0(clk),
  45.     .CLKOUT1(clk_pwm),
  46.     .CLKFBOUT(feedback), // 1-bit output: Feedback clock
  47.     .CLKIN1(hclk),
  48.     .CLKFBIN(feedback) // 1-bit input: Feedback clock
  49. );
  50.  
  51. pwm(clk_pwm, sw[3:0], led[15]);
  52.  
  53. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement