Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. reg [7:0] counter;
  2.  
  3. wire [8:0] subtract = { 1'b0, counter[7:0] } - 1'b1;
  4. ...
  5. counter[7:0] <= 8'h02; // initialize counter somewhere in always construct: wire[8] will get set on second cycle and catched on 3rd
  6. ...
  7. counter[7:0] <= subtract[7:0]; // update counter at every clock
  8.  
  9. wire [8:0] add = { 1'b0, counter[7:0] } + 1'b1;
  10. ...
  11. counter[7:0] <= 8'hfd; // initialize counter somewhere in always construct: wire[8] will get set on second cycle and catched on 3rd
  12. ...
  13. counter[7:0] <= add[7:0]; // update counter at every clock
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement