1

2016. 11. 22. 22:53 from 카테고리 없음

Verilog datatype : variable, net

두 구룹은 값을 할당받고 유지하는 방식에 있어서 다르다. 또한 서로 다른 하드웨어 구조를 나타낸다.



net datatype


논리게이트나 모듈 등 하드웨어 요소들 사이의 물리적 연결을 나타내기 위해 사용됨. net은 값을 저장하지 않으며(단, trireg net는 예외), continuous assignment, gate primitive 등과 같은 driver의 값에 의해 net의 값이 연속적으로 유지된다. 만약 net에 구동자가 연결되어 있지 않으면, default 값은 high0impedance(z)가 된다.



variable datatype


reg, integer, real, time, realtime 등의 자료형 집합을 variable datatype이라고 한다. variable 자료형을 갖는 개체는 절차적 할당문 (procedural assignment)의 실행에 의해 그 값이 바뀌며, 할당에서부터 다음 할당까지 값을 저장하므로 프로그래밍 언어의 variable과 유사한 개념이라고 볼 수 있다.


- reg

 reg 자료형은 always나 initial 구문 내부의 절차적 할당문으로 값을 받는 객체의 자료형이다. always 내부에서 값을 할당받을 때 반드시 reg 자료형으로 선언되어야 하는 이유는 아래 글 참조.



처음 Verilog HDL 언어를 접하면서 가장 힘들었던 부분은 역시 wire와 reg의 구분을 하는것

wire = '선'

reg = '레지스터' 라고 우선 생각을 한다.

wire는 실제 wire 처럼 단지 어떤 모듈과 모듈을 이어주는 선에 불과하고 reg은 실제로 레지스터처럼 어떤 신호에 영향을 받아 바뀌는 값이라고 생각. 따라서 always문 안에서만 reg값의 변경이 가능하고 wire 값은 그 자체로 변경이 불가능하다. 단지 선을 연결하거나 and나 or등의 모듈로 나온 선을 잇는 것만 가능할 뿐.



* 합성용 셀 라이브러리 * 스위치 수준의 모델링

Posted by 나무길 :

Gate Primitive level modeling


Gate primitive를 이용한 modeling : NOT, XOR, NAND 등 이러한 게이트들이 미리 함수식으로 선언 되어 있는데 이것을 가져다 쓰는 것을 말함 


- Gate Primitive level modeling


module half_adder (a, b, sum, cout);

input a, b;

output sum, cout;

wire cout_bar;


xor (sum, a, b);

nand (cout_bar, a, b);

not (cout, cout_bar);

endmodule



Continuous assignment level modeling (Dataflow 중 하나)


Verilog의 연속 할당문은 assign 문으로 표현되며, 할당 기호 '='의 좌변의 신호에 우변의 결과 값을 할당한다. Verilog 모델링의 몸체부를 구성하는 문장들은 병행문이므로, 두 개의 assign 문장들은 그 순서에 무관하게 동일한 결과를 갖는다.


- Continuous assignment level modeling


module half_adder2 (a, b, sum, cout);

input a, b;

output sum, cout;

assign cout = a & b;

assign sum = a ^ b;

endmodule



Behavioral level modeling


- Behavioral level modeling


module mux2xb_if (in0, in1, sel, out);

input [1:0] in0, in1;

input sel;

output [1:0] out;

reg [1:0] out;


always @(sel or in0 or in1) begin

if (sel == 0)

out = in0;

else

out = in1;

end

endmodule




-------------------------------------------------- 잡것 정리 -----------------------------------------------


always 문법, 블로킹 연산자가 순차회로에 적합하지 않은 이유.

-> non-blocking 연산자 동일 시점에서 변수들의 순서나 상호 의존성에 의해서 할당이 이루어져야 하는 경우에 사용된다.

다시 말하면 clock이 들어오는 순간 변수가 동시에 다 바뀌는 거에 사용.

