ewaddr.v
4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
// $Id: ewaddr.v,v 1.4 2003/01/24 23:07:36 berndt Exp $
/////////////////////////////////////////////////////////////////////////
//
// Project Reality
//
// module: ewaddr
// description: computes the initial address for each span
//
//
// designer: Mike M. Cai 5/13/94
//
/////////////////////////////////////////////////////////////////////////
module ewaddr( // outputs
ew_ms_addr,
// inputs
width_cimage, width_timage,
load_cmd_image,
x_sc_major, x_minor, yh,
start_mult, addr_newspan,
reset_l, start_gclk, clk );
output [19:0] ew_ms_addr;
input [9:0] width_cimage, width_timage;
input load_cmd_image;
input [11:0] x_sc_major, x_minor;
input [11:0] yh;
input start_mult, addr_newspan;
input reset_l, start_gclk, clk;
reg [3:0] cnt_mult;
reg [1:0] cnt_addr;
reg posy_state;
reg yh_cur;
wire mult,
add_zero,
carry_in,
sel_mult,
ld_addr;
wire [1:0] sel_addr;
reg [19:0] addr_scanline,
a_adder,
b_adder_m,
b_adder,
sum,
ew_ms_addr;
reg [9:0] a_adder_m;
reg [11:0] b_adder_a;
wire [9:0] width;
assign width = load_cmd_image ? width_timage : width_cimage;
always @(posedge clk)
if ( reset_l == 1'b0) begin
cnt_mult <= 4'h0;
cnt_addr <= 2'h0;
posy_state <= 1'h0;
end
else if (start_gclk)
begin
cnt_mult <= (start_mult | ~((cnt_mult == 4'ha) | cnt_mult == 4'h0))
? (cnt_mult + 1) : 4'h0;
cnt_addr <= (addr_newspan | ~(cnt_addr == 2'h0))
? (cnt_addr + 1) : 2'h0;
case ({start_mult, addr_newspan, ~(yh[11] | yh[10]), posy_state})
4'h0, 4'h2, 4'h4, 4'h8, 4'h9, 4'hc, 4'hd: posy_state <= 1'h0;
4'h1, 4'h3, 4'h5, 4'h6, 4'h7, 4'ha, 4'hb,
4'he, 4'hf: posy_state <= 1'h1;
endcase
end
always @( cnt_mult or yh)
case (cnt_mult)
4'h1: yh_cur = yh[9];
4'h2: yh_cur = yh[8];
4'h3: yh_cur = yh[7];
4'h4: yh_cur = yh[6];
4'h5: yh_cur = yh[5];
4'h6: yh_cur = yh[4];
4'h7: yh_cur = yh[3];
4'h8: yh_cur = yh[2];
4'h9: yh_cur = yh[1];
4'ha: yh_cur = yh[0];
default: yh_cur = yh[0];
endcase
assign mult = ~(cnt_mult == 0);
assign add_zero = yh[11] | yh[10] | ~yh_cur;
assign sel_mult = ~((cnt_mult == 4'h0) | (cnt_mult == 4'h1));
assign ld_addr = ~(cnt_mult == 4'h0) | (cnt_addr == 2'h3);
assign sel_addr = {2{posy_state}} & (cnt_addr);
assign carry_in = (mult & ~add_zero) | (~mult & (cnt_addr == 2'h3) & posy_state);
always @(posedge clk)
if ( reset_l == 1'b0 ) begin
addr_scanline <= 20'h0;
ew_ms_addr <= 20'h0;
end
else if (start_gclk) begin
a_adder_m = add_zero ? 10'h0 : width;
a_adder = mult ? {10'h0, a_adder_m} : addr_scanline;
b_adder_m = sel_mult ? {addr_scanline[18:0], 1'h0} : 20'h0;
case (sel_addr)
2'h0: b_adder_a = 12'h0;
2'h1: b_adder_a = x_sc_major;
2'h2: b_adder_a = x_minor;
2'h3: b_adder_a = {2'h0,width};
endcase
b_adder = mult ? b_adder_m : {8'h0, b_adder_a};
sum = a_adder + b_adder + carry_in;
addr_scanline <= ld_addr ? sum : addr_scanline;
ew_ms_addr <= sum;
end
endmodule // ewaddr