简体   繁体   中英

What's the recommended MyHDL design pattern for multi-tick operations?

I'm trying to learn MyHDL by writing a very simple machine with just a handful of instructions and operations. What I'm struggling with is the best way to design my machine to handle operations that take multiple clock cycles to resolve. Currently, all of the hardware components that I've written need just a single tick to resolve, so it's the control unit that I'm having trouble with.

For example, let's say that all of my machine's operations take between 1 and 3 clock cycles to complete, which means that I'll need to have 3 cycles for every instruction (as I'm not doing any parallelism right now).

This will mean that I need three stages to my machine or, in HDL terms, three clock sensitive logic blocks. One complete iteration of the machine would look like:

  • Control A
    • Tick :: Components
  • Control B
    • Tick :: Components
  • Control C
    • Tick :: Components
  • Back to A

Since there is no parallelism and each stage is using shared hardware, I want the control blocks to be triggered sequentially and in order. To do this, would I want multiple clocks? One clock for the components and one for the control where the ticking of the components clock is done at the end of each control phase? But then control A, B, and C will all be executed together by each clock tick. Would I then want four clocks, with one for the components and one for each control phase where the component clock and the clock of the next phase is advanced at the end of each control phase? Or do I want just one clock and some boolean signals that tell each phase when they should be going (every control phase would check a flag and if it's set, they would execute and set the flag for the next phase)?

From your description I think that you could try to solve you problem using a state machine and spliting your circuits into independent units.

Since you said that you don't want to add any paralelism in your design you could try to keep your design within a single circuit, with only one clock and control the behavior using registers. Try to describe the circuit considering that one action will be taken per clock.

Try to add some example code and more concrete information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM