HDLBits - Dff8p
·
HDLBits/Circuits
요구사항이 negedge clk와 reset시에 0x34를 넣으라는 문제module top_module ( input clk, input reset, input [7:0] d, output [7:0] q); always @(negedge clk)begin if(reset) q
HDLBits - Dff8r
·
HDLBits/Circuits
module top_module ( input clk, input reset, // Synchronous reset input [7:0] d, output [7:0] q); always @(posedge clk) begin if(reset) q RESET신호가 추가된 DFF (Synchronous)
HDLBits - Dff8
·
HDLBits/Circuits
module top_module ( input clk, input [7:0] d, output [7:0] q); always @(posedge clk) begin q 이전.. 코드랑 똑같은 8bit짜리 DFF
HDLBits - Dff
·
HDLBits/Circuits
module top_module ( input clk, // Clocks are used in sequential circuits input d, output reg q );// always @(posedge clk) begin q 간단한 D Flip Flop
HDLBits - Module
·
HDLBits/Verilog
Moudle 선언 방법으로 instance하는 문제!그림처럼 mod_a가 이미 선언 되어있다고 가정하고 mod_a를 instance하면 된다.나는 By Name 방식으로 불러서 쓰는 것이 좀더 명확하다고 생각해서 항상 그렇게 한다.module top_module ( input a, input b, output out ); mod_a U_mod_a ( .out(out), .in1(a), .in2(b) );endmodule
HDLBits - Vector5
·
HDLBits/Verilog
주어진 5개의 1-bit 신호를 XNOR 연산을 통해주어진 그림과 같이 연산하여 25-bit의 출력으로 나타내는 문제이다.항상 코드의 범용성과 가독성을 고려해서 작성하려고 노력하는 편이다.이번에도 그렇게 짜려고 wire을 일부러 선언하여 사용했다.module top_module ( input a, b, c, d, e, output [24:0] out );// wire [4:0] w_abcde = {a, b, c, d, e}; wire [4:0] w_xnor_a = ~{5{a}} ^ w_abcde; wire [4:0] w_xnor_b = ~{5{b}} ^ w_abcde; wire [4:0] w_xnor_c = ~{5{c}} ^ w_abcde; wire [4:0] w_x..
HDLBits - Vector4
·
HDLBits/Verilog
Concatenation Operator{} 연결 연산자를 사용해서 더 큰 Vector를 형성 할 수 있다.{num{vector}} 반복되는 Vector는 앞에 숫자를 붙여서 축약 할 수 있다.예를 들어{2{a,b,c}}, {3'd5, {2{3'd6}}}와 같이 사용 가능하다.문제는 8bit 짜리 in을 부호자리를 늘려서 32bit로 표현 하라는 문제module top_module ( input [7:0] in, output [31:0] out ); assign out = {{24{in[7]}}, in[7:0]};endmodule
HDLBits - Vectorr
·
HDLBits/Verilog
Given an 8-bit input vector [7:0], reverse its bit ordering.그냥 뒤집?으라는 문제단순히 생각해서 [0:7]을 하면 오류가 난다. 뒤집어서 선언하는건 막아놨기 때문일단 하나씩 이렇게 적어도 되긴한다.module top_module( input [7:0] in, output [7:0] out); assign out = {in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]};endmodule근데.. 많이 귀찮다많아지면? 다 적을수는 없으니까 해결법 중 always문안에 for 루프를 사용하는 것도 괜찮다.module top_module( input [7:0] in, output [7..