2019-01-17 13:35:52 +01:00
|
|
|
module example (
|
2019-01-05 17:02:01 +01:00
|
|
|
input clk,
|
2019-03-06 02:27:58 +01:00
|
|
|
input SW1,
|
|
|
|
|
input SW2,
|
2019-01-05 17:02:01 +01:00
|
|
|
output LED1,
|
|
|
|
|
output LED2,
|
|
|
|
|
output LED3,
|
2019-03-06 02:27:58 +01:00
|
|
|
output LED4
|
2019-01-05 17:02:01 +01:00
|
|
|
);
|
|
|
|
|
|
2019-03-06 02:27:58 +01:00
|
|
|
localparam BITS = 4;
|
2019-01-05 17:02:01 +01:00
|
|
|
localparam LOG2DELAY = 22;
|
|
|
|
|
|
|
|
|
|
reg [BITS+LOG2DELAY-1:0] counter = 0;
|
|
|
|
|
reg [BITS-1:0] outcnt;
|
|
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
2019-03-06 02:27:58 +01:00
|
|
|
counter <= counter + SW1 + SW2 + 1;
|
2019-01-05 17:02:01 +01:00
|
|
|
outcnt <= counter >> LOG2DELAY;
|
|
|
|
|
end
|
|
|
|
|
|
2019-03-06 02:27:58 +01:00
|
|
|
assign {LED1, LED2, LED3, LED4} = outcnt ^ (outcnt >> 1);
|
2019-01-05 17:02:01 +01:00
|
|
|
endmodule
|