Created
September 8, 2014 11:23
-
-
Save aki-lua87/1a46f544f89b794139d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module led_light(KEY0,LED[1:0],CLK); | |
input KEY0,CLK; /* CLK PIN_R8 */ | |
output [1:0] LED; /* LED0:PIN_B5 LED1:debug */ | |
reg [126:0] rand; | |
reg [6:0] offset; | |
reg [25:0] count = 0; | |
/* led output ***************************************/ | |
function[126:0] randc; | |
input [6:0] rand; | |
integer i; | |
begin | |
randc[6:0] = rand; | |
i = 7; | |
while(i < 127) begin | |
randc[i] = randc[i-7]^randc[i-1]; | |
i = i+1; | |
end | |
end | |
endfunction | |
function disp; | |
input [6:0] j; | |
input [126:0] rand; | |
integer i; | |
begin | |
for (i = 0; i < 1; i = i + 1) begin | |
disp = rand[i + j]; | |
end | |
end | |
endfunction | |
always @(posedge CLK) begin | |
if(count == 1250) count <= 0; /* 1250 = 25us */ | |
else count <= count +1; | |
end | |
assign enable = (count == 0)?1:0; | |
always @(posedge CLK) begin | |
if(enable == 1) begin | |
rand = randc(7'b1111111); | |
offset = offset +1; end | |
end | |
assign LED[0] = disp(offset, rand); | |
/* assign LED[1] = disp(offset, rand); debug*/ | |
/* LED output end ************************** */ | |
/* *********************************************** */ | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment