--lpm_counter CBX_DECLARE_ALL_CONNECTED_PORTS="OFF" DEVICE_FAMILY="Cyclone II" lpm_modulus=55 lpm_port_updown="PORT_CONNECTIVITY" lpm_width=6 aclr clock q CARRY_CHAIN="MANUAL" CARRY_CHAIN_LENGTH=48
--VERSION_BEGIN 7.2 cbx_cycloneii 2007:06:13:15:47:32:SJ cbx_lpm_add_sub 2007:08:06:16:01:34:SJ cbx_lpm_compare 2007:06:21:15:54:06:SJ cbx_lpm_counter 2007:08:07:01:40:08:SJ cbx_lpm_decode 2007:03:12:19:01:52:SJ cbx_mgl 2007:08:03:15:48:12:SJ cbx_stratix 2007:05:02:16:27:14:SJ cbx_stratixii 2007:06:28:17:26:26:SJ  VERSION_END


-- Copyright (C) 1991-2007 Altera Corporation
--  Your use of Altera Corporation's design tools, logic functions 
--  and other software and tools, and its AMPP partner logic 
--  functions, and any output files from any of the foregoing 
--  (including device programming or simulation files), and any 
--  associated documentation or information are expressly subject 
--  to the terms and conditions of the Altera Program License 
--  Subscription Agreement, Altera MegaCore Function License 
--  Agreement, or other applicable license agreement, including, 
--  without limitation, that your use is for the sole purpose of 
--  programming logic devices manufactured by Altera and sold by 
--  Altera or its authorized distributors.  Please refer to the 
--  applicable agreement for further details.


FUNCTION cycloneii_lcell_comb (cin, dataa, datab, datac, datad)
WITH ( LUT_MASK, SUM_LUTC_INPUT)
RETURNS ( combout, cout);
FUNCTION cycloneii_lcell_ff (aclr, clk, datain, ena, sclr, sdata, sload)
WITH ( x_on_violation)
RETURNS ( regout);

--synthesis_resources = lut 10 reg 6 
SUBDESIGN cntr_gbi
( 
	aclr	:	input;
	clock	:	input;
	q[5..0]	:	output;
) 
VARIABLE 
	counter_comb_bita0 : cycloneii_lcell_comb
		WITH (
			LUT_MASK = "5A90",
			SUM_LUTC_INPUT = "cin"
		);
	counter_comb_bita1 : cycloneii_lcell_comb
		WITH (
			LUT_MASK = "5A90",
			SUM_LUTC_INPUT = "cin"
		);
	counter_comb_bita2 : cycloneii_lcell_comb
		WITH (
			LUT_MASK = "5A90",
			SUM_LUTC_INPUT = "cin"
		);
	counter_comb_bita3 : cycloneii_lcell_comb
		WITH (
			LUT_MASK = "5A90",
			SUM_LUTC_INPUT = "cin"
		);
	counter_comb_bita4 : cycloneii_lcell_comb
		WITH (
			LUT_MASK = "5A90",
			SUM_LUTC_INPUT = "cin"
		);
	counter_comb_bita5 : cycloneii_lcell_comb
		WITH (
			LUT_MASK = "5A90",
			SUM_LUTC_INPUT = "cin"
		);
	counter_reg_bit1a[5..0] : cycloneii_lcell_ff;
	cmpr2_aeb_int	:	WIRE;
	cmpr2_aeb	:	WIRE;
	cmpr2_dataa[5..0]	:	WIRE;
	cmpr2_datab[5..0]	:	WIRE;
	aclr_actual	: WIRE;
	clk_en	: NODE;
	cnt_en	: NODE;
	compare_result	: WIRE;
	cout_actual	: WIRE;
	data[5..0]	: NODE;
	external_cin	: WIRE;
	modulus_bus[5..0]	: WIRE;
	modulus_trigger	: WIRE;
	s_val[5..0]	: WIRE;
	safe_q[5..0]	: WIRE;
	sclr	: NODE;
	sload	: NODE;
	sset	: NODE;
	time_to_clear	: WIRE;
	updown_dir	: WIRE;

BEGIN 
	counter_comb_bita[5..0].cin = ( counter_comb_bita[4..0].cout, external_cin);
	counter_comb_bita[5..0].dataa = ( counter_reg_bit1a[5..0].regout);
	counter_comb_bita[5..0].datab = ( updown_dir, updown_dir, updown_dir, updown_dir, updown_dir, updown_dir);
	counter_comb_bita[5..0].datad = ( B"1", B"1", B"1", B"1", B"1", B"1");
	counter_reg_bit1a[].aclr = aclr_actual;
	counter_reg_bit1a[].clk = clock;
	counter_reg_bit1a[].datain = ( counter_comb_bita[5..0].combout);
	counter_reg_bit1a[].ena = (clk_en & (((sclr # sset) # sload) # cnt_en));
	counter_reg_bit1a[].sdata = ((! sclr) & ((sset & s_val[]) # ((! sset) & ((sload & data[]) # (((! sload) & modulus_bus[]) & (! updown_dir))))));
	counter_reg_bit1a[].sload = (((sclr # sset) # sload) # modulus_trigger);
	IF (cmpr2_dataa[] == cmpr2_datab[]) THEN
		cmpr2_aeb_int = VCC;
	ELSE
		cmpr2_aeb_int = GND;
	END IF;
	cmpr2_aeb = cmpr2_aeb_int;
	cmpr2_dataa[] = safe_q[];
	cmpr2_datab[] = modulus_bus[];
	aclr_actual = aclr;
	clk_en = VCC;
	cnt_en = VCC;
	compare_result = cmpr2_aeb;
	cout_actual = (counter_comb_bita[5].cout # (time_to_clear & updown_dir));
	data[] = GND;
	external_cin = B"1";
	modulus_bus[] = B"110110";
	modulus_trigger = cout_actual;
	q[] = safe_q[];
	s_val[] = B"111111";
	safe_q[] = counter_reg_bit1a[].regout;
	sclr = GND;
	sload = GND;
	sset = GND;
	time_to_clear = compare_result;
	updown_dir = B"1";
END;
--VALID FILE
