4bits Binary Up-Down Counter

On this page, I will introduce "4 bits Binary Up-Down Counter" which was written in VHDL.
This source file is written for CPLD(XC9536-PC44).
The other CPLD device can be used if arranging a little.

The logic is the function which is same as Logic IC( 74161 ) approximately.
But, a carry bit, a borrow bit aren't supported.
Those functions can be put if you arrange logic.

I programed this logic in CPLD and confirmed in the operation and had confirmed normal operation.
Source code and Explanation

Fitting report

Processing parameter specification

Operating state table
HXXXX0,0,0,0Counter clear
LHXXD3,D2,D1,D0Counter preset
LLLXQ = QCount stop
LLHHQ = Q+1Count up
LLHLQ = Q-1Count down

H : High level
L : Low level
X : Don't care
CLK is effective when changing into H from the L.