Advertisement
Guest User

Untitled

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