OpenCores
URL https://opencores.org/ocsvn/pdp1/pdp1/trunk

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [rtl/] [verilog/] [vector2scanline.v] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 yannv
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: Yann Vernier
5
// 
6
// Create Date:    21:37:32 02/19/2011 
7
// Design Name: 
8
// Module Name:    vector2scanline 
9
// Project Name: PDP-1
10
// Target Devices: Spartan 3A
11
// Tool versions: 
12
// Description: Converts vector data (exposed points) into raster video
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
module vector2scanline(
23
    input clk,
24
 
25
    input strobe,
26
    input [9:0] x,
27
    input [9:0] y,
28
 
29
    input [9:0] xout,
30
    input [9:0] yout,
31
         input newline,
32
         input newframe,
33
    output [7:0] pixel
34
    );
35
 
36
parameter X_WIDTH = 10;
37
parameter Y_WIDTH = 10;
38
parameter HIST_WIDTH = 10;
39
parameter AGE_WIDTH = 8;
40
 
41
reg [X_WIDTH+Y_WIDTH+AGE_WIDTH-1:0] exposures [(2**HIST_WIDTH)-1:0];
42
reg [X_WIDTH+Y_WIDTH+AGE_WIDTH-1:0] expr;
43
wire [X_WIDTH-1:0] expx;
44
wire [Y_WIDTH-1:0] expy;
45
wire [7:0] expi;
46
wire exposed;
47
reg [HIST_WIDTH-1:0] exprptr=0, expwptr=0;
48
 
49
// double-buffered; one gets wiped as it is displayed
50
// the other gets filled in with current exposures
51
reg [AGE_WIDTH-1:0] scanline0 [(2**X_WIDTH)-1:0];
52
reg [AGE_WIDTH-1:0] scanline1 [(2**X_WIDTH)-1:0];
53
reg [AGE_WIDTH-1:0] pixelout;
54
reg bufsel = 0;
55
wire [X_WIDTH-1:0] sl0w, sl1w;
56
 
57
always @(posedge clk) begin
58
        expr<=exposures[exprptr];
59
        if (!strobe) begin
60
                exprptr<=exprptr+1;
61
        end
62
end
63
assign expx = strobe?x:expr[X_WIDTH+Y_WIDTH+AGE_WIDTH-1:Y_WIDTH+AGE_WIDTH];
64
assign expy = strobe?y:expr[Y_WIDTH+AGE_WIDTH-1:AGE_WIDTH];
65
assign expi = strobe?(2**AGE_WIDTH)-1:expr[AGE_WIDTH-1:0];
66
assign exposed = expi!=0;
67
 
68
always @(posedge clk) begin
69
        // Feed incoming exposures into exposure buffer
70
        if (exposed) begin
71
                exposures[expwptr] <= {expx, expy, expy==yout?expi-1:expi};
72
                expwptr <= expwptr+1;
73
        end
74
end
75
 
76
assign sl0w=bufsel?expx:xout;
77
assign sl1w=bufsel?xout:expx;
78
always @(posedge clk) begin
79
        // Read out & wipe front buffer
80
        // Store exposures for current scanline as well
81
        if (expy==(y+1)) begin
82
                scanline0[sl0w] <= bufsel?expi:0;
83
                scanline1[sl1w] <= bufsel?0:expi;
84
                pixelout <= bufsel?scanline1[xout]:scanline0[xout];
85
        end
86
        if (newframe) begin
87
                bufsel <= ~bufsel;
88
        end
89
end
90
 
91
assign pixel = pixelout;
92
 
93
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.