mc97_tb.v 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * mc97_tb.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. */
  7. `default_nettype none
  8. module mc97_tb;
  9. // Signals
  10. // -------
  11. wire mc97_sdata_out;
  12. wire mc97_sdata_in;
  13. wire mc97_sync;
  14. reg mc97_bitclk = 1'b0;
  15. wire [15:0] pcm_out_data;
  16. wire pcm_out_ack;
  17. wire [15:0] pcm_in_data;
  18. wire pcm_in_stb;
  19. wire [19:0] gpio_in;
  20. wire [19:0] gpio_out;
  21. wire gpio_ena;
  22. wire [ 5:0] reg_addr;
  23. wire [15:0] reg_wdata;
  24. wire [15:0] reg_rdata;
  25. wire reg_rerr;
  26. wire reg_valid;
  27. wire reg_we;
  28. wire reg_ack;
  29. wire cfg_run;
  30. wire stat_codec_ready;
  31. wire [12:0] stat_slot_valid;
  32. wire [12:0] stat_slot_req;
  33. wire stat_clr;
  34. reg clk = 1'b0;
  35. reg rst = 1'b1;
  36. // Setup recording
  37. // ---------------
  38. initial begin
  39. $dumpfile("mc97_tb.vcd");
  40. $dumpvars(0,mc97_tb);
  41. # 2000000 $finish;
  42. end
  43. always #29.833 clk <= !clk; // 24 MHz
  44. always #40.690 mc97_bitclk <= !mc97_bitclk; // 12.288 MHz
  45. initial begin
  46. #200 rst = 0;
  47. end
  48. // DUT
  49. // ---
  50. mc97 dut_I (
  51. .mc97_sdata_out (mc97_sdata_out),
  52. .mc97_sdata_in (mc97_sdata_in),
  53. .mc97_sync (mc97_sync),
  54. .mc97_bitclk (mc97_bitclk),
  55. .pcm_out_data (pcm_out_data),
  56. .pcm_out_ack (pcm_out_ack),
  57. .pcm_in_data (pcm_in_data),
  58. .pcm_in_stb (pcm_in_stb),
  59. .gpio_in (gpio_in),
  60. .gpio_out (gpio_out),
  61. .gpio_ena (gpio_ena),
  62. .reg_addr (reg_addr),
  63. .reg_wdata (reg_wdata),
  64. .reg_rdata (reg_rdata),
  65. .reg_rerr (reg_rerr),
  66. .reg_valid (reg_valid),
  67. .reg_we (reg_we),
  68. .reg_ack (reg_ack),
  69. .cfg_run (cfg_run),
  70. .stat_codec_ready(stat_codec_ready),
  71. .stat_slot_valid (stat_slot_valid),
  72. .stat_slot_req (stat_slot_req),
  73. .stat_clr (stat_clr),
  74. .clk (clk),
  75. .rst (rst)
  76. );
  77. assign mc97_sdata_in = mc97_sdata_out;
  78. assign pcm_out_data = 16'hcafe;
  79. assign gpio_ena = 1'b1;
  80. assign gpio_out = 20'hb00b5;
  81. assign reg_addr = 5'h1e;
  82. assign reg_wdata = 16'hbabe;
  83. assign reg_we = 1'b1;
  84. assign reg_valid = 1'b1;
  85. assign cfg_run = 1'b1;
  86. assign stat_clr = 1'b0;
  87. endmodule // mc97_tb