usage_examples

Chaining General Purpose Counters

The following commands create three general purpose counters that all count to 10. The done signal of the lower indexed counters are used as the enable of the higher index counter.

Voice Commands
  1. "configure counter"
  2. "count ten"
  3. "configure counter one"
  4. "count ten"
  5. "enable chain"
  6. "configure counter two"
  7. "count 10"
  8. "enable chain"
  9. "ok"
Hotkey Commands
  1. cc
  2. count 10
  3. cc1
  4. count 10
  5. enable chain
  6. cc2
  7. count 10
  8. enable chain
  9. ok
Chained Counters

Chaining General Purpose Counters

-------------------------------------------------------------------------
---------------------------sys_clk 100MHz active resource 0 state -1-----
-------------------------------------------------------------------------
RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
-------------------------------------------------------------------------
CONFIGURE_COUNTER( 0, 10, -1, next_state_rec, state_reg_rec );
CONFIGURE_COUNTER( 1, 10, -1, next_state_rec, state_reg_rec, chain );
CONFIGURE_COUNTER( 2, 10, -1, next_state_rec, state_reg_rec, chain );

Chaining General Purpose Counters

See also
  CONFIGURE_COUNTER

Chaining General Purpose Counters

Chaining General Purpose Counters

Creating A Time Counter

The following commands configure the divide counter (faster counter) to count 1.1us and the slower delay counter to count to 3.  The net affect is a 3.3 us counter that rolls over and starts again, but outputs strobes every 1.1us.  In order to cut down on simulation time, the clock frequency was dropped from 100MHz to 10MHz.

Voice Commands
  1. "time counter"
  2. "delay three"
  3. "divide one point one micro-second"
  4. "--"
  5. "ok"
Hotkey Commands
  1. tc
  2. delay 3
  3. divide 1.1us
  4. clk_freq = 10MHz
  5. ok
Time Counter

Creating A Time Counter

--------------------------------------------------------------------------------------------
----------------------------sys_clk 10MHz active resource 0 state -1-------------------------
--------------------------------------------------------------------------------------------
RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
--------------------------------------------------------------------------------------------
TIME_COUNTER( 3, us(1.1), next_state_rec, state_reg_rec );

Creating A Time Counter

See also
  TIME_COUNTER

Creating A Time Counter

Multiple Clock Domain Counters

The following commands configure two framework counters.  One counter operates on the default sys_clk domain (100MHz) while the other operates on a user specified 50MHz clock domain.

Voice Commands
  1. "resource zero"
  2. "configure counter zero"
  3. "resource one"
  4. "resource clock fifty mega-hertz"
  5. "configure counter zero"
Hotkey Commands
  1. rs0
  2. cc0
  3. rs1
  4. rs_clk 50e6
  5. cc0
Counters On Separate Clock Domains

Multiple Clock Domain Counters

RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
CONFIGURE_COUNTER( 0, 128, -1, next_state_rec, state_reg_rec );
RESOURCE_SELECT( 50e6, next_state_rec(1), state_reg_rec(1) );
CONFIGURE_COUNTER( 0, 128, -1, next_state_rec(1), state_reg_rec(1) );

Multiple Clock Domain Counters

See also
  CONFIGURE_COUNTER

Multiple Clock Domain Counters

Multiple Clock Domain Counters

Writing to and Reading From a Fifo

Using the following commands, application module ' writer.vhd ' streams data from counter(0) into a fifo and application module ' reader.vhd ' reads the data from the fifo.  Note that the fifo_write_enable signal is used as the enable for the counter.

writer.vhd Hotkey Commands
  1. cc
  2. enable .write_ready
  3. wr
  4. index reader
  5. data counter0
reader.vhd Hotkey commands
  1. rf
  2. index writer
writer.vhd Procedure Calls

Writing to and Reading From a Fifo

RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
WRITE_FIFO_DATA( reader, srr.counter(0).value, srr.fifo_write_ready, -1, -1,
next_state_rec, state_reg_rec );
CONFIGURE_COUNTER( 0, 128, -1, next_state_rec, state_reg_rec, srr.fifo_write_ready );

Writing to and Reading From a Fifo

reader.vhd Procedure Calls

Writing to and Reading From a Fifo

RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
READ_FIFO_DATA( writer, srr.fifo_data_ready, -1, -1, next_state_rec, state_reg_rec );

Writing to and Reading From a Fifo

Note
The WRITE_FIFO_DATA and the CONFIGURE_COUNTER procedure calls are operating in parallel, thus in this case it does not matter which call appears first in the VHDL code.

Writing to and Reading From a Fifo

Writing to and Reading From a Fifo