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

Subversion Repositories warp

[/] [warp/] [rtl/] [tmu_addresses.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 lekernel
/*
2
 * Milkymist VJ SoC
3
 * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
4
 *
5
 * This program is free and excepted software; you can use it, redistribute it
6
 * and/or modify it under the terms of the Exception General Public License as
7
 * published by the Exception License Foundation; either version 2 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful, but WITHOUT
11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
 * FOR A PARTICULAR PURPOSE. See the Exception General Public License for more
13
 * details.
14
 *
15
 * You should have received a copy of the Exception General Public License along
16
 * with this project; if not, write to the Exception License Foundation.
17
 */
18
 
19
module tmu_addresses #(
20
        parameter fml_depth = 26
21
) (
22
        input sys_clk,
23
        input sys_rst,
24
 
25
        output busy,
26
 
27
        input [fml_depth-1-1:0] src_base, /* in 16-bit words */
28
        input [10:0] src_hres,
29
        input [fml_depth-1-1:0] dst_base, /* in 16-bit words */
30
        input [10:0] dst_hres,
31
 
32
        input pipe_stb_i,
33
        output pipe_ack_o,
34
        input [10:0] P_X,
35
        input [10:0] P_Y,
36
        input [10:0] P_U,
37
        input [10:0] P_V,
38
 
39
        output pipe_stb_o,
40
        input pipe_ack_i,
41
        output reg [fml_depth-1-1:0] src_addr, /* in 16-bit words */
42
        output reg [fml_depth-1-1:0] dst_addr  /* in 16-bit words */
43
);
44
 
45
wire en;
46
wire s0_valid;
47
reg s1_valid;
48
reg s2_valid;
49
 
50
always @(posedge sys_clk) begin
51
        if(sys_rst) begin
52
                s1_valid <= 1'b0;
53
                s2_valid <= 1'b0;
54
        end else if(en) begin
55
                s1_valid <= s0_valid;
56
                s2_valid <= s1_valid;
57
        end
58
end
59
 
60
/* Pipeline MAC operation on two stages.
61
 * The synthesis tool automatically retimes and pushes
62
 * the registers into the hardwired fast DSP macros.
63
 */
64
 
65
reg [fml_depth-1-1:0] s1_src_addr;
66
reg [fml_depth-1-1:0] s1_dst_addr;
67
 
68
/* WA for strange behaviour/bug in Verilator 3.700 :
69
 * if we directly put the multiplications in the
70
 * reg assignments, it thinks the results are 11 bits...
71
 */
72
wire [21:0] s0_expanded_pv = src_hres*P_V;
73
wire [21:0] s0_expanded_py = dst_hres*P_Y;
74
 
75
always @(posedge sys_clk) begin
76
        if(en) begin
77
                s1_src_addr <= src_base + {{fml_depth-22-1{1'b0}}, s0_expanded_pv} + {{fml_depth-11-1{1'b0}}, P_U};
78
                s1_dst_addr <= dst_base + {{fml_depth-22-1{1'b0}}, s0_expanded_py} + {{fml_depth-11-1{1'b0}}, P_X};
79
                src_addr <= s1_src_addr;
80
                dst_addr <= s1_dst_addr;
81
        end
82
end
83
 
84
/* Pipeline management */
85
 
86
assign busy = s1_valid|s2_valid;
87
 
88
assign s0_valid = pipe_stb_i;
89
assign pipe_ack_o = pipe_ack_i;
90
 
91
assign en = pipe_ack_i;
92
assign pipe_stb_o = s2_valid;
93
 
94
endmodule

powered by: WebSVN 2.1.0

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