Skip to content

Instantly share code, notes, and snippets.

@musaprg
Last active March 11, 2017 06:19
Show Gist options
  • Save musaprg/8e11490a2c8956babd91bb5264b1bd28 to your computer and use it in GitHub Desktop.
Save musaprg/8e11490a2c8956babd91bb5264b1bd28 to your computer and use it in GitHub Desktop.
Lチカ with CycloneIV @ FPGAスタートアップ講座第5回
//module name must be set the same one as Project Name.
//module name must be set with alphabet, not only number.
module sample (out,clk);
//signal input and output of module
input clk;
output out;
//set 25bit variable. [24][23][22]...[3][2][1][0] as "count"
reg[24:0]count;
assign out = count[24];
//posedge -> positive signal
//negedge -> negative signal
always @(posedge(clk)) begin
count = count + 1;
end
//50MHz -> 20ns / count
//2^25 = 3.4*10^7 times counts.
// 3.4*10^7 * 20ns = 0.67 s ??
endmodule
module sample (led1,led2,clk,btn);
input clk;
input btn;
output led1;
output led2;
reg[24:0]count;
assign led1 = count[24];
assign led2 = btn;
always @(posedge(clk)) begin
if(btn == 0) count <= count + 1;
end
endmodule
@musaprg
Copy link
Author

musaprg commented Mar 11, 2017

verilogHDLコードをコンパイル→PinPlannnerで各inputとoutputをassign→pinanalysis

@musaprg
Copy link
Author

musaprg commented Mar 11, 2017

Lチカできなかったのにコメント消したら動いたキレそう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment