필터 지우기
필터 지우기

HDL Counter with programmable limit

조회 수: 7 (최근 30일)
Charles
Charles 2023년 3월 7일
댓글: Charles 2023년 3월 9일
Hello,
I am using Simulink/HDL Coder to design a system. I use the HDL Counter block a lot. As I learn more, I realize that the HDL Counter doesn't quite do everything I need.
In particular, I'd like to be able to programmatically set the "Count to" value (for a Count limited counter) depending on the system configuration. For example: say I have a signal vector that is Nsamples long. Depending on the system configuration, Nsamples could be 1000 or it could be 1500 or any arbitrary value in that range. My system needs to count out those samples and do processing that depends on the length. But since the counter limit is set via a mask parameter, it gets compiled in as a constant and cannot be changed at runtime. The generated HDL code shows that this is a constant compiled into the source, hence not at all easily settable.
I would be happy if this could be set once on startup from a register - the counter limit would never need to change again, and a system reconfig would always involve a reset/reload of the FPGA. To change the value with the current HDL Counter, I will need to change it in the design and resynthesize the whole system, not to mention test it to make sure it still works. Is there some other block out there I'm missing? Or, should I go and design my own?
Suggestions welcome. Thanks,
Charles

채택된 답변

Ryan Baird
Ryan Baird 2023년 3월 7일
Would a free running counter with a reset port connected to a comparison work for your use case?
  댓글 수: 1
Charles
Charles 2023년 3월 9일
Hi Ryan,
That's a great idea - I don't use the reset port often and tend to forget about it. What's missing is that I do use the enable port often, and simply adding that to the system does not produce identical timing behavior. So I added an AND gate as in the system below showing two counters, the upper one programmable, the lower configured in the mask:
Luckily this worked and produced the same timing for the count_hit and programmable_count signals as for the signals from the stock counter. Do you see anything I should be thinking about?
Thanks,
Charles

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by