bhainary

Ananya Johnson

Jul 29th, 2021 (edited)
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module myClock( input clk, input rst, output reg out_clk
  4.     );
  5. parameter N = 13000000;
  6.  
  7. reg [21:0] count;
  8.  
  9. always@(posedge clk) begin
  10.  
  11.     if (~rst) begin
  12.     count = 0;
  13.     out_clk = 0;
  14.     end
  15.    
  16.     else begin
  17.     count = count + 1;
  18.     end
  19.    
  20.     if (count == N) begin
  21.     count = 0;
  22.     out_clk = ~out_clk;
  23.     end
  24. end
  25.  
  26. endmodule
  27.  
  28. module johnson(input clk, input rst, output reg [3:0] x, output reg [6:0] y);
  29.  
  30. reg [3:0] counter;
  31. wire out_clk;
  32. myClock my(clk,rst,out_clk);
  33.  
  34. always@(posedge out_clk) begin
  35.     if(~rst) begin
  36.         counter = 0;
  37.         x = 4'b1110;
  38.         y = 7'b0000001;
  39.     end
  40.    
  41.     else begin
  42.         counter = {counter[2:0],~counter[3]};
  43.         x = {x[2:0],x[3]};
  44.     end
  45.    
  46.     case (counter)
  47.     0:y = 7'b0000001;
  48.     1:y = 7'b1001111;
  49.     3:y = 7'b0000110;
  50.     7:y = 7'b0001111;
  51.     14:y = 7'b0110000;
  52.     12:y = 7'b0110001;
  53.     8:y = 7'b0000000;
  54.     endcase
  55.  
  56. end
  57.  
  58. endmodule
  59.  
  60. //////////////////////////////////////////////
  61.  
  62. NET "clk" LOC = "P51";
  63. NET "rst" LOC = "P141";
  64.  
  65. NET "y[6]" LOC="P140";
  66. NET "y[5]" LOC="P137";
  67. NET "y[4]" LOC="P134";
  68. NET "y[3]" LOC="P133";
  69. NET "y[2]" LOC="P131";
  70. NET "y[1]" LOC="P127";
  71. NET "y[0]" LOC="P126";
  72. NET "x[0]" LOC ="P120";
  73. NET "x[1]" LOC ="P119";
  74. NET "x[2]" LOC ="P118";
  75. NET "x[3]" LOC ="P117";
Advertisement
Add Comment
Please, Sign In to add comment