Line 1... |
Line 1... |
/* ============================================================================
|
// ============================================================================
|
2006,2007,2011 Robert T Finch
|
// __
|
robfinch@<remove>sympatico.ca
|
// \\__/ o\ (C) 2006-2020 Robert Finch, Waterloo
|
|
// \ __ / All rights reserved.
|
ParallelToSerial.v
|
// \/_// robfinch<remove>@finitron.ca
|
Parallel to serial data converter (shift register).
|
// ||
|
|
//
|
This source code is available for evaluation and validation purposes
|
//
|
only. This copyright statement and disclaimer must remain present in
|
// ParallelToSerial.v
|
the file.
|
// Parallel to serial data converter (shift register).
|
|
//
|
|
// BSD 3-Clause License
|
NO WARRANTY.
|
// Redistribution and use in source and binary forms, with or without
|
THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF ANY KIND, WHETHER
|
// modification, are permitted provided that the following conditions are met:
|
EXPRESS OR IMPLIED. The user must assume the entire risk of using the
|
//
|
Work.
|
// 1. Redistributions of source code must retain the above copyright notice, this
|
|
// list of conditions and the following disclaimer.
|
IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
|
//
|
INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES WHATSOEVER RELATING TO
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
THE USE OF THIS WORK, OR YOUR RELATIONSHIP WITH THE AUTHOR.
|
// this list of conditions and the following disclaimer in the documentation
|
|
// and/or other materials provided with the distribution.
|
IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU TO USE THE WORK
|
//
|
IN APPLICATIONS OR SYSTEMS WHERE THE WORK'S FAILURE TO PERFORM CAN
|
// 3. Neither the name of the copyright holder nor the names of its
|
REASONABLY BE EXPECTED TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN
|
// contributors may be used to endorse or promote products derived from
|
LOSS OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK, AND YOU
|
// this software without specific prior written permission.
|
AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS FROM ANY CLAIMS OR
|
//
|
LOSSES RELATING TO SUCH UNAUTHORIZED USE.
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
Webpack 9.1i xc3s1000-4ft256
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
LUTs / slices / MHz
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
block rams
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
============================================================================ */
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
module ParallelToSerial(rst, clk, ce, ld, qin, d, qh);
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
parameter WID=8;
|
//
|
|
// ============================================================================
|
|
//
|
|
module ParallelToSerial(rst, clk, ce, ld, a, qin, d, qh);
|
|
localparam WID=64;
|
input rst; // reset
|
input rst; // reset
|
input clk; // clock
|
input clk; // clock
|
input ce; // clock enable
|
input ce; // clock enable
|
input ld; // load
|
input ld; // load
|
|
input [2:0] a; // bits 3-5 of the font width
|
input qin; // serial shifting input
|
input qin; // serial shifting input
|
input [WID:1] d; // data to load
|
input [WID-1:0] d; // data to load
|
output qh; // serial output
|
output reg qh; // serial output
|
|
|
reg [WID:1] q;
|
reg [WID-1:0] q;
|
|
|
always @(posedge clk)
|
always @(posedge clk)
|
if (rst)
|
if (rst)
|
q <= 0;
|
q <= {WID{1'b0}};
|
else if (ce) begin
|
else if (ce) begin
|
if (ld)
|
if (ld)
|
q <= d;
|
q <= d;
|
else
|
else
|
q <= {q[WID-1:1],qin};
|
q <= {q[WID-2:0],qin};
|
end
|
end
|
|
|
assign qh = q[WID];
|
always @(posedge clk)
|
|
if (ce)
|
|
casez(a)
|
|
3'b1??: qh <= q[63];
|
|
// 3'b110: qh <= q[55];
|
|
// 3'b101: qh <= q[47];
|
|
// 3'b100: qh <= q[39];
|
|
3'b01?: qh <= q[31];
|
|
// 3'b010: qh <= q[23];
|
|
3'b001: qh <= q[15];
|
|
3'b000: qh <= q[ 7];
|
|
endcase
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|