Skip to content

Commit

Permalink
Implemented holdCounter
Browse files Browse the repository at this point in the history
Changed counter component to removed the clk_en input and and added an
input that allows for the counter to count up or count down
  • Loading branch information
yangsu committed Nov 1, 2012
1 parent 2360dc1 commit 56d96c0
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 41 deletions.
26 changes: 13 additions & 13 deletions counter.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ ENTITY counter IS
PORT
(
aclr : IN STD_LOGIC ;
clk_en : IN STD_LOGIC ;
clock : IN STD_LOGIC ;
cnt_en : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (11 DOWNTO 0);
sload : IN STD_LOGIC ;
updown : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (11 DOWNTO 0)
);
END counter;
Expand All @@ -68,11 +68,11 @@ ARCHITECTURE SYN OF counter IS
);
PORT (
sload : IN STD_LOGIC ;
clk_en : IN STD_LOGIC ;
aclr : IN STD_LOGIC ;
clock : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (11 DOWNTO 0);
data : IN STD_LOGIC_VECTOR (11 DOWNTO 0);
updown : IN STD_LOGIC ;
cnt_en : IN STD_LOGIC
);
END COMPONENT;
Expand All @@ -82,17 +82,17 @@ BEGIN

lpm_counter_component : lpm_counter
GENERIC MAP (
lpm_direction => "DOWN",
lpm_port_updown => "PORT_UNUSED",
lpm_direction => "UNUSED",
lpm_port_updown => "PORT_USED",
lpm_type => "LPM_COUNTER",
lpm_width => 12
)
PORT MAP (
sload => sload,
clk_en => clk_en,
aclr => aclr,
clock => clock,
data => data,
updown => updown,
cnt_en => cnt_en,
q => sub_wire0
);
Expand All @@ -108,11 +108,11 @@ END SYN;
-- Retrieval info: PRIVATE: ALOAD NUMERIC "0"
-- Retrieval info: PRIVATE: ASET NUMERIC "0"
-- Retrieval info: PRIVATE: ASET_ALL1 NUMERIC "1"
-- Retrieval info: PRIVATE: CLK_EN NUMERIC "1"
-- Retrieval info: PRIVATE: CLK_EN NUMERIC "0"
-- Retrieval info: PRIVATE: CNT_EN NUMERIC "1"
-- Retrieval info: PRIVATE: CarryIn NUMERIC "0"
-- Retrieval info: PRIVATE: CarryOut NUMERIC "0"
-- Retrieval info: PRIVATE: Direction NUMERIC "1"
-- Retrieval info: PRIVATE: Direction NUMERIC "2"
-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone II"
-- Retrieval info: PRIVATE: ModulusCounter NUMERIC "0"
-- Retrieval info: PRIVATE: ModulusValue NUMERIC "0"
Expand All @@ -122,20 +122,20 @@ END SYN;
-- Retrieval info: PRIVATE: SSET_ALL1 NUMERIC "1"
-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
-- Retrieval info: PRIVATE: nBit NUMERIC "12"
-- Retrieval info: CONSTANT: LPM_DIRECTION STRING "DOWN"
-- Retrieval info: CONSTANT: LPM_PORT_UPDOWN STRING "PORT_UNUSED"
-- Retrieval info: CONSTANT: LPM_DIRECTION STRING "UNUSED"
-- Retrieval info: CONSTANT: LPM_PORT_UPDOWN STRING "PORT_USED"
-- Retrieval info: CONSTANT: LPM_TYPE STRING "LPM_COUNTER"
-- Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "12"
-- Retrieval info: USED_PORT: aclr 0 0 0 0 INPUT NODEFVAL aclr
-- Retrieval info: USED_PORT: clk_en 0 0 0 0 INPUT NODEFVAL clk_en
-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL clock
-- Retrieval info: USED_PORT: cnt_en 0 0 0 0 INPUT NODEFVAL cnt_en
-- Retrieval info: USED_PORT: data 0 0 12 0 INPUT NODEFVAL data[11..0]
-- Retrieval info: USED_PORT: q 0 0 12 0 OUTPUT NODEFVAL q[11..0]
-- Retrieval info: USED_PORT: sload 0 0 0 0 INPUT NODEFVAL sload
-- Retrieval info: USED_PORT: updown 0 0 0 0 INPUT NODEFVAL updown
-- Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0
-- Retrieval info: CONNECT: q 0 0 12 0 @q 0 0 12 0
-- Retrieval info: CONNECT: @clk_en 0 0 0 0 clk_en 0 0 0 0
-- Retrieval info: CONNECT: @updown 0 0 0 0 updown 0 0 0 0
-- Retrieval info: CONNECT: @cnt_en 0 0 0 0 cnt_en 0 0 0 0
-- Retrieval info: CONNECT: @sload 0 0 0 0 sload 0 0 0 0
-- Retrieval info: CONNECT: @aclr 0 0 0 0 aclr 0 0 0 0
Expand All @@ -144,8 +144,8 @@ END SYN;
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter.vhd TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter.inc FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter.cmp FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter.bsf TRUE FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter.bsf TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter_inst.vhd FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter_waveforms.html TRUE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter_waveforms.html FALSE
-- Retrieval info: GEN_FILE: TYPE_NORMAL counter_wave*.jpg FALSE
-- Retrieval info: LIB_FILE: lpm
18 changes: 9 additions & 9 deletions frameCounter.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ ARCHITECTURE arch OF frameCounter IS
PORT
(
aclr : IN STD_LOGIC ;
clk_en : IN STD_LOGIC ;
clock : IN STD_LOGIC ;
cnt_en : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (11 DOWNTO 0);
sload : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (11 DOWNTO 0)
updown : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (11 DOWNTO 0)
);
END COMPONENT;

BEGIN
counter0: counter PORT MAP(
aclr => aclr,
clk_en => '1',
clock => clk,
cnt_en => enable,
data => "000000000000",
sload => '0',
q => count
aclr => aclr,
clock => clk,
cnt_en => enable,
data => "000000000000",
sload => '0',
updown => '1',
q => count
);
END arch;
16 changes: 8 additions & 8 deletions holdCounter.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ ARCHITECTURE arch of holdCounter IS
PORT
(
aclr : IN STD_LOGIC ;
clk_en : IN STD_LOGIC ;
clock : IN STD_LOGIC ;
cnt_en : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (11 DOWNTO 0);
sload : IN STD_LOGIC ;
updown : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (11 DOWNTO 0)
);
END COMPONENT;
Expand All @@ -32,13 +32,13 @@ ARCHITECTURE arch of holdCounter IS
BEGIN

counter0: counter PORT MAP(
aclr => aclr,
clk_en => '1',
clock => clk,
cnt_en => enable AND NOT isEqual12,
data => "000000000000",
sload => '0',
q => tempCount
aclr => aclr,
clock => clk,
cnt_en => enable AND NOT isEqual12,
data => "000000000000",
sload => '0',
updown => '1',
q => tempCount
);

isEqual12 <= '1' WHEN (tempCount = "000000001100") ELSE '0';
Expand Down
Loading

0 comments on commit 56d96c0

Please sign in to comment.