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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [rtl/] [ao486/] [pipeline/] [write_string.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * Copyright (c) 2014, Aleksander Osman
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * * Redistributions of source code must retain the above copyright notice, this
9
 *   list of conditions and the following disclaimer.
10
 *
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 *   this list of conditions and the following disclaimer in the documentation
13
 *   and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
 
27
`include "defines.v"
28
 
29
module write_string(
30
 
31
    input               wr_is_8bit,
32
    input               wr_operand_16bit,
33
    input               wr_address_16bit,
34
    input               wr_address_32bit,
35
    input       [1:0]   wr_prefix_group_1_rep,
36
 
37
    input               wr_string_gp_fault_check,
38
 
39
    input               dflag,
40
 
41
    input               wr_zflag_result,
42
 
43
    input       [31:0]  ecx,
44
    input       [31:0]  esi,
45
    input       [31:0]  edi,
46
 
47
    input       [63:0]  es_cache,
48
    input               es_cache_valid,
49
    input       [31:0]  es_base,
50
    input       [31:0]  es_limit,
51
 
52
    //output
53
    output      [31:0]  wr_esi_final,
54
    output      [31:0]  wr_edi_final,
55
    output      [31:0]  wr_ecx_final,
56
 
57
    output              wr_string_ignore,
58
    output              wr_string_finish,
59
    output              wr_string_zf_finish,
60
 
61
    output      [31:0]  wr_string_es_linear,
62
 
63
    output              wr_string_es_fault
64
);
65
 
66
//------------------------------------------------------------------------------ string
67
wire [31:0] w_string_size;
68
wire [31:0] w_esi;
69
wire [31:0] w_edi;
70
wire [31:0] w_ecx;
71
 
72
 
73
assign w_string_size = (wr_is_8bit)? 32'd1 : (wr_operand_16bit)? 32'd2 : 32'd4;
74
 
75
assign w_esi = (dflag)? esi - w_string_size : esi + w_string_size;
76
assign w_edi = (dflag)? edi - w_string_size : edi + w_string_size;
77
assign w_ecx = ecx - 32'd1;
78
 
79
assign wr_esi_final = (wr_address_16bit)? { esi[31:16], w_esi[15:0] } : w_esi;
80
assign wr_edi_final = (wr_address_16bit)? { edi[31:16], w_edi[15:0] } : w_edi;
81
assign wr_ecx_final = (wr_address_16bit)? { ecx[31:16], w_ecx[15:0] } : w_ecx;
82
 
83
assign wr_string_ignore = wr_prefix_group_1_rep != 2'd0 &&
84
    ((wr_address_16bit && ecx[15:0] == 16'd0) || (wr_address_32bit && ecx == 32'd0));
85
 
86
assign wr_string_finish =
87
    (wr_prefix_group_1_rep != 2'd0 && ((wr_address_16bit && ecx[15:0] == 16'd1) || (wr_address_32bit && ecx == 32'd1)));
88
 
89
assign wr_string_zf_finish =
90
     wr_string_finish ||
91
    (wr_prefix_group_1_rep == 2'd1 && wr_zflag_result) ||
92
    (wr_prefix_group_1_rep == 2'd2 && ~(wr_zflag_result));
93
 
94
//------------------------------------------------------------------------------ string ES
95
wire [31:0] w_edi_offset;
96
wire [2:0]  wr_string_es_length;
97
wire [2:0]  wr_string_es_length_minus_1;
98
wire [31:0] w_string_es_upper_limit;
99
 
100
wire        w_string_es_not_fit;
101
wire        w_string_es_limit_overflow;
102
 
103
wire        w_string_es_no_write;
104
 
105
assign w_edi_offset = (wr_address_16bit)? { 16'd0, edi[15:0] } : edi;
106
 
107
assign wr_string_es_linear = es_base + w_edi_offset;
108
 
109
assign wr_string_es_length         = (wr_is_8bit)? 3'd1 : (wr_operand_16bit)? 3'd2 : 3'd4;
110
assign wr_string_es_length_minus_1 = wr_string_es_length - 3'd1;
111
 
112
assign w_string_es_upper_limit = (es_cache[`DESC_BIT_D_B])? 32'hFFFFFFFF : 32'h0000FFFF; //d-b
113
 
114
// (CODE or not EXPAND-DOWN)
115
assign w_string_es_not_fit = (es_cache[43] || !es_cache[42])?
116
    es_limit                - w_edi_offset < { 29'd0, wr_string_es_length_minus_1 } :
117
    w_string_es_upper_limit - w_edi_offset < { 29'd0, wr_string_es_length_minus_1 };
118
 
119
assign w_string_es_limit_overflow =
120
    ((es_cache[43] || !es_cache[42]) && w_edi_offset > es_limit) ||
121
    (!es_cache[43] && es_cache[42] && (w_edi_offset <= es_limit || w_edi_offset > w_string_es_upper_limit));
122
 
123
// (CODE or not writable)
124
assign w_string_es_no_write = es_cache[43] || !es_cache[41];
125
 
126
assign wr_string_es_fault = ~(wr_string_ignore) && wr_string_gp_fault_check &&
127
    (w_string_es_not_fit || w_string_es_limit_overflow || ~(es_cache_valid) || w_string_es_no_write);
128
 
129
//------------------------------------------------------------------------------
130
 
131
// synthesis translate_off
132
wire _unused_ok = &{ 1'b0, es_cache[63:55], es_cache[53:44], es_cache[40:0], 1'b0 };
133
// synthesis translate_on
134
 
135
//------------------------------------------------------------------------------
136
 
137
endmodule

powered by: WebSVN 2.1.0

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