Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <systemc.h>
  2. #include <stdio.h>
  3.  
  4. #ifdef __RTL_SIMULATION__
  5. #include "iosc_rtl_wrapper.h"
  6. #define iosc iosc_rtl_wrapper
  7. #else
  8. #include "ios.h"
  9. #endif
  10.  
  11. #include "ios_driver.h"
  12.  
  13. int sc_main (int argc , char *argv[])
  14. {
  15. sc_report_handler::set_actions("/IEEE_Std_1666/deprecated", SC_DO_NOTHING);
  16. sc_report_handler::set_actions( SC_ID_LOGIC_X_TO_BOOL_, SC_LOG);
  17. sc_report_handler::set_actions( SC_ID_VECTOR_CONTAINS_LOGIC_VALUE_, SC_LOG);
  18. sc_report_handler::set_actions( SC_ID_OBJECT_EXISTS_, SC_LOG);
  19.  
  20. sc_trace_file *tracefile;
  21.  
  22. sc_signal<bool> s_reset;
  23. sc_signal<sc_uint<4> > s_switch;
  24. sc_signal<sc_uint<4> > s_ctrl;
  25. sc_signal<sc_uint<4> > s_leds;
  26.  
  27. // Create a 10ns period clock signal
  28. sc_clock s_clk("s_clk", 10, SC_NS);
  29. iosc U_iosc("U_iosc");
  30. ios_driver U_tb_driver("U_tb_driver");
  31.  
  32. // Create tacefile
  33. tracefile = sc_create_vcd_trace_file("IOSC_Wave");
  34. if (!tracefile) cout << "Could not create trace file." << endl;
  35.  
  36. // Set resolution of trace file to be in 10 US
  37. tracefile->set_time_unit(1, SC_NS);
  38.  
  39. sc_trace(tracefile, s_clk, "clock");
  40.  
  41. sc_trace(tracefile, s_reset, "reset");
  42.  
  43. sc_trace(tracefile, s_ctrl, "ctrl");
  44. sc_trace(tracefile, s_leds, "leds");
  45.  
  46. sc_trace(tracefile, s_switch, "switch");
  47.  
  48. // Connect the DUT
  49. U_iosc.clk(s_clk);
  50. U_iosc.reset(s_reset);
  51.  
  52. U_iosc.ctrl(s_ctrl);
  53. U_iosc.outLeds(s_leds);
  54. U_iosc.inSwitch(s_switch);
  55.  
  56. // Drive stimuli from dat* ports
  57. // Capture results at out* ports
  58. U_tb_driver.clk(s_clk);
  59. U_tb_driver.reset(s_reset);
  60.  
  61. U_tb_driver.inLeds(s_leds);
  62. U_tb_driver.outSwitch(s_switch);
  63. U_tb_driver.ctrl(s_ctrl);
  64.  
  65. // Sim for 200
  66. int end_time = 200;
  67. std::cout << "INFO: Simulating" << std::endl;
  68. // start simulation
  69. sc_start(end_time, SC_NS);
  70.  
  71. if (U_tb_driver.retval == 0) {
  72. printf("Test passed !\n");
  73. } else {
  74. printf("Test failed !!!\n");
  75. }
  76.  
  77. sc_close_vcd_trace_file(tracefile);
  78. std::cout << "Created IOSC_Wave.vcd" << std::endl;
  79.  
  80. return U_tb_driver.retval;
  81. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement