gateware/simple: Demo tweaks

Signed-off-by: David Shah <dave@ds0.me>
master
David Shah 6 years ago
parent 63ba407fbc
commit d3a4f9b402

@ -7,10 +7,11 @@ module demo_top(
output [11:0] led output [11:0] led
); );
reg [11:0] ctr_scroll = 1'b1; reg [35:0] ctr_scroll;
reg [35:0] ctr_scroll_swapped;
reg clk_div = 0; reg clk_div = 0;
localparam DIV = 21; localparam DIV = 20;
reg [DIV-1:0] div_ctr = 0; reg [DIV-1:0] div_ctr = 0;
always @(posedge clk_12) begin always @(posedge clk_12) begin
@ -18,16 +19,28 @@ module demo_top(
if (clk_div) begin if (clk_div) begin
if (!(|ctr_scroll)) if (!(|ctr_scroll))
ctr_scroll <= 1'b1; ctr_scroll <= {1'b1, {10{1'b0}}, 1'b1, {13{1'b0}}, 1'b1};
else else
ctr_scroll <= {ctr_scroll[10:0], ctr_scroll[11]}; ctr_scroll <= {ctr_scroll[34:24], ctr_scroll[35],
ctr_scroll[22:12], ctr_scroll[23],
ctr_scroll[10:0], ctr_scroll[11]};
end end
end end
integer i, j;
always @(posedge clk_12) begin
for (i = 0; i < 36; i = i + 6)
for (j = 0; j < 6; j = j + 1)
if ((i % 12) == 0)
ctr_scroll_swapped[i+j] <= ctr_scroll[i+j];
else
ctr_scroll_swapped[i+j] <= ctr_scroll[i+5-j];
end
led_ctrl led_ctrl_i ( led_ctrl led_ctrl_i (
.clk(clk_12), .clk(clk_12),
.led_in_yr({ctr_scroll[5:0], dip_sw[1:0], btn}), .led_in_yr({ctr_scroll_swapped[23:12] | ctr_scroll_swapped[35:24]}),
.led_in_bg({dip_sw[7:2], ctr_scroll[11:6]}), .led_in_bg({ctr_scroll_swapped[11:0] | ctr_scroll_swapped[35:24]}),
.led_pin(led) .led_pin(led)
); );

@ -16,6 +16,10 @@ module led_ctrl (
always @(posedge clk) ctr <= ctr + 1'b1; always @(posedge clk) ctr <= ctr + 1'b1;
wire pwm_1_4 = ctr[DIV_FACTOR - 1 : DIV_FACTOR - 2] > 2'b10;
wire pwm_7_8 = ctr[DIV_FACTOR - 1 : DIV_FACTOR - 3] > 2'b000;
genvar i; genvar i;
wire [11:0] led_o, led_en; wire [11:0] led_o, led_en;
generate generate
@ -23,14 +27,16 @@ module led_ctrl (
/* /*
Only YR asserted : LED at constant 1'b0 Only YR asserted : LED at constant 1'b0
Both YR & BG asserted : blend colour by connecting LED to divider MSB Both YR & BG asserted : blend colour by connecting LED to divider MSB
NB: bias towards yellow (i<6) or green (i>=6) for better white/orange
Only BG asserted : LED at constant 1'b1 Only BG asserted : LED at constant 1'b1
Neither asserted : LED off (1'bz) Neither asserted : LED off (1'bz)
*/ */
assign led_o[i] = led_in_yr[i] ? assign led_o[i] = led_in_yr[i] ?
(led_in_bg[i] ? ctr[DIV_FACTOR - 1] : 1'b0) : (led_in_bg[i] ? (i < 6 ? pwm_1_4 : pwm_7_8) : 1'b0) :
1'b1; 1'b1;
assign led_en[i] = led_in_yr[i] || led_in_bg[i]; assign led_en[i] = led_in_yr[i] || led_in_bg[i];
assign led_pin[i] = led_en[i] ? led_o[i] : 1'bz; assign led_pin[i] = led_en[i] ? led_o[i] : 1'bz;
//BB bb_i (.I(led_o[i]), .T(~led_en[i]), .B(led_pin[i]));
end end
endgenerate endgenerate

Loading…
Cancel
Save