- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I have a module takes in input [15:0] in and I want to compare this new input to my previous value by number of counts. module _update(input clk, input [15:0] in, ....) reg [15:0] rPrev, rChange; always @(posedge clk) begin rPrev <= in; end always @(posedge clk) begin if (in > rPrev) rChange <= in - rPrev; else if (in < rPrev) rChange <= rPrev - in; end always @(posedge clk) begin if (rPrev != in && rChange >= 50 && rChange <= 100) begin // rChange has to be in range 50 to 100 counts // update end end Am I doing this right? Thanks, SeanLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
why not simulate it in a testbench and find out yourself?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
People who ask "help me with my homework/project" questions on the forums will probably learn more by talking with fellow students and the prof. You need to learn how to simulate hardware to move forward with this.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page