0

I am trying to implement a counter logic in SIMULINK where

in1, in2 are inputs

out1 is the output

if in2 = 0, out1 = 0;

if in2 = 1, out1 = 1 after x high edges of in1

I have tried using "Detect Rise Positive" block but failed miserably because I don't have sufficient experience of implementing a timing diagram correctly in SIMULINK. Could anyone kindly point me to the right direction?

Update

An approach I have taken since I posted this question is the "Triggered and enabled subsystem". I am trying to set it up so that:

in2 becomes the enable signal
in1 becomes the trigger
in2 becomes the intput to the subsystem
Out1 becomes the output of the subsystem

But I think that the above was rubbish. Unfortunately it is not VHDL where I could have implemented it using 4-5 lines of description of the hardware logic.

TylerH
  • 20,799
  • 66
  • 75
  • 101
ha9u63a7
  • 6,233
  • 16
  • 73
  • 108

2 Answers2

0

Using a Triggered and Enabled subsystem is the right approach, but your inputs (and no doubt what's inside the subsystem) needs to be modified.

Don't have any input to the subsystem (other than the trigger and enable signals).

Inside the subsystem,

  • set the enable block property to reset the state when disabled.
  • set the outport property to reset when disabled and give the initial condition as 0.
  • create a counter out of a constant (value=1), a summation and a unit delay block.
  • feed the counter into a Compare to Constant block set to the 'x' value in your question.
  • feed that block to the outport.

When enabled, the counter should count the required number of steps (when triggered) before the output goes high.

Phil Goddard
  • 10,571
  • 1
  • 16
  • 28
0

A counter logic can be implemented very easily in simulink. Take a switch,give the control input as int1. If int1 is 1 ur output shuld be 0 else take another switch give its control input as int2. if int2 is 1 ur output shuld be 1+ previous value given in feedback funit delay block

Vishakha
  • 1
  • 1