Verwendeter Programmcode in Studienarbeit für ESY1B zum Thema "Verifikation mit SystemVerilog und Python"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

registerInterface.v 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //////////////////////////////////////////////////////////////////////
  2. //// ////
  3. //// registerInterface.v ////
  4. //// ////
  5. //// This file is part of the i2cSlave opencores effort.
  6. //// <http://www.opencores.org/cores//> ////
  7. //// ////
  8. //// Module Description: ////
  9. //// You will need to modify this file to implement your
  10. //// interface.
  11. //// Add your control and status bytes/bits to module inputs and outputs,
  12. //// and also to the I2C read and write process blocks
  13. //// ////
  14. //// To Do: ////
  15. ////
  16. //// ////
  17. //// Author(s): ////
  18. //// - Steve Fielding, sfielding@base2designs.com ////
  19. //// ////
  20. //////////////////////////////////////////////////////////////////////
  21. //// ////
  22. //// Copyright (C) 2008 Steve Fielding and OPENCORES.ORG ////
  23. //// ////
  24. //// This source file may be used and distributed without ////
  25. //// restriction provided that this copyright statement is not ////
  26. //// removed from the file and that any derivative work contains ////
  27. //// the original copyright notice and the associated disclaimer. ////
  28. //// ////
  29. //// This source file is free software; you can redistribute it ////
  30. //// and/or modify it under the terms of the GNU Lesser General ////
  31. //// Public License as published by the Free Software Foundation; ////
  32. //// either version 2.1 of the License, or (at your option) any ////
  33. //// later version. ////
  34. //// ////
  35. //// This source is distributed in the hope that it will be ////
  36. //// useful, but WITHOUT ANY WARRANTY; without even the implied ////
  37. //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
  38. //// PURPOSE. See the GNU Lesser General Public License for more ////
  39. //// details. ////
  40. //// ////
  41. //// You should have received a copy of the GNU Lesser General ////
  42. //// Public License along with this source; if not, download it ////
  43. //// from <http://www.opencores.org/lgpl.shtml> ////
  44. //// ////
  45. //////////////////////////////////////////////////////////////////////
  46. //
  47. `include "i2cSlave_define.v"
  48. module registerInterface (
  49. clk,
  50. addr,
  51. dataIn,
  52. writeEn,
  53. dataOut,
  54. tb_readEn,
  55. tb_writeEn,
  56. tb_addr,
  57. tb_dataIn,
  58. tb_dataOut
  59. );
  60. // i2c interface
  61. input clk;
  62. input [15:0] addr;
  63. input [7:0] dataIn;
  64. input writeEn;
  65. output [7:0] dataOut;
  66. reg [7:0] dataOut;
  67. // speicher
  68. reg [7:0] memory [16'hffff:0];
  69. // tb interface
  70. input tb_readEn;
  71. input tb_writeEn;
  72. input [15:0] tb_addr;
  73. input [15:0] tb_dataIn;
  74. output [15:0] tb_dataOut;
  75. reg [15:0] tb_dataOut;
  76. // --- TB Read
  77. always @(posedge tb_readEn) begin
  78. tb_dataOut[15:8] <= memory[tb_addr];
  79. tb_dataOut[7:0] <= memory[tb_addr + 1'b1];
  80. end
  81. // --- TB Write
  82. always @(posedge tb_writeEn) begin
  83. memory[tb_addr] <= tb_dataIn[15:8];
  84. memory[tb_addr + 1'b1] <= tb_dataIn[7:0];
  85. end
  86. // --- I2C Read
  87. always @(posedge clk) begin
  88. dataOut <= memory[addr];
  89. end
  90. // --- I2C Write
  91. always @(posedge clk) begin
  92. if (writeEn == 1'b1) begin
  93. memory[addr] <= dataIn;
  94. end
  95. end
  96. endmodule