|
| 1 | +// Copyright (c) 2001-2016 Intel Corporation |
| 2 | +// |
| 3 | +// Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | +// copy of this software and associated documentation files (the |
| 5 | +// "Software"), to deal in the Software without restriction, including |
| 6 | +// without limitation the rights to use, copy, modify, merge, publish, |
| 7 | +// distribute, sublicense, and/or sell copies of the Software, and to |
| 8 | +// permit persons to whom the Software is furnished to do so, subject to |
| 9 | +// the following conditions: |
| 10 | +// |
| 11 | +// The above copyright notice and this permission notice shall be included |
| 12 | +// in all copies or substantial portions of the Software. |
| 13 | +// |
| 14 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 | +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 17 | +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 18 | +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 19 | +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 20 | +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | + |
| 22 | +//////////////////////////////////////////////////////////////////////////// |
| 23 | +// top.v |
| 24 | +// a simple design to get LEDs blink using a 32-bit counter |
| 25 | +// |
| 26 | +// Some of the lines of code are commented out. They are not |
| 27 | +// needed since this is the flat implementation of the design |
| 28 | +// |
| 29 | +// As the accompanied application note document explains, the commented lines |
| 30 | +// would be needed as the design implementation migrates from flat to |
| 31 | +// Partial-Reconfiguration (PR) mode |
| 32 | +//////////////////////////////////////////////////////////////////////////// |
| 33 | +`timescale 1 ps / 1 ps |
| 34 | +`default_nettype none |
| 35 | + |
| 36 | +module top |
| 37 | + ( |
| 38 | + |
| 39 | + //////////////////////////////////////////////////////////////////////// |
| 40 | + // Control signals for the LEDs |
| 41 | + //////////////////////////////////////////////////////////////////////// |
| 42 | + led_zero_on, |
| 43 | + led_one_on, |
| 44 | + led_two_on, |
| 45 | + led_three_on, |
| 46 | + |
| 47 | + //////////////////////////////////////////////////////////////////////// |
| 48 | + // clock |
| 49 | + //////////////////////////////////////////////////////////////////////// |
| 50 | + clock |
| 51 | + ); |
| 52 | + |
| 53 | + //////////////////////////////////////////////////////////////////////// |
| 54 | + // assuming single bit control signal to turn LED 'on' |
| 55 | + //////////////////////////////////////////////////////////////////////// |
| 56 | + output reg led_zero_on; |
| 57 | + output reg led_one_on; |
| 58 | + output reg led_two_on; |
| 59 | + output reg led_three_on; |
| 60 | + |
| 61 | + //////////////////////////////////////////////////////////////////////// |
| 62 | + // clock |
| 63 | + //////////////////////////////////////////////////////////////////////// |
| 64 | + input wire clock; |
| 65 | + |
| 66 | + localparam COUNTER_TAP = 24; |
| 67 | + |
| 68 | + //////////////////////////////////////////////////////////////////////// |
| 69 | + // the 32-bit counter |
| 70 | + //////////////////////////////////////////////////////////////////////// |
| 71 | + reg [31:0] count; |
| 72 | + |
| 73 | + //////////////////////////////////////////////////////////////////////// |
| 74 | + // wire declarations |
| 75 | + //////////////////////////////////////////////////////////////////////// |
| 76 | + wire freeze; // freeze is not used until design is changed to PR |
| 77 | + wire [2:0] pr_ip_status; |
| 78 | + wire pr_led_two_on; |
| 79 | + wire pr_led_three_on; |
| 80 | + |
| 81 | + wire led_zero_on_w; |
| 82 | + wire led_one_on_w; |
| 83 | + wire led_two_on_w; |
| 84 | + wire led_three_on_w; |
| 85 | + |
| 86 | + //////////////////////////////////////////////////////////////////////// |
| 87 | + // The counter: |
| 88 | + //////////////////////////////////////////////////////////////////////// |
| 89 | + always_ff @(posedge clock) |
| 90 | + begin |
| 91 | + count <= count + 1; |
| 92 | + end |
| 93 | + |
| 94 | + //////////////////////////////////////////////////////////////////////// |
| 95 | + // Register the LED outputs |
| 96 | + //////////////////////////////////////////////////////////////////////// |
| 97 | + always_ff @(posedge clock) |
| 98 | + begin |
| 99 | + led_zero_on <= led_zero_on_w; |
| 100 | + led_one_on <= led_one_on_w; |
| 101 | + led_two_on <= led_two_on_w; |
| 102 | + led_three_on <= led_three_on_w; |
| 103 | + end |
| 104 | + |
| 105 | + //////////////////////////////////////////////////////////////////////// |
| 106 | + // driving LEDs to show PR as the rest of logic is running |
| 107 | + //////////////////////////////////////////////////////////////////////// |
| 108 | + assign led_zero_on_w = count[COUNTER_TAP]; |
| 109 | + assign led_one_on_w = count[COUNTER_TAP]; |
| 110 | + |
| 111 | + //////////////////////////////////////////////////////////////////////// |
| 112 | + // When moving from flat design to PR the following two |
| 113 | + // lines of assign statements need to be used. |
| 114 | + // User needs to uncomment them. |
| 115 | + // |
| 116 | + // The output ports driven by PR logic need to stablized |
| 117 | + // during PR reprograming. Using "freeze" control signal, |
| 118 | + // from PR IP, to drive these output to logic 1 during |
| 119 | + // reconfiguration. The logic 1 is chosen because LED is active low. |
| 120 | + //////////////////////////////////////////////////////////////////////// |
| 121 | + // The following line is used in PR implementation |
| 122 | + // assign led_two_on_w = freeze ? 1'b1 : pr_led_two_on; |
| 123 | + |
| 124 | + // The following line is used in PR implementation |
| 125 | + // assign led_three_on_w = freeze ? 1'b1 : pr_led_three_on; |
| 126 | + |
| 127 | + //////////////////////////////////////////////////////////////////////// |
| 128 | + // instance of the default persona |
| 129 | + //////////////////////////////////////////////////////////////////////// |
| 130 | + blinking_led u_blinking_led |
| 131 | + ( |
| 132 | + .led_two_on (led_two_on_w), // used in flat implementation |
| 133 | + // .led_two_on (pr_led_two_on), // used in PR implementation |
| 134 | + |
| 135 | + .led_three_on (led_three_on_w), // used in flat implementation |
| 136 | + // .led_three_on (pr_led_three_on), // used in PR implementation |
| 137 | + |
| 138 | + .clock (clock) |
| 139 | + ); |
| 140 | + |
| 141 | + // //////////////////////////////////////////////////////////////////////// |
| 142 | + // // when moving from flat design to PR then the following |
| 143 | + // // pr_ip needs to be instantiated in order to be able to |
| 144 | + // // partially reconfigure the design. |
| 145 | + // // |
| 146 | + // // This tutorial implements PR over JTAG |
| 147 | + // //////////////////////////////////////////////////////////////////////// |
| 148 | + // pr_ip u_pr_ip |
| 149 | + // ( |
| 150 | + // .clk (clock), |
| 151 | + // .nreset (1'b1), |
| 152 | + // .freeze (freeze), |
| 153 | + // .pr_start (1'b0), // ignored for JTAG |
| 154 | + // .status (pr_ip_status), |
| 155 | + // .data (16'b0), |
| 156 | + // .data_valid (1'b0), |
| 157 | + // .data_ready () |
| 158 | + // ); |
| 159 | + |
| 160 | +endmodule |
0 commit comments