gateware: Blinky working

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

@ -1,3 +1,5 @@
`default_nettype none
module demo_top(
input clk_12,
input [3:0] btn,
@ -8,10 +10,10 @@ module demo_top(
reg [11:0] ctr_scroll = 1'b1;
reg clk_div = 0;
localparam DIV = 20;
localparam DIV = 21;
reg [DIV-1:0] div_ctr = 0;
always @(posedge clk) begin
always @(posedge clk_12) begin
{clk_div, div_ctr} <= div_ctr + 1'b1;
if (clk_div) begin
@ -24,8 +26,8 @@ module demo_top(
led_ctrl led_ctrl_i (
.clk(clk_12),
.led_in_yr({dip_sw, btn}),
.led_in_bg(ctr_scroll),
.led_in_yr({ctr_scroll[5:0], dip_sw[1:0], btn}),
.led_in_bg({dip_sw[7:2], ctr_scroll[11:6]}),
.led_pin(led)
);

@ -17,6 +17,7 @@ module led_ctrl (
always @(posedge clk) ctr <= ctr + 1'b1;
genvar i;
wire [11:0] led_o, led_en;
generate
for (i = 0; i < 12; i = i + 1'b1) begin
/*
@ -25,9 +26,11 @@ module led_ctrl (
Only BG asserted : LED at constant 1'b1
Neither asserted : LED off (1'bz)
*/
assign led_pin[i] = led_in_yr ?
(led_in_bg ? ctr[DIV_FACTOR - 1] : 1'b0) :
(led_in_bg ? 1'b1 : 1'bz);
assign led_o[i] = led_in_yr[i] ?
(led_in_bg[i] ? ctr[DIV_FACTOR - 1] : 1'b0) :
1'b1;
assign led_en[i] = led_in_yr[i] || led_in_bg[i];
assign led_pin[i] = led_en[i] ? led_o[i] : 1'bz;
end
endgenerate

Loading…
Cancel
Save