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 - GitHub 주소
·
HDLBits/Verilog
https://github.com/Zi-Yoon/HDLBits GitHub - Zi-Yoon/HDLBits: Solving HDLBitsSolving HDLBits . Contribute to Zi-Yoon/HDLBits development by creating an account on GitHub.github.com해결한 모든 문제는 GitHub에 업로드 중입니다.
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..
HDLBits - Gates4
·
HDLBits/Verilog
Build a combinational circuit with four inputs, in[3:0]There are 3 outputs:out_and: output of a 4-input AND gate.out_or: output of a 4-input OR gate.out_xor: output of a 4-input XOR gate.3개의 Output을 위에서 말하는 Gate들로 만드는 문제Bit들을 하나씩 떨어뜨리고 연산하면 끝module top_module( input [3:0] in, output out_and, output out_or, output out_xor); assign out_and = in[0] & in[1] & in[2] & in[3]; assign..
HDLBits - Vectorgates
·
HDLBits/Verilog
Build a circuit that has two 3-bit inputs that computesthe bitwise-OR of the two vectors,the logical-OR of the two vectors,the inverse (NOT) of both vectors.Place the inverse of b in the upper half of out_not (i.e., bits [5:3]), and the inverse of a in the lower half.적힌대로 2개의 3-bit입력을 output으로 만드는 문제Bitwise와 Logical Operators의 차이점은단순 비트 연산과, 논리 연산 이라는 것에 차이가 있다.module top_module( input [2:0]..
HDLBits-Vector2
·
HDLBits/Verilog
이제는 Vector의 그냥 활용이 문제로 나오는듯? 하다A 32-bit vector can be viewed as containing 4 bytes (bits [31:24], [23:16], etc.).Build a circuit that will reverse the byte ordering of the 4-byte word.32-bit Vector는 4 bytes를 포함한다. byte는 8bit니까.. AaaaaaaaBbbbbbbbCcccccccDddddddd => DdddddddCcccccccBbbbbbbbAaaaaaaa이걸 이렇게 만들라는 문제다.8bit 단위로 떼서 옮기면 될 것 같다.물론 바로 in에서 out으로 assign하면 되지만이렇게 하면 좀더 가독성이 좋고 나중에 기억하거나 수정할때 ..