You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

steuerung.sv 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. module steuerung (
  2. bus.steuerung_port b, //b.dip[3:0], b.timer, b.clk, b.spi_read[1:0]
  3. led_if.led_port_top i //i.rgb[2:0], i.rgbn[2:0]
  4. );
  5. //dip[3:2] -> select colour, dip[1] -> read ~ 1/write ~ 0, dip[0] -> on ~ 1/off ~ 0
  6. //input wire clk12M, -> b.clk
  7. //input wire rst, -> b.dip[0]
  8. //input wire [1:0] color_sel, -> b.dip[3:2]
  9. //input wire rw, -> b.dip[1]
  10. //output reg REDn, -> i.rgbn[0]
  11. //output reg BLUn, -> i.rgbn[1]
  12. //output reg GRNn, -> i.rgbn[2]
  13. //output reg RED, -> i.rgb[0]
  14. //output reg BLU, -> i.rgb[1]
  15. //output reg GRN -> i.rgb[2]
  16. wire red_pwm;
  17. wire grn_pwm;
  18. wire blu_pwm;
  19. defparam U1.on_hi = 2'b10;
  20. defparam U1.on_lo = 2'b01;
  21. defparam U1.off = 2'b00;
  22. defparam U1.LED_OFF = 2'b00;
  23. defparam U1.RAMP_UP = 2'b01;
  24. defparam U1.LED_ON = 2'b10;
  25. defparam U1.RAMP_DOWN = 2'b11;
  26. defparam U1.on_max_cnt = 28'h16E35ED; // 1 sec steady
  27. defparam U1.Brightness = 4'b0111; // 50% Brightness
  28. defparam U1.BreatheRamp = 4'b0110; // 2x
  29. defparam U1.BlinkRate = 4'b0101; // 1 sec
  30. defparam U2.RGB0_CURRENT = "0b111111";
  31. defparam U2.RGB1_CURRENT = "0b111111";
  32. defparam U2.RGB2_CURRENT = "0b111111";
  33. LED_control1 U1 (.clk12M(b.clk),.rst(b.dip[0]),.color_sel(b.dip[3:2]),.rw(b.dip[1]),.red_pwm(red_pwm),.blu_pwm(blu_pwm),.grn_pwm(grn_pwm));
  34. RGB U2 (.CURREN('b1),.RGB0PWM(blu_pwm),.RGB1PWM(grn_pwm),.RGB2PWM(red_pwm),.RGBLEDEN('b1),.RGB0(i.rgbn[1]),.RGB1(i.rgbn[2]),.RGB2(rgbn[0]));
  35. assign i.rgb[0] = red_pwm;
  36. assign i.rgb[2] = grn_pwm;
  37. assign i.rgb[1] = blu_pwm;
  38. endmodule