| 1 |
25 |
robfinch |
// ============================================================================
|
| 2 |
|
|
// __
|
| 3 |
|
|
// \\__/ o\ (C) 2023 Robert Finch, Waterloo
|
| 4 |
|
|
// \ __ / All rights reserved.
|
| 5 |
|
|
// \/_// robfinch@finitron.ca
|
| 6 |
|
|
// ||
|
| 7 |
|
|
//
|
| 8 |
|
|
// VideoTPG.sv
|
| 9 |
|
|
// - video test pattern generator
|
| 10 |
|
|
// - Responds to video memory requests by supplying a fixed pattern.
|
| 11 |
|
|
// - Responds in a variable number of cycles to simulate memory latency. So, there
|
| 12 |
|
|
// is jitter in the data supplied back to the frame buffer which should be able
|
| 13 |
|
|
// to display without the jitter.
|
| 14 |
|
|
//
|
| 15 |
|
|
// BSD 3-Clause License
|
| 16 |
|
|
// Redistribution and use in source and binary forms, with or without
|
| 17 |
|
|
// modification, are permitted provided that the following conditions are met:
|
| 18 |
|
|
//
|
| 19 |
|
|
// 1. Redistributions of source code must retain the above copyright notice, this
|
| 20 |
|
|
// list of conditions and the following disclaimer.
|
| 21 |
|
|
//
|
| 22 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
| 23 |
|
|
// this list of conditions and the following disclaimer in the documentation
|
| 24 |
|
|
// and/or other materials provided with the distribution.
|
| 25 |
|
|
//
|
| 26 |
|
|
// 3. Neither the name of the copyright holder nor the names of its
|
| 27 |
|
|
// contributors may be used to endorse or promote products derived from
|
| 28 |
|
|
// this software without specific prior written permission.
|
| 29 |
|
|
//
|
| 30 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 31 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 32 |
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 33 |
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 34 |
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 35 |
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 36 |
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 37 |
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 38 |
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 39 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 40 |
|
|
//
|
| 41 |
|
|
// ============================================================================
|
| 42 |
|
|
|
| 43 |
|
|
module VideoTPG(rst, clk, en, vSync, req, resp, ex_resp);
|
| 44 |
|
|
input rst;
|
| 45 |
|
|
input clk;
|
| 46 |
|
|
input en;
|
| 47 |
|
|
input vSync;
|
| 48 |
|
|
input fta_cmd_request128_t req;
|
| 49 |
|
|
output fta_cmd_response128_t resp;
|
| 50 |
|
|
input fta_cmd_response128_t ex_resp; // external response input
|
| 51 |
|
|
|
| 52 |
|
|
wire pe_vsync;
|
| 53 |
|
|
wire [30:0] lfsr31o;
|
| 54 |
|
|
|
| 55 |
|
|
edge_det uedvs1
|
| 56 |
|
|
(
|
| 57 |
|
|
.rst(rst),
|
| 58 |
|
|
.clk(clk),
|
| 59 |
|
|
.ce(1'b1),
|
| 60 |
|
|
.i(vSync),
|
| 61 |
|
|
.pe(pe_vsync),
|
| 62 |
|
|
.ne(),
|
| 63 |
|
|
.ee()
|
| 64 |
|
|
);
|
| 65 |
|
|
|
| 66 |
|
|
lfsr31 ulfsr1
|
| 67 |
|
|
(
|
| 68 |
|
|
.rst(pe_vsync),
|
| 69 |
|
|
.clk(clk),
|
| 70 |
|
|
.ce(req.cyc),
|
| 71 |
|
|
.cyc(1'b0),
|
| 72 |
|
|
.o(lfsr31o)
|
| 73 |
|
|
);
|
| 74 |
|
|
|
| 75 |
|
|
reg [11:0] p, m;
|
| 76 |
|
|
reg [19:0] q,d400;
|
| 77 |
|
|
reg [31:0] m400;
|
| 78 |
|
|
reg [15:0] c;
|
| 79 |
|
|
always_comb
|
| 80 |
|
|
d400 = ({16'h0,req.padr} * 16'd2621) >> 20;
|
| 81 |
|
|
always_comb
|
| 82 |
|
|
m400 = req.padr - ({10'd0,d400} * 10'd400);
|
| 83 |
|
|
always_comb
|
| 84 |
|
|
p = m400 >> 5;
|
| 85 |
|
|
always_comb
|
| 86 |
|
|
q = ({16'd0,req.padr} * 16'd78) >> 20; // /(32*400)
|
| 87 |
|
|
always_comb
|
| 88 |
|
|
c = {1'b0,5'h1F,q[4:0],p[4:0]};
|
| 89 |
|
|
|
| 90 |
|
|
vtdl #(.WID(1), .DEP(16)) urdyd2 (.clk(clk), .ce(1'b1), .a(lfsr31o[3:0]), .d(req.cyc), .q(resp.ack));
|
| 91 |
|
|
vtdl #(.WID(6), .DEP(16)) urdyd3 (.clk(clk), .ce(1'b1), .a(lfsr31o[3:0]), .d(req.cid), .q(resp.cid));
|
| 92 |
|
|
vtdl #(.WID($bits(fta_tranid_t)), .DEP(16)) urdyd4 (.clk(clk), .ce(1'b1), .a(lfsr31o[3:0]), .d(req.tid), .q(resp.tid));
|
| 93 |
|
|
vtdl #(.WID($bits(fta_address_t)), .DEP(16)) urdyd5 (.clk(clk), .ce(1'b1), .a(lfsr31o[3:0]), .d(req.padr), .q(resp.adr));
|
| 94 |
|
|
vtdl #(.WID(128), .DEP(16)) urdyd6 (.clk(clk), .ce(1'b1), .a(lfsr31o[3:0]), .d(en ? {8{c}} : ex_resp.dat), .q(resp.dat));
|
| 95 |
|
|
|
| 96 |
|
|
always_ff @(posedge clk)
|
| 97 |
|
|
begin
|
| 98 |
|
|
/*
|
| 99 |
|
|
resp.tid <= req.tid;
|
| 100 |
|
|
resp.cid <= req.cid;
|
| 101 |
|
|
resp.ack <= req.cyc;
|
| 102 |
|
|
*/
|
| 103 |
|
|
resp.stall <= 1'b0;
|
| 104 |
|
|
resp.next <= 1'b0;
|
| 105 |
|
|
resp.err <= 1'b0;
|
| 106 |
|
|
resp.rty <= 1'b0;
|
| 107 |
|
|
resp.pri <= 4'd7;
|
| 108 |
|
|
/*
|
| 109 |
|
|
resp.adr <= req.padr;
|
| 110 |
|
|
resp.dat <= {8{c}};
|
| 111 |
|
|
*/
|
| 112 |
|
|
/*
|
| 113 |
|
|
casez({~en,req.padr[11:8]})
|
| 114 |
|
|
5'h00: resp.dat <= {4{lfsr31o}};
|
| 115 |
|
|
5'h02: resp.dat <= ex_resp.dat;
|
| 116 |
|
|
5'h1?: resp.dat <= ex_resp.dat;
|
| 117 |
|
|
default: resp.dat <= {16{req.padr[15:8]}};
|
| 118 |
|
|
endcase
|
| 119 |
|
|
*/
|
| 120 |
|
|
end
|
| 121 |
|
|
|
| 122 |
|
|
endmodule
|