| 1 |
56 |
robfinch |
// ============================================================================
|
| 2 |
|
|
// __
|
| 3 |
|
|
// \\__/ o\ (C) 2020 Robert Finch, Waterloo
|
| 4 |
|
|
// \ __ / All rights reserved.
|
| 5 |
|
|
// \/_// robfinch@finitron.ca
|
| 6 |
|
|
// ||
|
| 7 |
|
|
//
|
| 8 |
|
|
// DPD1000Decode.sv
|
| 9 |
|
|
//
|
| 10 |
|
|
// BSD 3-Clause License
|
| 11 |
|
|
// Redistribution and use in source and binary forms, with or without
|
| 12 |
|
|
// modification, are permitted provided that the following conditions are met:
|
| 13 |
|
|
//
|
| 14 |
|
|
// 1. Redistributions of source code must retain the above copyright notice, this
|
| 15 |
|
|
// list of conditions and the following disclaimer.
|
| 16 |
|
|
//
|
| 17 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
| 18 |
|
|
// this list of conditions and the following disclaimer in the documentation
|
| 19 |
|
|
// and/or other materials provided with the distribution.
|
| 20 |
|
|
//
|
| 21 |
|
|
// 3. Neither the name of the copyright holder nor the names of its
|
| 22 |
|
|
// contributors may be used to endorse or promote products derived from
|
| 23 |
|
|
// this software without specific prior written permission.
|
| 24 |
|
|
//
|
| 25 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 26 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 27 |
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 28 |
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 29 |
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 30 |
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 31 |
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 32 |
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 33 |
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 34 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 35 |
|
|
//
|
| 36 |
|
|
// ============================================================================
|
| 37 |
55 |
robfinch |
|
| 38 |
|
|
module DPD1000Decode(clk, i, o);
|
| 39 |
|
|
input clk;
|
| 40 |
|
|
input [9:0] i;
|
| 41 |
|
|
output [11:0] o;
|
| 42 |
|
|
|
| 43 |
|
|
reg [9:0] i1;
|
| 44 |
|
|
genvar g;
|
| 45 |
|
|
|
| 46 |
|
|
(* ram_style="block" *)
|
| 47 |
|
|
reg [11:0] tbl [0:1023];
|
| 48 |
|
|
|
| 49 |
|
|
generate begin : gDPDTbl
|
| 50 |
|
|
for (g = 0; g < 1024; g = g + 1) begin
|
| 51 |
|
|
initial begin
|
| 52 |
|
|
tbl[g] = (g % 10) | (((g / 10) & 15) << 4) | (((g/100) & 15) << 8);
|
| 53 |
|
|
end
|
| 54 |
|
|
end
|
| 55 |
|
|
end
|
| 56 |
|
|
endgenerate
|
| 57 |
|
|
|
| 58 |
|
|
always @(posedge clk)
|
| 59 |
|
|
i1 <= i;
|
| 60 |
|
|
|
| 61 |
|
|
assign o = tbl[i1];
|
| 62 |
|
|
|
| 63 |
|
|
endmodule
|
| 64 |
|
|
|
| 65 |
|
|
module DPDDecodeN(clk, i, o);
|
| 66 |
|
|
parameter N=11;
|
| 67 |
|
|
input clk;
|
| 68 |
|
|
input [N*10-1:0] i;
|
| 69 |
|
|
output [N*12-1:0] o;
|
| 70 |
|
|
|
| 71 |
|
|
genvar g;
|
| 72 |
|
|
|
| 73 |
|
|
generate begin : gDPD
|
| 74 |
|
|
for (g = 0; g < N; g = g + 1)
|
| 75 |
|
|
DPD1000Decode(clk, i[g*10+9:g*10], o[g*12+11:g*12]);
|
| 76 |
|
|
end
|
| 77 |
|
|
endgenerate
|
| 78 |
|
|
|
| 79 |
|
|
endmodule
|