Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
2,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. // wishbone.v - wishbone master
  2. // 03-21-19 E. Brombaugh
  3.  
  4. `default_nettype none
  5.  
  6. module wishbone(
  7. input clk, // system clock
  8. input rst, // system reset
  9. input cs, // chip select
  10. input we, // write enable
  11. input [7:0] addr, // register select
  12. input [7:0] din, // data bus input
  13. output reg [7:0] dout, // data bus output
  14. output reg rdy, // low-true processor stall
  15.  
  16. output reg wb_stbo, // wishbone STB
  17. output reg [7:0] wb_adro, // wishbone Address
  18. output reg wb_rwo, // wishbone read/write
  19. output reg [7:0] wb_dato, // wishbone data out
  20. input wb_acki, // wishbone ACK
  21. input [7:0] wb_dati // wishbone data in
  22. );
  23.  
  24. // start bus transactions
  25. always @(posedge clk)
  26. if(rst == 1'b1)
  27. begin
  28. // clear all at reset
  29. dout <= 8'h00;
  30. rdy <= 1'b1;
  31. wb_stbo <= 1'b0;
  32. wb_adro <= 8'h00;
  33. wb_rwo <= 1'b1;
  34. wb_dato <= 8'h00;
  35. end
  36. else
  37. begin
  38. if(rdy == 1'b1)
  39. begin
  40. // No transaction pending - start new one
  41. if(cs == 1'b1)
  42. begin
  43. wb_stbo <= 1'b1;
  44. wb_adro <= addr;
  45. wb_rwo <= we;
  46. rdy <= 1'b0;
  47.  
  48. if(we == 1'b1)
  49. begin
  50. // write cycle
  51. wb_dato <= din;
  52. end
  53. end
  54. end
  55. else
  56. begin
  57. // Transaction in process
  58. if(wb_acki == 1'b1)
  59. begin
  60. // finish cycle
  61. wb_stbo <= 1'b0;
  62. rdy <= 1'b1;
  63. if(wb_rwo == 1'b1)
  64. begin
  65. // finish read cycle
  66. dout <= wb_dati;
  67. end
  68. end
  69. end
  70. end
  71. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement