Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // Company:
  5. // Engineer:
  6. //
  7. // Create Date:   13:16:34 11/14/2018
  8. // Design Name:   zad
  9. // Module Name:   /home/stud2015/5stasiak/sem7/egzamin/egzamin/test.v
  10. // Project Name:  egzamin
  11. // Target Device:  
  12. // Tool versions:  
  13. // Description:
  14. //
  15. // Verilog Test Fixture created by ISE for module: zad
  16. //
  17. // Dependencies:
  18. //
  19. // Revision:
  20. // Revision 0.01 - File Created
  21. // Additional Comments:
  22. //
  23. ////////////////////////////////////////////////////////////////////////////////
  24.  
  25. module test;
  26.  
  27.     // Inputs
  28.     reg clk;
  29.     reg rst;
  30.     reg in;
  31.  
  32.     // Outputs
  33.     wire ready;
  34.     wire ovl;
  35.     wire [clogb2(14)-1:0] data;
  36.  
  37.     // Instantiate the Unit Under Test (UUT)
  38.     zad #(.range(14)) uut (
  39.         .clk(clk),
  40.         .rst(rst),
  41.         .in(in),
  42.         .ready(ready),
  43.         .ovl(ovl),
  44.         .data(data)
  45.     );
  46.  
  47.     initial begin
  48.         clk = 1'b0;
  49.         forever #10 clk = ~clk;
  50.     end
  51.    
  52.     initial begin
  53.         rst = 1'b0;
  54.         #5 rst = 1'b1;
  55.         #10 rst = 1'b0;
  56.     end
  57.    
  58.     always @(negedge clk)
  59.         in <= {$random}%2;
  60.        
  61.     initial #5000 $finish;
  62.    
  63. // funkcja logarytmujaca
  64. function integer clogb2(input integer value);
  65.     begin
  66.         value = value - 1;
  67.         for(clogb2 = 0; value > 0; clogb2 = clogb2 + 1)
  68.             value = value >> 1;
  69.     end
  70. endfunction
  71. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement