DFF, incorrect initialization?

OP #7750174
Rate this post
• ▲ useful
▼ not useful

Hi everyone,

I’m new to Verilog (and this forum) and currently learning through some problem sets: https://hdlbits.01xz.net/wiki/Problem_sets. I’m working on creating a data latch, data flip-flop and circuit with this elements using a structural approach, specifically without using any always blocks.

I successfully implemented a master-slave data flip-flop itself, and also passed the tests for synchronous and asynchronous reset tasks. However, I ran into issues with the following tasks:

https://hdlbits.01xz.net/wiki/Exams/m2014_q4d https://hdlbits.01xz.net/wiki/Mt2015_muxdff

In the first task, my output was always inverted. I suspected it might be due to incorrect initialization, so I did a quick fix by inverting the output, and that worked.

In the second task, there is one mismatch out of 199 cases: in the first half-cycle, the output is 1 instead of 0. I am wondering if this issue is also related to the initialization of my data flip-flop. I attempted to set the output to 0 using both an initial block and by declaring it as = 0 in the module declaration, but neither approach resolved the issue.

Since I don’t have control over the testing environment, I can't reset the data flip-flop at the start.

Also I would prefer NOT to use high-level always blocks.

Is there anything I can do to fix these problems?

I am attaching a file with the current incorrect (1 out of 199 mismatch) second problem solution

Thank you!

Attached files:

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.