daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Oct 24th, 2018 91 in 181 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module top (
  2.     input CLK,    // 16MHz clock
  3.     output LED,   // User/boot LED next to power LED
  4.     output PIN_3,
  5.     output PIN_4,
  6.     output PIN_5,
  7.     output PIN_6,
  8.     output PIN_7,
  9.     output PIN_8,
  10.     output PIN_9,
  11.     output PIN_10,
  12.     output PIN_11,
  13.     output PIN_12,
  14.     output PIN_13,
  15.     output PIN_14,
  16.     output PIN_15,
  17.     output PIN_16,
  18.     output PIN_17,
  19.     output PIN_18,
  20.     output PIN_19,
  21.     output PIN_20,
  22.     output PIN_21,
  23.     output PIN_22,
  24.     output PIN_23,
  25.     output PIN_24,
  26.     output USBPU  // USB pull-up resistor
  27. );
  28.     // drive USB pull-up resistor to '0' to disable USB
  29.     assign USBPU = 0;
  30.  
  31.     //pwm counter 0-1023 possible values
  32.     reg [9:0] pwm_counter;
  33.  
  34.     reg [9:0] led_01_duty ;
  35.     reg [9:0] led_02_duty ;
  36.     reg [9:0] led_03_duty ;
  37.     reg [9:0] led_04_duty ;
  38.     reg [9:0] led_05_duty ;
  39.     reg [9:0] led_06_duty ;
  40.     reg [9:0] led_07_duty ;
  41.     reg [9:0] led_08_duty ;
  42.     reg [9:0] led_09_duty ;
  43.     reg [9:0] led_10_duty ;
  44.     initial led_01_duty = 10'b0100000000;
  45.     initial led_02_duty = 10'b0010000000;
  46.     initial led_03_duty = 10'b0001000000;
  47.     initial led_04_duty = 10'b0000100000;
  48.     initial led_05_duty = 10'b0000010000;
  49.     initial led_06_duty = 10'b0000001000;
  50.     initial led_07_duty = 10'b0000000100;
  51.     initial led_08_duty = 10'b0000000010;
  52.     initial led_09_duty = 10'b0000000001;
  53.     initial led_10_duty = 10'b0000000001;
  54.     ////////
  55.     // make a simple blink circuit
  56.     ////////
  57.  
  58.     // keep track of time and location in blink_pattern
  59.     reg [25:0] blink_counter;
  60.  
  61.     // pattern that will be flashed over the LED over time
  62.     wire [31:0] blink_pattern = 32'b101010001110111011100010101;
  63.  
  64.     // increment the blink_counter every clock
  65.     always @(posedge CLK) begin
  66.         blink_counter <= blink_counter + 1;
  67.         pwm_counter <=  pwm_counter + 1;
  68.     end
  69.     //assign led = led_pwm > pwm_cnt;
  70.     // light up the LED according to the pattern
  71.     assign LED = blink_pattern[blink_counter[25:21]];
  72.  
  73.  
  74.     assign PIN_4 = pwm_counter <= led_10_duty;
  75.     assign PIN_5 = pwm_counter <= led_09_duty;
  76.     assign PIN_6 = pwm_counter <= led_08_duty;
  77.     assign PIN_7 = pwm_counter <= led_07_duty;
  78.     assign PIN_8 = pwm_counter <= led_06_duty;
  79.     assign PIN_9 = pwm_counter <= led_05_duty;
  80.     assign PIN_10 = pwm_counter <= led_04_duty;
  81.     assign PIN_11 = pwm_counter <= led_03_duty;
  82.     assign PIN_12 = pwm_counter <= led_02_duty;
  83.     assign PIN_13 = pwm_counter <= led_01_duty;
  84.  
  85.  
  86.  
  87.     assign PIN_14 = pwm_counter <= led_01_duty;
  88.     assign PIN_15 = pwm_counter <= led_02_duty;
  89.     assign PIN_16 = pwm_counter <= led_03_duty;
  90.     assign PIN_17 = pwm_counter <= led_04_duty;
  91.     assign PIN_18 = pwm_counter <= led_05_duty;
  92.     assign PIN_19 = pwm_counter <= led_06_duty;
  93.     assign PIN_20 = pwm_counter <= led_07_duty;
  94.     assign PIN_21 = pwm_counter <= led_08_duty;
  95.     assign PIN_22 = pwm_counter <= led_09_duty;
  96.     assign PIN_23 = pwm_counter <= led_10_duty;
  97. endmodule
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top