always @ (A, B)
begin
D = (A & B) | C;
end
always @ (A, B, C)
begin
D = (A & B) | C;
end
Synthesis 툴이 강제적으로 추가한다.
always @ (In_A, In_B)
begin
Intermediate_Variable = In_A & In_B;
Data_Out = Intermediate_Variable;
end
Blocking assignment to Intermediate_Variable occurs immediately.
read after it is updated.
always @ (In_A, In_B, Intermediate_Variable)
begin
Intermediate_Variable <= In_A & In_B;
Data_Out = Intermediate_Variable;
end
Nonblocking assignment to Intermediate_Variable is scheduled to occur at the end of the current Verilog simulation cycle.
read before it is updated.
Intermediate_Variable MUST be in the event list.
one_hot Directive// synopsys one_hot "Set, Reset"
always @ (posedge Clock, posedge Treset, posedge Set)
begin
if (Set)
begin
Data_Out <= 1'b1;
end
else if (Reset)
begin
Data_Out <= 1'b0;
end
else
begin
Data_out <= Data_In;
end
end
Set과Reset이 동시에 1이되는 경우 문제, Mismatch가 발생
`ifndef SYNTHESIS
always @ (Reset, Set)
begin
if (Reset & Set)
begin
$display ("one_hot violation for Reset and Set");
end
end
`endif
해당 구문으로 Simulation에서 Violation Check 할 수 있도록 추가하기
task Task_Mismatch (input T_In_A,
input T_Sel,
output T_Out
reg Internal_Reg;
begin
if (T_Sel)
begin
Internal_Reg = T_In_A;
end
T_Out = Internal_Reg;
end
endtask
Task_Mismatch(Data_In, Enable, D_Out)
Latch 생성을 원했지만, 합성하면
D_Out = Enable & Data_In의 AND Gate가 나옴
hdlin_infer_function_local_latches 를 true로 바꾸면 subprograms 가 latch로 생성된다.input [7:0] Data_A;
input [7:0] Data_B;
output [7:0] Data_C;
reg [7:0] Data_C;
always @ (Data_A, Data_B)
begin
if (Data_A == Data_B)
begin
Data_C = Data_A;
end
end
simulation 상에서는 문제 없는데 실제 회로에서는 비교기와 결과 실행에 시간이 필요하다.
input Clock;
input [7:0] Data_A;
input [7:0] Data_B;
output [7:0] Data_C;
reg [7:0] Data_C;
always @ (posedge Clock)
begin
if (Data_A == Data_B)
begin
Data_C = Data_A;
end
end
FF으로 설계하기
input [1:0] Sel_X;
input [1:0] Sel_Y;
case (Sel_X ~^ Sel_Y)
3'b000: Data_Out = In_A + In_B;
3'b001: Data_Out = In_C + In_D;
3'b010: Data_Out = In_E + In_F;
3'b011: Data_Out = In_G + In_H;
default: Data_Out = In_I + In_J;
endcase
Option #1
default branch will NEVER be executedOption #2
~^ operator on these three bit operandsdefault branch will ALWAYS be executedSynopsys VCS, Synthesis는 Option #1