Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.01 KB | None | 0 0
  1. `default_nettype none
  2. module simple_ipod_solution(
  3.  
  4. //////////// CLOCK //////////
  5. CLOCK_50,
  6.  
  7. //////////// LED //////////
  8. LEDG,
  9. LEDR,
  10.  
  11. //////////// KEY //////////
  12. KEY,
  13.  
  14. //////////// SW //////////
  15. SW,
  16.  
  17. //////////// SEG7 //////////
  18. HEX0,
  19. HEX1,
  20. HEX2,
  21. HEX3,
  22. HEX4,
  23. HEX5,
  24. HEX6,
  25. HEX7,
  26.  
  27. //////////// RS232 //////////
  28. UART_RXD,
  29. UART_TXD,
  30.  
  31. //////////// Audio //////////
  32. AUD_ADCDAT,
  33. AUD_ADCLRCK,
  34. AUD_BCLK,
  35. AUD_DACDAT,
  36. AUD_DACLRCK,
  37. AUD_XCK,
  38.  
  39. //////////// I2C for Audio //////////
  40. I2C_SCLK,
  41. I2C_SDAT,
  42.  
  43. //////////// Flash //////////
  44. FL_ADDR,
  45. FL_CE_N,
  46. FL_DQ,
  47. FL_OE_N,
  48. FL_RST_N,
  49. FL_WE_N,
  50.  
  51.  
  52. //////// PS2 //////////
  53. PS2_CLK,
  54. PS2_DAT,
  55.  
  56. //////// SDRAM //////////
  57. DRAM_ADDR,
  58. DRAM_BA_0,
  59. DRAM_BA_1,
  60. DRAM_CAS_N,
  61. DRAM_CKE,
  62. DRAM_CLK,
  63. DRAM_CS_N,
  64. DRAM_DQ,
  65. DRAM_LDQM,
  66. DRAM_UDQM,
  67. DRAM_RAS_N,
  68. DRAM_WE_N,
  69.  
  70.  
  71. //////// SDCARD //////////
  72. SD_CLK,
  73. SD_CMD,
  74. SD_DAT,
  75. SD_DAT3,
  76.  
  77.  
  78. //////// GPIO //////////
  79. GPIO_0,
  80. GPIO_1,
  81.  
  82. //////////// SRAM //////////
  83. SRAM_ADDR,
  84. SRAM_CE_N,
  85. SRAM_DQ,
  86. SRAM_LB_N,
  87. SRAM_OE_N,
  88. SRAM_UB_N,
  89. SRAM_WE_N,
  90.  
  91. //////////// LCD //////////
  92. LCD_DATA,
  93. LCD_EN,
  94. LCD_ON,
  95. LCD_RS,
  96. LCD_RW
  97.  
  98. );
  99. `define zero_pad(width,signal) {{((width)-$size(signal)){1'b0}},(signal)}
  100. //=======================================================
  101. // PORT declarations
  102. //=======================================================
  103.  
  104. //////////// CLOCK //////////
  105. input CLOCK_50;
  106.  
  107. //////////// LED //////////
  108. output [8:0] LEDG;
  109. output [17:0] LEDR;
  110.  
  111. //////////// KEY //////////
  112. input [3:0] KEY;
  113.  
  114. //////////// SW //////////
  115. input [17:0] SW;
  116.  
  117. //////////// SEG7 //////////
  118. output [6:0] HEX0;
  119. output [6:0] HEX1;
  120. output [6:0] HEX2;
  121. output [6:0] HEX3;
  122. output [6:0] HEX4;
  123. output [6:0] HEX5;
  124. output [6:0] HEX6;
  125. output [6:0] HEX7;
  126.  
  127. //////////// LCD //////////
  128. inout [7:0] LCD_DATA;
  129. output LCD_EN;
  130. output LCD_ON;
  131. output LCD_RS;
  132. output LCD_RW;
  133.  
  134. //////////// RS232 //////////
  135. input UART_RXD;
  136. output UART_TXD;
  137.  
  138. //////////// Audio //////////
  139. input AUD_ADCDAT;
  140. inout AUD_ADCLRCK;
  141. inout AUD_BCLK;
  142. output AUD_DACDAT;
  143. inout AUD_DACLRCK;
  144. output AUD_XCK;
  145.  
  146. //////////// I2C for Audio //////////
  147. output I2C_SCLK;
  148. inout I2C_SDAT;
  149.  
  150. //////////// Flash //////////
  151. output [21:0] FL_ADDR;
  152. output FL_CE_N;
  153. inout [7:0] FL_DQ;
  154. output FL_OE_N;
  155. output FL_RST_N;
  156. output FL_WE_N;
  157.  
  158.  
  159.  
  160. //////////// PS2 //////////
  161. inout PS2_CLK;
  162. inout PS2_DAT;
  163.  
  164. //////////// SDCARD //////////
  165. output SD_CLK;
  166. inout SD_CMD;
  167. inout SD_DAT;
  168. input SD_DAT3;
  169.  
  170. //////////// GPIO //////////
  171. inout [35:0] GPIO_0;
  172. inout [35:0] GPIO_1;
  173.  
  174.  
  175. //////////// SRAM //////////
  176. output [17:0] SRAM_ADDR;
  177. output SRAM_CE_N;
  178. inout [15:0] SRAM_DQ;
  179. output SRAM_LB_N;
  180. output SRAM_OE_N;
  181. output SRAM_UB_N;
  182. output SRAM_WE_N;
  183.  
  184.  
  185. //////////// SDRAM //////////
  186. output [11:0] DRAM_ADDR;
  187. output DRAM_BA_0;
  188. output DRAM_BA_1;
  189. output DRAM_CAS_N;
  190. output DRAM_CKE;
  191. output DRAM_CLK;
  192. output DRAM_CS_N;
  193. inout [15:0] DRAM_DQ;
  194. output DRAM_LDQM;
  195. output DRAM_UDQM;
  196. output DRAM_RAS_N;
  197. output DRAM_WE_N;
  198.  
  199.  
  200. //=======================================================
  201. // REG/WIRE declarations
  202. //=======================================================
  203. // Input and output declarations
  204. logic CLK_50M;
  205. logic [7:0] LED;
  206. assign CLK_50M = CLOCK_50;
  207. assign LEDG[7:0] = LED[7:0];
  208. wire audio_enable = SW[0];
  209. //Character definitions
  210.  
  211. //numbers
  212. parameter character_0 =8'h30;
  213. parameter character_1 =8'h31;
  214. parameter character_2 =8'h32;
  215. parameter character_3 =8'h33;
  216. parameter character_4 =8'h34;
  217. parameter character_5 =8'h35;
  218. parameter character_6 =8'h36;
  219. parameter character_7 =8'h37;
  220. parameter character_8 =8'h38;
  221. parameter character_9 =8'h39;
  222.  
  223.  
  224. //Uppercase Letters
  225. parameter character_A =8'h41;
  226. parameter character_B =8'h42;
  227. parameter character_C =8'h43;
  228. parameter character_D =8'h44;
  229. parameter character_E =8'h45;
  230. parameter character_F =8'h46;
  231. parameter character_G =8'h47;
  232. parameter character_H =8'h48;
  233. parameter character_I =8'h49;
  234. parameter character_J =8'h4A;
  235. parameter character_K =8'h4B;
  236. parameter character_L =8'h4C;
  237. parameter character_M =8'h4D;
  238. parameter character_N =8'h4E;
  239. parameter character_O =8'h4F;
  240. parameter character_P =8'h50;
  241. parameter character_Q =8'h51;
  242. parameter character_R =8'h52;
  243. parameter character_S =8'h53;
  244. parameter character_T =8'h54;
  245. parameter character_U =8'h55;
  246. parameter character_V =8'h56;
  247. parameter character_W =8'h57;
  248. parameter character_X =8'h58;
  249. parameter character_Y =8'h59;
  250. parameter character_Z =8'h5A;
  251.  
  252. //Lowercase Letters
  253. parameter character_lowercase_a= 8'h61;
  254. parameter character_lowercase_b= 8'h62;
  255. parameter character_lowercase_c= 8'h63;
  256. parameter character_lowercase_d= 8'h64;
  257. parameter character_lowercase_e= 8'h65;
  258. parameter character_lowercase_f= 8'h66;
  259. parameter character_lowercase_g= 8'h67;
  260. parameter character_lowercase_h= 8'h68;
  261. parameter character_lowercase_i= 8'h69;
  262. parameter character_lowercase_j= 8'h6A;
  263. parameter character_lowercase_k= 8'h6B;
  264. parameter character_lowercase_l= 8'h6C;
  265. parameter character_lowercase_m= 8'h6D;
  266. parameter character_lowercase_n= 8'h6E;
  267. parameter character_lowercase_o= 8'h6F;
  268. parameter character_lowercase_p= 8'h70;
  269. parameter character_lowercase_q= 8'h71;
  270. parameter character_lowercase_r= 8'h72;
  271. parameter character_lowercase_s= 8'h73;
  272. parameter character_lowercase_t= 8'h74;
  273. parameter character_lowercase_u= 8'h75;
  274. parameter character_lowercase_v= 8'h76;
  275. parameter character_lowercase_w= 8'h77;
  276. parameter character_lowercase_x= 8'h78;
  277. parameter character_lowercase_y= 8'h79;
  278. parameter character_lowercase_z= 8'h7A;
  279.  
  280. //Other Characters
  281. parameter character_colon = 8'h3A; //':'
  282. parameter character_stop = 8'h2E; //'.'
  283. parameter character_semi_colon = 8'h3B; //';'
  284. parameter character_minus = 8'h2D; //'-'
  285. parameter character_divide = 8'h2F; //'/'
  286. parameter character_plus = 8'h2B; //'+'
  287. parameter character_comma = 8'h2C; // ','
  288. parameter character_less_than = 8'h3C; //'<'
  289. parameter character_greater_than = 8'h3E; //'>'
  290. parameter character_equals = 8'h3D; //'='
  291. parameter character_question = 8'h3F; //'?'
  292. parameter character_dollar = 8'h24; //'$'
  293. parameter character_space=8'h20; //' '
  294. parameter character_exclaim=8'h21; //'!'
  295.  
  296.  
  297. wire Clock_1KHz, Clock_1Hz;
  298. wire Sample_Clk_Signal;
  299.  
  300. //=======================================================================================================================
  301. //
  302. // Insert your code for Lab2 here!
  303. //
  304. //
  305.  
  306. assign FL_WE_N = 1'b1;
  307. assign FL_RST_N = 1'b1;
  308.  
  309. wire Clock_22KHz;
  310. wire edge_detected;
  311. wire finish;
  312. wire start;
  313. wire [21:0] next_addr;
  314. wire [15:0] audio_data;
  315.  
  316. // Generate Clock_22KHz from CLOCK_50
  317. // Clk Count = ((50*10^6)/(22*10^3))/2 = ~1136
  318. Generate_Arbitrary_Divided_Clk32 Generate_Clk_22KHz(.inclk(CLOCK_50),.outclk(Clock_22KHz),.outclk_Not(),.div_clk_count(11'd1136),.Reset(1'h1));
  319.  
  320. // edge_detected detects rising edges of Clock_22KHz
  321. edge_detector i_edge_detector(.async_clk(Clock_22KHz), .clk(CLOCK_50), .edge_detected(edge_detected));
  322.  
  323. address_FSM i_address_FSM(.clk(CLOCK_50), .edge_detect(edge_detected), .finish_flash(finish), .out_addr(next_addr), .start_flash(start));
  324.  
  325. read_flash_fsm(.clk(CLOCK_50), .start(start), .in_addr(next_addr), .flash_data(FL_DQ), .finish(finish), .out_addr(FL_ADDR), .out_CE_N(FL_CE_N), .out_OE_N(FL_OE_N), .audio_data(audio_data));
  326.  
  327. //Audio Generation Signal
  328. //Note that the audio needs signed data - so convert 1 bit to 8 bits signed
  329. //wire [7:0] audio_data = {((~Sample_Clk_Signal)&audio_enable),{7{Sample_Clk_Signal&audio_enable}}}; //generate signed sample audio signal
  330.  
  331.  
  332.  
  333. //======================================================================================
  334. //
  335. // Keyboard Interface
  336. //
  337. //
  338.  
  339. wire ps2c, ps2d; //filtered kbd wires
  340. wire kbd_data_ready, Kbd_to_LCD_finish;
  341.  
  342. doublesync ps2c_doublsync
  343. (.indata(PS2_CLK),
  344. .outdata(ps2c),
  345. .clk(CLK_50M),
  346. .reset(1'b1));
  347.  
  348. doublesync ps2d_doublsync
  349. (.indata(PS2_DAT),
  350. .outdata(ps2d),
  351. .clk(CLK_50M),
  352. .reset(1'b1));
  353.  
  354. wire reset_kbd_data;
  355. (* KEEP = "TRUE" *) wire conv_now_ignore_timing;
  356.  
  357. wire [7:0] kbd_received_ascii_code, kbd_scan_code;
  358.  
  359. Kbd_ctrl Kbd_Controller(
  360. .kbd_clk(ps2c),
  361. .kbd_data(ps2d),
  362. .clk(CLK_50M),
  363. .scan_code(kbd_scan_code),
  364. .reset_kbd_reg(~reset_kbd_data),
  365. .data_ready(kbd_data_ready)
  366. );
  367.  
  368. key2ascii kbd2ascii(
  369. .key_code(kbd_scan_code),
  370. .ascii_code(kbd_received_ascii_code),
  371. .clk(conv_now_ignore_timing)
  372. );
  373.  
  374. parameter scope_info_bytes = 16;
  375. parameter scope_info_bits_per_byte = 8;
  376.  
  377. wire [15:0] write_kbd_debug;
  378.  
  379. wire [scope_info_bits_per_byte-1:0] scope_info0, scope_info1, scope_info2,
  380. scope_info3, scope_info4, scope_info5, scope_info6, scope_info7, scope_info8,
  381. scope_info9, scope_info10, scope_info11, scope_info12, scope_info13,
  382. scope_info14, scope_info15;
  383.  
  384. Write_Kbd_To_Scope_LCD Write_Kbd_To_LCD1
  385. (.kbd_ascii_data(kbd_received_ascii_code),
  386. .kbd_ready(kbd_data_ready), .reset_kbd_data(reset_kbd_data),
  387. .sm_clk(CLK_50M), .reset(1'b1),
  388. .finish(Kbd_to_LCD_finish),
  389. .scope_info0(scope_info0),
  390. .scope_info1(scope_info1),
  391. .scope_info2(scope_info2),
  392. .scope_info3(scope_info3),
  393. .scope_info4(scope_info4),
  394. .scope_info5(scope_info5),
  395. .scope_info6(scope_info6),
  396. .scope_info7(scope_info7),
  397. .scope_info8(scope_info8),
  398. .scope_info9(scope_info9),
  399. .scope_info10(scope_info10),
  400. .scope_info11(scope_info11),
  401. .scope_info12(scope_info12),
  402. .scope_info13(scope_info13),
  403. .scope_info14(scope_info14),
  404. .scope_info15(scope_info15),
  405. .debug(write_kbd_debug),
  406. .convert_now(conv_now_ignore_timing)
  407. );
  408.  
  409. //=====================================================================================
  410. //
  411. // LCD Scope Acquisition Circuitry Wire Definitions
  412. //
  413. //=====================================================================================
  414.  
  415. wire allow_run_LCD_scope;
  416. wire [15:0] scope_channelA, scope_channelB;
  417. wire scope_clk;
  418. reg user_scope_enable_trigger;
  419. wire user_scope_enable;
  420. wire user_scope_enable_trigger_path0, user_scope_enable_trigger_path1;
  421. wire scope_enable_source = SW[16];
  422. wire choose_LCD_or_SCOPE = SW[17];
  423.  
  424.  
  425. doublesync user_scope_enable_sync1(.indata(scope_enable_source),
  426. .outdata(user_scope_enable),
  427. .clk(CLK_50M),
  428. .reset(1'b1));
  429.  
  430. //Generate the oscilloscope clock
  431. Generate_Arbitrary_Divided_Clk32
  432. Generate_LCD_scope_Clk(
  433. .inclk(CLK_50M),
  434. .outclk(scope_clk),
  435. .outclk_Not(),
  436. .div_clk_count(scope_sampling_clock_count),
  437. .Reset(1'h1));
  438.  
  439. //Scope capture channels
  440.  
  441. scope_capture LCD_scope_channelA(
  442. .clk(scope_clk),
  443. .the_signal(Sample_Clk_Signal),
  444. .capture_enable(allow_run_LCD_scope & user_scope_enable),
  445. .captured_data(scope_channelA),
  446. .reset(1'b1));
  447.  
  448. scope_capture LCD_scope_channelB
  449. (
  450. .clk(scope_clk),
  451. .the_signal(SW[1]),
  452. .capture_enable(allow_run_LCD_scope & user_scope_enable),
  453. .captured_data(scope_channelB),
  454. .reset(1'b1));
  455.  
  456. assign LCD_ON = 1'b1;
  457. //The LCD scope and display
  458. LCD_Scope_Encapsulated_pacoblaze LCD_LED_scope(
  459. //LCD control signals
  460. .lcd_d(LCD_DATA),//don't touch
  461. .lcd_rs(LCD_RS), //don't touch
  462. .lcd_rw(LCD_RW), //don't touch
  463. .lcd_e(LCD_EN), //don't touch
  464. .clk(CLK_50M), //don't touch
  465.  
  466. //LCD Display values
  467. //.InH(8'hAA),
  468. .InH(next_addr[21:14]),
  469. .InG(next_addr[13:6]),
  470. .InF({next_addr[5:0], 2'b0}),
  471. .InE(8'h00),
  472. .InD(8'h00),
  473. .InC(8'h00),
  474. .InB(8'h00),
  475. .InA(8'h00),
  476.  
  477. //LCD display information signals
  478. .InfoH({scope_info15,scope_info14}),
  479. .InfoG({scope_info13,scope_info12}),
  480. .InfoF({scope_info11,scope_info10}),
  481. .InfoE({scope_info9,scope_info8}),
  482. .InfoD({scope_info7,scope_info6}),
  483. .InfoC({scope_info5,scope_info4}),
  484. .InfoB({scope_info3,scope_info2}),
  485. .InfoA({scope_info1,scope_info0}),
  486.  
  487. //choose to display the values or the oscilloscope
  488. .choose_scope_or_LCD(choose_LCD_or_SCOPE),
  489.  
  490. //scope channel declarations
  491. .scope_channelA(scope_channelA), //don't touch
  492. .scope_channelB(scope_channelB), //don't touch
  493.  
  494. //scope information generation
  495. .ScopeInfoA({character_1,character_K,character_H,character_lowercase_z}),
  496. .ScopeInfoB({character_S,character_W,character_1,character_space}),
  497.  
  498. //enable_scope is used to freeze the scope just before capturing
  499. //the waveform for display (otherwise the sampling would be unreliable)
  500. .enable_scope(allow_run_LCD_scope) //don't touch
  501.  
  502. );
  503.  
  504.  
  505. //=====================================================================================
  506. //
  507. // Seven-Segment and speed control
  508. //
  509. //=====================================================================================
  510.  
  511. wire speed_up_event, speed_down_event;
  512.  
  513. //Generate 1 KHz Clock
  514. Generate_Arbitrary_Divided_Clk32
  515. Gen_1KHz_clk
  516. (
  517. .inclk(CLK_50M),
  518. .outclk(Clock_1KHz),
  519. .outclk_Not(),
  520. .div_clk_count(32'h61A6), //change this if necessary to suit your module
  521. .Reset(1'h1));
  522.  
  523. wire speed_up_raw;
  524. wire speed_down_raw;
  525.  
  526. doublesync
  527. key0_doublsync
  528. (.indata(!KEY[0]),
  529. .outdata(speed_up_raw),
  530. .clk(Clock_1KHz),
  531. .reset(1'b1));
  532.  
  533.  
  534. doublesync
  535. key1_doublsync
  536. (.indata(!KEY[1]),
  537. .outdata(speed_down_raw),
  538. .clk(Clock_1KHz),
  539. .reset(1'b1));
  540.  
  541.  
  542. parameter num_updown_events_per_sec = 10;
  543. parameter num_1KHZ_clocks_between_updown_events = 1000/num_updown_events_per_sec;
  544.  
  545. reg [15:0] updown_counter = 0;
  546. always @(posedge Clock_1KHz)
  547. begin
  548. if (updown_counter >= num_1KHZ_clocks_between_updown_events)
  549. begin
  550. if (speed_up_raw)
  551. begin
  552. speed_up_event_trigger <= 1;
  553. end
  554.  
  555. if (speed_down_raw)
  556. begin
  557. speed_down_event_trigger <= 1;
  558. end
  559. updown_counter <= 0;
  560. end
  561. else
  562. begin
  563. updown_counter <= updown_counter + 1;
  564. speed_up_event_trigger <=0;
  565. speed_down_event_trigger <= 0;
  566. end
  567. end
  568.  
  569. wire speed_up_event_trigger;
  570. wire speed_down_event_trigger;
  571.  
  572. async_trap_and_reset_gen_1_pulse
  573. make_speedup_pulse
  574. (
  575. .async_sig(speed_up_event_trigger),
  576. .outclk(CLK_50M),
  577. .out_sync_sig(speed_up_event),
  578. .auto_reset(1'b1),
  579. .reset(1'b1)
  580. );
  581.  
  582. async_trap_and_reset_gen_1_pulse
  583. make_speedown_pulse
  584. (
  585. .async_sig(speed_down_event_trigger),
  586. .outclk(CLK_50M),
  587. .out_sync_sig(speed_down_event),
  588. .auto_reset(1'b1),
  589. .reset(1'b1)
  590. );
  591.  
  592.  
  593. wire speed_reset_event;
  594.  
  595. doublesync
  596. key2_doublsync
  597. (.indata(!KEY[2]),
  598. .outdata(speed_reset_event),
  599. .clk(CLK_50M),
  600. .reset(1'b1));
  601.  
  602. parameter oscilloscope_speed_step = 100;
  603.  
  604. wire [15:0] speed_control_val;
  605. speed_reg_control
  606. speed_reg_control_inst
  607. (
  608. .clk(CLK_50M),
  609. .up_event(speed_up_event),
  610. .down_event(speed_down_event),
  611. .reset_event(speed_reset_event),
  612. .speed_control_val(speed_control_val)
  613. );
  614.  
  615. logic [15:0] scope_sampling_clock_count;
  616. parameter [15:0] default_scope_sampling_clock_count = 12499; //2KHz
  617.  
  618.  
  619. always @ (posedge CLK_50M)
  620. begin
  621. scope_sampling_clock_count <= default_scope_sampling_clock_count+{{16{speed_control_val[15]}},speed_control_val};
  622. end
  623.  
  624.  
  625.  
  626. logic [7:0] Seven_Seg_Val[7:0];
  627. logic [3:0] Seven_Seg_Data[7:0];
  628.  
  629. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst0(.ssOut(Seven_Seg_Val[0]), .nIn(Seven_Seg_Data[0]));
  630. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst1(.ssOut(Seven_Seg_Val[1]), .nIn(Seven_Seg_Data[1]));
  631. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst2(.ssOut(Seven_Seg_Val[2]), .nIn(Seven_Seg_Data[2]));
  632. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst3(.ssOut(Seven_Seg_Val[3]), .nIn(Seven_Seg_Data[3]));
  633. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst4(.ssOut(Seven_Seg_Val[4]), .nIn(Seven_Seg_Data[4]));
  634. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst5(.ssOut(Seven_Seg_Val[5]), .nIn(Seven_Seg_Data[5]));
  635. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst6(.ssOut(Seven_Seg_Val[6]), .nIn(Seven_Seg_Data[6]));
  636. SevenSegmentDisplayDecoder SevenSegmentDisplayDecoder_inst7(.ssOut(Seven_Seg_Val[7]), .nIn(Seven_Seg_Data[7]));
  637.  
  638. assign HEX0 = Seven_Seg_Val[0];
  639. assign HEX1 = Seven_Seg_Val[1];
  640. assign HEX2 = Seven_Seg_Val[2];
  641. assign HEX3 = Seven_Seg_Val[3];
  642. assign HEX4 = Seven_Seg_Val[4];
  643. assign HEX5 = Seven_Seg_Val[5];
  644. assign HEX6 = Seven_Seg_Val[6];
  645. assign HEX7 = Seven_Seg_Val[7];
  646.  
  647. wire Clock_2Hz;
  648.  
  649. Generate_Arbitrary_Divided_Clk32
  650. Gen_2Hz_clk
  651. (.inclk(CLK_50M),
  652. .outclk(Clock_2Hz),
  653. .outclk_Not(),
  654. .div_clk_count(32'h17D7840 >> 1),
  655. .Reset(1'h1)
  656. );
  657.  
  658. logic [31:0] actual_7seg_output;
  659. reg [31:0] regd_actual_7seg_output;
  660.  
  661. always @(posedge Clock_2Hz)
  662. begin
  663. regd_actual_7seg_output <= actual_7seg_output;
  664. Clock_1Hz <= ~Clock_1Hz;
  665. end
  666.  
  667.  
  668. assign Seven_Seg_Data[0] = regd_actual_7seg_output[3:0];
  669. assign Seven_Seg_Data[1] = regd_actual_7seg_output[7:4];
  670. assign Seven_Seg_Data[2] = regd_actual_7seg_output[11:8];
  671. assign Seven_Seg_Data[3] = regd_actual_7seg_output[15:12];
  672. assign Seven_Seg_Data[4] = regd_actual_7seg_output[19:16];
  673. assign Seven_Seg_Data[5] = regd_actual_7seg_output[23:20];
  674. assign Seven_Seg_Data[6] = regd_actual_7seg_output[27:24];
  675. assign Seven_Seg_Data[7] = regd_actual_7seg_output[31:28];
  676.  
  677. assign actual_7seg_output = scope_sampling_clock_count;
  678.  
  679.  
  680.  
  681.  
  682. //=======================================================================================================================
  683. //
  684. // Audio controller code - do not touch
  685. //
  686. //========================================================================================================================
  687. wire [$size(audio_data)-1:0] actual_audio_data_left, actual_audio_data_right;
  688. wire audio_left_clock, audio_right_clock;
  689.  
  690. to_slow_clk_interface
  691. interface_actual_audio_data_right
  692. (.indata(audio_data),
  693. .outdata(actual_audio_data_right),
  694. .inclk(CLK_50M),
  695. .outclk(audio_right_clock));
  696.  
  697.  
  698. to_slow_clk_interface
  699. interface_actual_audio_data_left
  700. (.indata(audio_data),
  701. .outdata(actual_audio_data_left),
  702. .inclk(CLK_50M),
  703. .outclk(audio_left_clock));
  704.  
  705.  
  706. audio_controller
  707. audio_control(
  708. // Clock Input (50 MHz)
  709. .iCLK_50(CLK_50M), // 50 MHz
  710. .iCLK_28(), // 27 MHz
  711. // 7-SEG Displays
  712. // I2C
  713. .I2C_SDAT(I2C_SDAT), // I2C Data
  714. .oI2C_SCLK(I2C_SCLK), // I2C Clock
  715. // Audio CODEC
  716. .AUD_ADCLRCK(AUD_ADCLRCK), // Audio CODEC ADC LR Clock
  717. .iAUD_ADCDAT(AUD_ADCDAT), // Audio CODEC ADC Data
  718. .AUD_DACLRCK(AUD_DACLRCK), // Audio CODEC DAC LR Clock
  719. .oAUD_DACDAT(AUD_DACDAT), // Audio CODEC DAC Data
  720. .AUD_BCLK(AUD_BCLK), // Audio CODEC Bit-Stream Clock
  721. .oAUD_XCK(AUD_XCK), // Audio CODEC Chip Clock
  722. //.audio_outL({actual_audio_data_left,8'b1}),
  723. //.audio_outR({actual_audio_data_right,8'b1}),
  724. .audio_outL({actual_audio_data_left}),
  725. .audio_outR({actual_audio_data_right}),
  726. .audio_right_clock(audio_right_clock),
  727. .audio_left_clock(audio_left_clock)
  728. );
  729.  
  730.  
  731. //=======================================================================================================================
  732. //
  733. // End Audio controller code
  734. //
  735. //========================================================================================================================
  736.  
  737.  
  738. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement