SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Sequencer (
  2.     output reg interrupt, // causes data to be updated
  3.     output reg wdata,     // goes to my consumer
  4.     input clock,          // tick counter
  5.     input [7:0] data,     // describes the current pulse
  6.     input reset           // what it says on the tin
  7. );
  8.  
  9. reg [6:0] counter;
  10.  
  11. always @(posedge clock)
  12. begin
  13.     if (reset)
  14.     begin
  15.         counter <= 0;
  16.         interrupt <= 0;
  17.         wdata <= 0;
  18.     end
  19.     else
  20.     begin
  21.         // This matches both pulses (00-7f) and spaces (80).
  22.         // For a space, the counter will roll over back to zero.
  23.         if (counter == data[6:0])
  24.         begin
  25.             counter <= 0;
  26.             interrupt <= 1;
  27.             wdata <= ~data[7]; // 0x80 means no pulse
  28.         end
  29.         else
  30.         begin
  31.             counter <= counter + 7'b1;
  32.             interrupt <= 0;
  33.             wdata <= 0;
  34.         end
  35.     end
  36. end
  37.  
  38. endmodule
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top