HDLBits - Vector3
·
HDLBits
Concatenation needs to know the width of every component(or how would you know the length of the result?).Thus, {1, 2, 3} is illegal and results in the error message:unsized constants are not allowed in concatenations.{ } 를 사용해서 여러 비트를 연결할 때 bit의 크기를 무조건 명시해야한다.주어진 32-bits를 아래의 w,x,y,z로 재조정하는 문제이다.하나로 합친다음에 갈라서 assign 하였다.module top_module ( input [4:0] a, b, c, d, e, f, output [7:0] w, x,..
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하면 되지만이렇게 하면 좀더 가독성이 좋고 나중에 기억하거나 수정할때 ..
HDLBits - Vector1
·
HDLBits/Verilog
Vector 선언type [upper:lower] vector_name;Implict Nets - 암시적 Nets 방지하기`default_nettype nonePacked Arrayreg 타입 256-bit mem 변수를 총 8개 선언한 것reg [7:0] mem [255:0]Vector assignwire [7:0] w;와 output [3:0] a가 있을때assign w = a;를 하면 8-bit w wire에 4-bit a가 할당된다고 보면된다.bit수가 다를때 빈자리는 0으로 채워지고 모자란다면 잘려진다.설명은 여기서 끝이고이제 문제를 보자Build a combinational circuit that splits an input half-word (16 bits, [15:0] ) into lowe..
HDLBits - Vectors
·
HDLBits/Verilog
Vector의 사용법에 대해 알아보는 문제input [2:0] vec이 있을때,각각의 vector를 하나씩 output으로 선언할 수도 있고,통째로 원하는 만큼 선언도 가능하다.쉽게 보면 C언어의 배열? 같은 느낌인데Wire를 묶어서 생각하면 된다고 나는 이해했다.module top_module ( input wire [2:0] vec, output wire [2:0] outv, output wire o2, output wire o1, output wire o0 ); // Module body starts after module declaration assign outv = vec; assign o2 = vec[2]; assign o1 = vec[1]; ..
HDLBits - 7458 chip
·
HDLBits/Verilog
7458 chip 내부의 회로를 구현 하라는 문제그림을 잘보고 하나하나 만들어가면 크게 어렵지않다.좌측은 and gate들이 입력 2개를 받고 우측은 and gate들이 입력 3개를 받는 것만 유의해서 짜면 될것같다. 이로써 Verilog-Language의 Basics 챕터가 끝났다~module top_module ( input p1a, p1b, p1c, p1d, p1e, p1f, output p1y, input p2a, p2b, p2c, p2d, output p2y); wire w_and_1, w_and_2; wire w_tri_and_1, w_tri_and_2; wire w_or_1, w_or_2; assign w_and_1 = p2a & p2b; a..
HDLBits - Declaring wires
·
HDLBits/Verilog
이번 문제는 Wire의 사용법에 대해 배우는 문제인듯하다.`default_nettype nonemodule top_module( input a, input b, input c, input d, output out, output out_n ); wire w_and1; wire w_and2; wire w_or1; assign w_and1 = a & b; assign w_and2 = c & d; assign w_or1 = w_and1 | w_and2; assign out = w_or1; assign out_n = ~w_or1;endmodule