cleanup, smaller file, removed stuff that was unnecessary

This commit is contained in:
Bruno Levy
2021-03-29 22:32:45 +02:00
parent d3311fe7b7
commit 76175b25f5

View File

@@ -1,19 +1,24 @@
// Displays hypnotic moving circles with the FOMU
// Need to solder five wires to the FOMU (4 pads plus mass)
// See: https://twitter.com/mntmn/status/1281632873448124417
// https://twitter.com/foone/status/1281740047461396480
// https://github.com/mntmn/fomu-vga
`default_nettype none // Makes it easier to detect typos !
module vga (
input clki, // ->48 Mhz clock input
output rgb0, // \
output rgb1, // >LED
output rgb2, // /
output user_1, // ->hsync
output user_2, // ->vsync
output user_3, // ->color0
output user_4, // ->color1
output usb_dp, // \
output usb_dn, // >USB pins (should be driven low if not used)
output usb_dp_pu // /
);
module vga (
input clki, // ->48 Mhz clock input
output rgb0, // \
output rgb1, // >LED
output rgb2, // /
output user_1, // ->hsync
output user_2, // ->vsync
output user_3, // ->color0
output user_4, // ->color1
output usb_dp, // \
output usb_dn, // >USB pins (should be driven low if not used)
output usb_dp_pu // /
);
// USB pins driven low
assign usb_dp=0;
@@ -24,6 +29,8 @@
// PLL: converts system clock (48 MHz)
// to pixel clock (25.125 MHz for 640x480)
// Values obtained using:
// icepll -i 48 -o 25.125
SB_PLL40_CORE #(
.FEEDBACK_PATH("SIMPLE"),
.DIVR(4'b0011),
@@ -105,46 +112,26 @@
assign user_3 = out_color[0];
assign user_4 = out_color[1];
// LED driver
// Note: the LED driver is more intelligent than I wish, it changes color
// at the same frequency whatever the bit of frame I'm using, I need to
// understand what's going on here (supposed to be a PWM, maybe I should
// generate pulses of varying length to control intensity of r,g,b...)
// Instantiate iCE40 LED driver hard logic, connecting up
// latched button state, counter state, and LEDs.
//
// Note that it's possible to drive the LEDs directly,
// however that is not current-limited and results in
// overvolting the red LED.
//
// See also:
// https://www.latticesemi.com/-/media/LatticeSemi/Documents/ApplicationNotes/IK/ICE40LEDDriverUsageGuide.ashx?document_id=50668
SB_RGBA_DRV RGBA_DRIVER (
.CURREN(1'b1),
.RGBLEDEN(1'b1),
.RGB0PWM(frame[5]), // red
.RGB1PWM(frame[6]), // green
.RGB2PWM(frame[7]), // blue
.RGB0(rgb0),
.RGB1(rgb1),
.RGB2(rgb2)
);
// Parameters from iCE40 UltraPlus LED Driver Usage Guide, pages 19-20
localparam RGBA_CURRENT_MODE_FULL = "0b0";
localparam RGBA_CURRENT_MODE_HALF = "0b1";
// Current levels in Full / Half mode
localparam RGBA_CURRENT_04MA_02MA = "0b000001";
localparam RGBA_CURRENT_08MA_04MA = "0b000011";
localparam RGBA_CURRENT_12MA_06MA = "0b000111";
localparam RGBA_CURRENT_16MA_08MA = "0b001111";
localparam RGBA_CURRENT_20MA_10MA = "0b011111";
localparam RGBA_CURRENT_24MA_12MA = "0b111111";
// Set parameters of RGBA_DRIVER (output current)
//
// Mapping of RGBn to LED colours determined experimentally
defparam RGBA_DRIVER.CURRENT_MODE = RGBA_CURRENT_MODE_HALF;
defparam RGBA_DRIVER.RGB0_CURRENT = RGBA_CURRENT_16MA_08MA; // Blue - Needs more current.
defparam RGBA_DRIVER.RGB1_CURRENT = RGBA_CURRENT_08MA_04MA; // Red
defparam RGBA_DRIVER.RGB2_CURRENT = RGBA_CURRENT_08MA_04MA; // Green
SB_RGBA_DRV led_driver #(
.CURRENT_MODE("0b1"); // half current mode
.RGB0_CURRENT("0b001111"); // Blue - Needs more current.
.RGB1_CURRENT("0b000011"); // Red
.RGB2_CURRENT("0b000011"); // Green
)(
.CURREN(1'b1),
.RGBLEDEN(1'b1),
.RGB0PWM(frame[0]), // red
.RGB1PWM(frame[1]), // green
.RGB2PWM(frame[2]), // blue
.RGB0(rgb0),
.RGB1(rgb1),
.RGB2(rgb2)
);
endmodule