본문 바로가기

분류 전체보기

(142)
Quartus II Project - notes [2] Always / Initial Blocks (Procedural Assignments) 1. initial - each 'initial' blocks executes concurrently starting at time 0. - executes only 'once' and does not execute again. module system; reg a, b, c, d; // single statement initial a = 1'b0; // time 0 : power ON initial begin b = 1'b1; #5 c = 1'b0; #10 d = 1'b0; end initial #20 $finish; endmodule 2. always - each 'always' blocks executes con..
Quartus II project - notes [1]
Quartus II project - Simple Uart Tx. BPS : 115200 DE1-SoC Board default Frequency : 50Mhz [20ns] 1/115200 = 0.00000868s = 0.00868ms = 8.68us = 8680ns [1bit] need to maintain 434 cycles to make 8680ns. // 434 counter = 8680ns reg [3:0] cst; //idle ~ stop_1, 12 state reg [3:0] nst; reg [8:0] clk_count; // 512, 9bit always @(posedge clk, negedge reset_n) begin if(!reset_n) begin // active low clk_count
Quartus II Project - fnd counter module fnd_counter ( input clk, input reset_n, output seg_a, seg_b, seg_c, seg_d, seg_e, seg_f, seg_g ); wire w_clk; wire [3:0] w_cnt; sec_tick_gen uSec_tick_gen ( .clk(clk), .reset(reset_n), .o_clk(w_clk) ); data_gen uData_gen ( .tick(w_clk), .reset_n(reset_n), .cnt(w_cnt) ); seven_segment_cntrl uSeven_segment_cntrl ( .inp(w_cnt), .seg_a(seg_a), .seg_b(seg_b), .seg_c(seg_c), .seg_d(seg_d), .seg..
[Vivado] 0X. Source Code Calculator_8bit_PB_FSM_stopwatch.v `timescale 1ns / 1ps module Calculator_8bit_PB_FSM_stopwatch( input clk, input reset, input [7:0] i_a, input [7:0] i_b, input i_pbrunstop, input i_pbclear, output [3:0] o_digitSel, output [7:0] o_fndFont ); wire [8:0] w_sum; wire w_stoprun, w_clear; wire [13:0] w_stopwatchValue, w_FndsourceValue; wire w_pbrunstop, w_pbclear; PushButton_Oneshot U_pb_runstop(clk,..
[Vivado] 07. Calculator 8bit, PB FSM StopWatch Data 가 변하는 과정에서 Chattering, Bouncing 등이 발생할 수도 있으며 이럴 때, 입력 값이 0 인지 1 인지 정확하게 확인할 수 없는 Meta Stable 상태가 되고 오류를 발생시킨다. 이는 동기화(Synchronize, D_FF) 를 통해 해결할 수 있다. D_FF 가 많으면 많을수록 System 은 더 안정된다. 하지만 그 만큼 입력 Delay 가 길어지는 단점도 있다. Pull - Down 장치로 PB 를 Arbitrary Time 동안 눌렀을 때, 1 이 정확하게 1 period 만큼만 발생하도록 설계하려고 한다. [1] Switch[0], [1] 대신 PushButton (runstop, clear) 을 사용하기 위해서는 D_FF 를 활용한 Synchronizer 가 필요..
[Vivado] 06. Calculator 8bit, FSM StopWatch 0.1s UpCount [1] StopWatch 설계 후, FSM (sw[0], sw[1]) 으로 Stop, Run, Clear 상태 제어. stopwatch 내부에 clkDivider 와 0.1s Counter 가 필요하다. clkDivider 는 10hz, Counter 는 0 ~ 9999 까지 Count 하도록 설계한다(14bit). fig.1 과 같이 FSM 의 stoprun 신호를 받을 수 있는 enable 과 clear 신호를 받는 reset(clear) port 를 선언해주어야 한다. `timescale 1ns / 1ps module stopwatch( input clk, input reset, input i_run_stop, input i_clear, output [13:0] o_upCounter ); wire ..
[Vivado] 05. Finite State Machine LED current nextState reset input state output state 1 - - 0 OFF 0 0 OFF 0 OFF 0 1 OFF 1 ON 0 0 ON 0 OFF 0 1 ON 1 ON reset 값은 OFF 에서 시작. output 은 input 과 서로 독립적이며 state 값을 따른다. `timescale 1ns / 1ps // moore machine module LED_FSM( input clk, input reset, input i_ledswitch, output reg o_led ); parameter S_OFF = 1'b0, S_ON = 1'b1; reg state = S_OFF, nextState; // state register always@(posedge clk, po..