no image
[Verilog] 7. 교통신호기 FSM
교통신호기 다시 FSM을 이용하여 RED, GREEN, YELLOW가 있는 신호등을 만들어 볼 것입니다. PED는 보행자가 요청하면 건널 수 있는 스위치를 설치한다는 가정입니다. 각각의 신호의 시간 계산을 따로하지 않고 하나의 함수를 이용하여 계산을 진행할 예정입니다. my_signal`timescale 1ns / 1psmodule my_signal( input RST, input CLK, input [6:0] time_slot, input start, output [6:0] curr_slot, output done ); parameter CLK_FREQ = 125_000_000;wire [29:0] MAX_CNT = time_slot + CLK_F..
2024.04.29
no image
[Verilog] 6.FSM Security
FSM Security저번에 포스팅한 FSM을 이용한 Security를 만드는 Verilog code를 만들어 보겠습니다.2개의 블럭을 만들어 연결하는 방식으로 Hardware를 구성해 보겠습니다.my_fsm_sec`timescale 1ns / 1psmodule my_fsm_sec #(parameter CLK_FREQ = 125_000_000) // parameter로 CLK_FREQ 지정( input RST, input CLK, input [1:0] KEYPAD, input SENSOR, output reg [1:0] FSM_state, output reg Alarm_sys ); localparam [1:0] disarmed = 2'b..
2024.04.29
no image
[Verilog] 5. FSM Demo.
FSM(Finite State Machine)  FSM, 즉 유한상태머신은 지정된 수의 상태 변화에 따라 출력을 조절하는 머신입니다.input과 현재상태에 따라 output을 출력하는 Next state logic, 현재 상태를 저장하는 State Register, 입력과 현재상태에 따라 출력을 선택하는 Output Logic으로 구성됩니다. 저는 Switch와 LED를 통해 입력과 출력의 변화를 확인하도록 코드를 작성할 것입니다.FSM Code`timescale 1ns / 1psmodule my_fsm( input RST, input CLK, input [1:0] SWT, output reg [1:0] LED, output VCC //output GND ); ..
2024.04.26
no image
[Verilog] 4. 1 Sec Counter- (Cora-z7)
1Sec Counter 설계설계 요구사항- RST = 1일 경우 LED off, RST = 0일 경우 1초 마다 LED on/off- 내부 counter를 설계하여 1초마다 enable 되는 신호 생성 enable 신호를 이용하여 출력을 반전 시키는 회로 설계  `timescale 1ns / 1ps//////////////////////////////////////////////////////////////////////////////////module my_1sec( input RST, input CLK, output reg LED ); parameter clk_freq = 125_000_000;reg enable;reg [31:0] cnt;always @(posedge CL..
2024.04.01
no image
[Verilog] 3. Counter / Testbench- (Cora-z7)
Counter 설계설계 요구사항- CLK의 상승 Edge마다 up_down 신호가 High면 내부 32bit Counter가 증가, Low면 감소- 상위 3bit를 LED를 활용하여 출력 동작 확인`timescale 1ns / 1psmodule my_count( input RST, input CLK, input DIR, output [2:0] LED ); reg [31:0] cnt; //32bit register로 cnt 값 저장 assign LED = cnt[31:29]; // cnt의 상위 3 bit LED 출력으로 할당 always @(posedge CLK) // CLK 의 신호 상승 Edge가 감지될 때마다.begin if(R..
2024.04.01
no image
[Verilog] 2. 2Bit Adder - (Cora-z7)
기본의 2bit adder는 Half adder와 Full adder로 이루어져있습니다. 하지만 이번 포스팅에서는 Full adder 두 개로 이루어진 2bit adder를 구성해 보겠습니다.module my_4bit_fadder( input [1:0] A, input [1:0] B, output [1:0] S, output Co ); wire [1:0]ca;assign Co = ca[1];my_fadder fa0( .A(A[0]), .B(B[0]), .Ci(1'b0), .S(S[0]), .Co(ca[0]) ); my_fadder fa1( .A(A[1]), .B(B[1]), .Ci(ca[0]), .S(S[1]..
2024.03.29
no image
[Verilog] 1. Vivado 전가산기(Full Adder) - (Cora-z7)
전가산기  기존에 만들어둔 반가산기를 사용합니다. Create Source로 새로운 디자인으로 전가산기를 만들면 두 개의 Design Source가 구성되어 있는 모습을 확인 할 수있습니다. 그 후 Create된 파일에 Verilog 코드를 위와 같이 작성합니다. Full adder는 Half adder 2개와 1개의 OR로 이루어져 있기 때문에 그점을 이용하여 코드를 작성할 것입니다.코드 작성 후 저장을 하면 Source의 디렉토리가 변경된 모습을 확인할 수 있습니다.Open Elaborated Design을 하면 위 사진과 같이 Half Adder 두개와 OR Gate로 이루어진 Full Adder를 확인 할 수 있습니다.Run Synthesis 에서 Open Synthesized Design을 선택..
2024.03.29
no image
[Verilog] 0. VIVADO project 만들기 - 2(Cora-z7)
Full Adder이번에는 Half Adder에 이어서 Full Adder를 구성해 보겠습니다.이번 Full Adder는 Input port가 3개로 전에 구성했던 Half Adder에 비하여 1개 더 추가되었습니다. 하지만 제가 사용하는 보드는 버튼이 2개 존재하기 때문에 PMOD Switch를 연결해 3개의 입력으로 구성해 보겠습니다.Schematic을 확인 후 JA1~6까지 PMOD SWT와 연결합니다.PMOD SWT와 연결된 JA1~4는 Y19~Y16에 연결된 구성을 확인할 수 있습니다.이전 포스팅과 동일하게 파일을 생성 후 I/O Port를 구성해 줍니다.wire로 A xor B, A and B, Ci and (A xor B)를 선언합니다.위의 Schematic I/O Port에 맞추어 Pin ..
2024.03.19
no image
[Verilog] 0. VIVADO project 만들기 - 1(Cora-z7)
오늘은 Verilog의 Simulation Tool인 Vivado에서 프로젝트를 만들어 보겠습니다. Vivado Downloadhttps://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools.html DownloadsVivado, Vitis, Vitis Embedded Platform, PetaLinux, Device modelswww.xilinx.comAMD 홈페이지에서 회원가입 후 위의 파일을 설치해 vivado를 다운로드합니다. Half Adder 위에 보이는 'Quick Start'에서 'Create Project'를 클릭합니다. 저는 Half Adder를 설계해 볼 것이기 때문에 ..
2024.03.19