Xillinx의 Vivado를 이용하여 FPGA에 프로그램을 올려 Counter를 만들어보겠습니다.
먼저 첫째로 0~9까지 카운트를 하는데 스위치를 이용하여 fnd의 위치에 따라서 켜지게 해보겠습니다.
counter를 만들기위해 clk, counter, fnd_decoder, dec 2x4모듈을 만들어 합치는 작업을 합니다.
module clk_1Mhz(in_clk, in_reset, out_clk);
input in_clk, in_reset;
output out_clk;
reg out_clk = 0;
reg [31:0] count = 0;
always@(posedge in_clk or posedge in_reset) begin
if(in_reset) begin
count <= 0;
end
else begin
if(count == 50_000_000)begin
out_clk <= ~out_clk;
count<=0;
end
else begin
count <= count +1;
end
end
end
endmodule
module counter(in_clk, in_reset, out_value);
input in_clk, in_reset;
output [3:0] out_value;
reg[3:0] out_value =0;
always@(posedge in_clk or posedge in_reset) begin
if(in_reset) begin
out_value <=0;
end
else if (in_clk) begin
out_value <= out_value+1;
if(out_value == 9)
out_value<= 0;
end
end
endmodule
module fnd_decoder(in_data,out_fndFont);
input [3:0]in_data;
output [7:0] out_fndFont;
reg[7:0] out_fndFont;
always@(*)begin
//out_fndFont = 8'hff;
case (in_data)
default : out_fndFont = 8'hc0;//
1 : out_fndFont = 8'hf9;
2 : out_fndFont = 8'ha4;
3 : out_fndFont = 8'hb0;
4 : out_fndFont = 8'h99;
5 : out_fndFont = 8'h92;
6 : out_fndFont = 8'h82;
7 : out_fndFont = 8'hf8;
8 : out_fndFont = 8'h80;
9 : out_fndFont = 8'h90;
endcase
end
endmodule
module dec_2x4(in_sel, out_sel);
input [1:0] in_sel;
output [3:0] out_sel;
reg[3:0] out_sel;
always@(*) begin
case(in_sel)
1: out_sel = 4'b1101;
2: out_sel = 4'b1011;
3: out_sel = 4'b0111;
default: out_sel = 4'b1110;
endcase
end
endmodule

제조사에서 제공하는 데이터 시트를 이용하여 I/O Planning을 진행하였습니다.

다음은 동작 검증을 해보겠습니다.

위의 그림과같이 애너드는 0일때 작동을하므로 00일때 1110, 01일때 1101, 10일때 1011, 11일때 0111이므로 잘 검증이 되었다고 알 수 있습니다.
이를 동영상을 통해 완성된 결과를 확인해보겠습니다.
다음내용은 다음에
'나의 전자 공부방 > FPGA' 카테고리의 다른 글
| vivado, FPGA로 Stopwatch 만들기 (0) | 2023.05.15 |
|---|---|
| vivado, FPGA로 LED right hift, LED left shift하기 (0) | 2023.05.15 |
| vivado, FPGA를 이용해서 시계(TimeClock)만들기 (0) | 2023.05.10 |
| vivado의 create block design을 사용해서 apb 만들기 (0) | 2023.04.19 |