/* ************************************************************ */ declare CNT4 { input PARAM_in[4] ; // Initial parameter. input LOAD_in ; // Synchronous PARAM_in load request. input ENB_in ; // Count enable func_in CARRY_in() ; // Carry-input from a lower level 4bit // counter's carry-output. output Q_out[4] ; // Flip-Flop data output func_out CARRY_out() ; // Carry-output to a higher lovel 4bit // counter's carry-input } /* ************************************************************ */ // Declare module module CNT4 { /* ************************************************************ */ // Internal operation signals reg Counter_4bit[4] ; // DタイプF/Fの宣言. /* ************************************************************ */ // Equation /* *********************************************** */ /* Pallarel equation */ { /* **** Data output **** */ Q_out = Counter_4bit ; // Q_out = Counter_4bit[3:0] is OK. // Q_out[3:0] = .... is NG. /* **** Flip-Flop equation **** */ if ( LOAD_in ) Counter_4bit := PARAM_in ; /* **** Carry-out equation **** */ if ( Counter_4bit == 4'b1111 ) { CARRY_out() ; } } /* *********************************************** */ /* Function independent equation */ function CARRY_in { if ( ENB_in ) { Counter_4bit := Counter_4bit + 4'b1 ; // Must define inclement data bit width !!! } } } /* ************************************************************ */