nios2_uc_pio_BUTTON.v 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_BUTTON (
  19. // inputs:
  20. address,
  21. clk,
  22. in_port,
  23. reset_n,
  24. // outputs:
  25. readdata
  26. )
  27. ;
  28. output [ 31: 0] readdata;
  29. input [ 1: 0] address;
  30. input clk;
  31. input [ 7: 0] in_port;
  32. input reset_n;
  33. wire clk_en;
  34. wire [ 7: 0] data_in;
  35. wire [ 7: 0] read_mux_out;
  36. reg [ 31: 0] readdata;
  37. assign clk_en = 1;
  38. //s1, which is an e_avalon_slave
  39. assign read_mux_out = {8 {(address == 0)}} & data_in;
  40. always @(posedge clk or negedge reset_n)
  41. begin
  42. if (reset_n == 0)
  43. readdata <= 0;
  44. else if (clk_en)
  45. readdata <= {32'b0 | read_mux_out};
  46. end
  47. assign data_in = in_port;
  48. endmodule