nios2_uc_pio_COL_ADDR.v 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //Legal Notice: (C)2020 Altera Corporation. All rights reserved. Your
  2. //use of Altera Corporation's design tools, logic functions and other
  3. //software and tools, and its AMPP partner logic functions, and any
  4. //output files any of the foregoing (including device programming or
  5. //simulation files), and any associated documentation or information are
  6. //expressly subject to the terms and conditions of the Altera Program
  7. //License Subscription Agreement or other applicable license agreement,
  8. //including, without limitation, that your use is for the sole purpose
  9. //of programming logic devices manufactured by Altera and sold by Altera
  10. //or its authorized distributors. Please refer to the applicable
  11. //agreement for further details.
  12. // synthesis translate_off
  13. `timescale 1ns / 1ps
  14. // synthesis translate_on
  15. // turn off superfluous verilog processor warnings
  16. // altera message_level Level1
  17. // altera message_off 10034 10035 10036 10037 10230 10240 10030
  18. module nios2_uc_pio_COL_ADDR (
  19. // inputs:
  20. address,
  21. chipselect,
  22. clk,
  23. reset_n,
  24. write_n,
  25. writedata,
  26. // outputs:
  27. out_port,
  28. readdata
  29. )
  30. ;
  31. output [ 7: 0] out_port;
  32. output [ 31: 0] readdata;
  33. input [ 2: 0] address;
  34. input chipselect;
  35. input clk;
  36. input reset_n;
  37. input write_n;
  38. input [ 31: 0] writedata;
  39. wire clk_en;
  40. reg [ 7: 0] data_out;
  41. wire [ 7: 0] out_port;
  42. wire [ 7: 0] read_mux_out;
  43. wire [ 31: 0] readdata;
  44. wire wr_strobe;
  45. assign clk_en = 1;
  46. //s1, which is an e_avalon_slave
  47. assign read_mux_out = {8 {(address == 0)}} & data_out;
  48. assign wr_strobe = chipselect && ~write_n;
  49. always @(posedge clk or negedge reset_n)
  50. begin
  51. if (reset_n == 0)
  52. data_out <= 0;
  53. else if (clk_en)
  54. if (wr_strobe)
  55. data_out <= (address == 5)? data_out & ~writedata[7 : 0]: (address == 4)? data_out | writedata[7 : 0]: (address == 0)? writedata[7 : 0]: data_out;
  56. end
  57. assign readdata = {32'b0 | read_mux_out};
  58. assign out_port = data_out;
  59. endmodule