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
RISC-V CPU 설계 (0)
·
Hardware/RISC-V Project
뭔가 취준 + 교육 준비 같은걸 하면서 머리가 정리가 안되고 너무 복잡해서RISC-V 구조를 갖는 CPU나 하나 만들어보자는 생각이 들었다. 물론 나의 선생님 GPT와 함께 만들거지만 ^^ 전체적인 아웃라인설계 목표32bit RISC-V Structure기본 구조5-stage Pipeline: Fetch - Decode - Execute - Memory - Write Back파이프라인 구성 요소Register FileALUMemory InterfaceControl UnitPipeline Register파이프라인 Hazard 처리Control Logic & FSM검증 & 시뮬레이션구현디버깅 & 최종 검증
Verilog [ generate와 always@(*) ] 차이점
·
Hardware/ETC.
generate반복적으로 독립된 하드웨어를 생성하드웨어 자원 증가같은 논리 회로가 여러 번 복사always @(*)Combinational Logic입력 변화에 따라 동작이 결정되며, 최적화된 회로로 구현
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 - 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..