機能
IF構文をつかった,算術演算と算術比較の設計例
解説
2つの入力信号を算術演算し,機能出力端子を駆動する回路例.
NSL記述例
/* ************************************************************ */
declare VAR_IF {
input A_i ;
input B_i ;
input Enb_i ;
func_in Check_i() ;
func_out Q_AND() ;
func_out Q_OR() ;
func_out Q_ExOR() ;
func_out Q_AisH() ;
func_out Q_BisL() ;
}
/* ************************************************************ */
// Declare module
module VAR_IF {
/* ************************************************************ */
// Internal operation signals
func_name if_statement_check() ;
/* ************************************************************ */
// Equation
func Check_i {
// Statement case #1
// if ( Enb_i == 1’b1 ) { // if ( Enb_i ) …. => OK
// if_statement_check() ;
// }
// Statement case #2
any {
Enb_i : if_statement_check() ;
}
}
func if_statement_check {
// Logical decision
if ( A_i & B_i ) // Compare A and B.
Q_AND() ; // Drive output function terminal.
if ( A_i | B_i ) // Logical OR of A and B.
Q_OR() ; // Drive output function terminal.
if ( A_i ^ B_i ) // Logical ExOR of A and B.
Q_ExOR() ; // Drive output function terminal.
// Variation 1
if ( A_i ) { // Logical H level detect
Q_AisH () ; // Drive output function terminal.
}
// // Variation 2
// if ( A_i == 1’b1 ) { // Compare both A and ‘1’ value
// Q_AisH () ; // Drive output function terminal.
// }
// // Variation 3
// if ( A_i != 1’b0 ) { // Compare both A and not ‘0’ value.
// Q_AisH () ; // Drive output function terminal.
// }
// Variation 4
if ( ~B_i ) { // Logical L level detect
Q_BisL () ; // Drive output function terminal.
}
// // Variation 5
// if ( B_i == 1’b0 ) { // Compare both A and ‘0’ value
// Q_BisL () ; // Drive output function terminal.
// }
// // Variation 6
// if ( B_i != 1’b1 ) { // Compare both A and not ‘1’ value.
// Q_BisL () ; // Drive output function terminal.
// }
}
}
/* ************************************************************ */
Verilog変換例
/*
Produced by NSL Core, IP ARCH, Inc. Fri Jun 04 18:15:18 2010
Licensed to :EVALUATION USER:
*/
module VAR_IF ( p_reset , m_clock , A_i , B_i , Enb_i , Check_i , Q_AND , Q_OR , Q_ExOR , Q_AisH , Q_BisL );
input p_reset, m_clock;
input A_i;
input B_i;
input Enb_i;
input Check_i;
output Q_AND;
output Q_OR;
output Q_ExOR;
output Q_AisH;
output Q_BisL;
wire if_statement_check;
wire _net_0;
wire _net_1;
wire _net_2;
wire _net_3;
assign if_statement_check = Check_i&Enb_i;
assign _net_0 = A_i&B_i;
assign _net_1 = A_i|B_i;
assign _net_2 = A_i^B_i;
assign _net_3 = ~B_i;
assign Q_AND = if_statement_check&_net_0;
assign Q_OR = if_statement_check&_net_1;
assign Q_ExOR = if_statement_check&_net_2;
assign Q_AisH = if_statement_check&A_i;
assign Q_BisL = if_statement_check&_net_3;
endmodule
/*
Produced by NSL Core, IP ARCH, Inc. Fri Jun 04 18:15:18 2010
Licensed to
*/