SHOW:
|
|
- or go back to the newest paste.
1 | `timescale 1ns / 1ps | |
2 | ||
3 | module clock(input clk, input reset, output clk_out); | |
4 | ||
5 | reg [14:0] ctr; | |
6 | assign clk_out = ctr[13]; | |
7 | ||
8 | always @(posedge clk) begin | |
9 | ||
10 | if (reset == 1) ctr = 0; | |
11 | else ctr = ctr + 1; | |
12 | ||
13 | end | |
14 | ||
15 | endmodule | |
16 | ||
17 | module dancingLED(input clk, input reset_clk, input reset_led, output reg [3:0] EN, output reg [7:0] y | |
18 | ); | |
19 | ||
20 | wire clk_out; | |
21 | clock cout(clk,reset_clk,clk_out); | |
22 | ||
23 | ||
24 | always@(posedge clk_out) begin | |
25 | ||
26 | ||
27 | ||
28 | if (reset_led == 1'b1) begin | |
29 | EN = 4'b1110; | |
30 | y = 8'b11111110; | |
31 | end | |
32 | ||
33 | else begin | |
34 | - | if (y[7] == 0) EN = (EN << 1) | (EN >> 3); |
34 | + | if (y[7] == 0) {EN[3:1],EN[0]} = {EN[2:0],EN[3]}; |
35 | - | y = (y << 1) | (y >> 7); |
35 | + | {y[7:1],y[0]} = {y[6:0], y[7]}; |
36 | end | |
37 | ||
38 | end | |
39 | ||
40 | endmodule | |
41 | ||
42 |