반대로 blocking 연산자는 동일시점이 아닌 (비동기) 먼저 들어온 것이 먼저 처리 되어야 할 때 blocking 연산자를 사용한다. 즉, 어떤 시점에 처리할 때 다른 연산은 block (금지)되는 용도로 사용.




- Design Specifications -> Behavioral Modeling -> RTL level HDL Modeling -> Functional Simulation -> Logic Synthesis -> Gate-level Verification


- Behavioral Modeling : 상세 설계 이전에 설계사양을 확인할 수 있도록 시스템의 전체 기능을 모델링하고 검증하는 과정.

ASIC(Application Specific Integrated Circuit) or FPGA (Field Programmable Gate Array)로 구현하기 위한 상세설계가 시작.

상세설계는 합성 가능한 Verilog 구문들을 이용하여 RTL 수준으로 모델링하고 이를 검증하기 위한 테스트 벤치를 생성하는 것. (RTL : a way of describing a circuit


- Verilog HDL 구문 : 논리합성용 구문, 시뮬레이션용 구문, 라이브러리 설계용 구문

논리합성용 구문 : assign, always, if~else, case, for 등 대부분의 논리합성 툴에서 게이트 수준 합성을 지우너하는 구문들.

시뮬레이션용 구문 : initial, $finish, $fopen 등 시뮬레이션을 위한 테스트벤치의 작성에 사용됨,

라이브러리 설계용 구문 : 


- module 몸체 부분은 always or initial 구문을 이용한 behavioral modeling, assign statement를 이용한 data flow modeling 등을 포함

'Language > verilog HDL' 카테고리의 다른 글

blocking과 nonblocking 연산자 의미  (0) 2016.11.27
Assignment  (0) 2016.11.23
Gate delay, net delay  (0) 2016.11.23
Behavioral, RTL, Gate level  (0) 2016.11.22
Little endian, Big endian  (0) 2016.11.16
Posted by 나무길 :

Three levels



Behavioral has the highest layer of abstraction which describes the overall behavior and is often not synthesizeable, but is useful for verification. (Abstraction 반대 : gate 수준(NAND, NOR etc))



RTL describes the hardware you want by implying logic. Defining flip-flops, latches and how data is transfered between them. This is synthesizable synthesis may alter/optimize the logic used but not behavior. Switching muxes for gates etc some times inverting signals to better optimize the design.



Verilog RTL implying a flip-flop :


logic a;    // logic is SystemVerilog, could be a 'reg'

logic k;    // Driven by RTL not shown

always @ (posedge clk or negedge rst_n) begin

if (~rst_n) begin

a <= 'b0';

end

else begin

a <= k;

end

end


Combinatorial Bitwise operators :


logic [1:0] n;

logic [1:0] m;

logic [1:0] result;


assign result = n & m;



Gate level is a design using the base logic gates (NAND, NOR, AND, OR, MUX, FLIP-FLOP). It does not need to be synthesized or is the output from synthesis. This has the lowest level of abstraction. It is the logic gates that you will use on the chip, but it lacks positional information.



Gate level verilog (same function as above) :


wire a;

wire k;

DFFRX1 dffrx1_i0 (

.Q (a),    //Output

.QN( ),     //Inverted output not used

.D( (k),     //Input

.CK(clk),     //Clk

.RN(rst_n)    //Active low async Reset

);


Combinatorial


logic [1:0] n;

logic [1:0] m;

logic [1:0] result;


AND2X1 and2x1_i0 (

.Y (result[0]),

.A (n[0]),

.B (m[0])

);

AND2X1 and2x1_i1 (

.Y (result [1]),

.A (n[1]),

.B (m[1])

);


'Language > verilog HDL' 카테고리의 다른 글

blocking과 nonblocking 연산자 의미  (0) 2016.11.27
Assignment  (0) 2016.11.23
Gate delay, net delay  (0) 2016.11.23
Gate-level, Dataflow, Behavoral modeling  (0) 2016.11.22
Little endian, Big endian  (0) 2016.11.16
Posted by 나무길 :