// Example code for an AHBLite System-on-Chip // Iain McNally // ECS, University of Soutampton // // This module is a wrapper allowing the system to be used on the DE0 FPGA board // module de0_wrapper( input CLOCK_50, input [9:0] SW, input [2:0] KEY, // DE0 keys are active low output [9:0] LEDG, output [7:0] HEX0, output [7:0] HEX1, output [7:0] HEX2, output [7:0] HEX3 ); timeunit 1ns; timeprecision 100ps; localparam heartbeat_count_msb = 25; localparam seven_seg_L = ~7'b0111000; localparam seven_seg_E = ~7'b1111001; localparam seven_seg_o = ~7'b1011100; localparam seven_seg_off = ~7'b0000000; wire HCLK, HRESETn, LOCKUP, DataValid; wire [1:0] Buttons; wire [15:0] Switches; assign Switches = { 6'd0, SW }; // DE0 has just 10 switches assign Buttons = ~KEY[1:0]; soc soc_inst(.HCLK, .HRESETn, .DataOut(LEDG), .DataValid, .Switches, .Buttons, .LOCKUP); // Drive HRESETn directly from active low CPU KEY[2] button assign HRESETn = KEY[2]; // Drive HCLK from 50MHz de0 board clock assign HCLK = CLOCK_50; // This code gives us a heartbeat signal // logic running, heartbeat; logic [heartbeat_count_msb:0] tick_count; always_ff @(posedge CLOCK_50, negedge HRESETn ) if ( ! HRESETn ) begin running <= 0; heartbeat <= 0; tick_count <= 0; end else begin running <= 1; heartbeat = tick_count[heartbeat_count_msb] && tick_count[heartbeat_count_msb-2]; tick_count <= tick_count + 1; end // these digits on the seven-segment display are not used here assign HEX0 = '1; assign HEX1 = '1; assign HEX2 = '1; // HEX3 is status/heartbeat assign HEX3 = (LOCKUP) ? seven_seg_L : (!DataValid) ? seven_seg_E : (heartbeat) ? seven_seg_o : seven_seg_off; endmodule