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

Subversion Repositories yacc

[/] [yacc/] [trunk/] [syn/] [xilinx/] [yacc2.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tak.sugawa
//Jun.30.2004 blez bgtz bug fix
2
//Jul.7.2004 int bug fix
3
//Jul.11.2004 bgezQ,bltzQ
4
//Apr.2.2005 Change Port Address, change uart interface port
5
//Apr.3.2005 bgtz bug fix
6
`include "define.h"
7
`ifdef RTL_SIMULATION
8
module yacc(clock,Async_Reset,MemoryWData,MWriteFF,data_port_address,
9
           RXD,TXD);
10
        input clock;
11
        input Async_Reset;
12
        output [31:0] MemoryWData;
13
        output [15:0] data_port_address;
14
 
15
 
16
 
17
 
18
        output MWriteFF;
19
        input RXD;
20
        output TXD;
21
`else
22
 
23
module yacc(clock,Async_Reset,     RXD,TXD);
24
        input clock;
25
        input Async_Reset;
26
        input RXD;
27
        output TXD;
28
 
29
`endif
30
 
31
        wire [31:0] MOUT,IRD1;
32
 
33
        wire RegWriteD2;
34
        wire [1:0] A_Right_SELD1;
35
        wire [1:0] RF_inputD2;
36
        wire M_signD1,M_signD2;
37
        wire [1:0] M_access_modeD1,M_access_modeD2;
38
        wire [3:0] ALU_FuncD2;
39
        wire [1:0] Shift_FuncD2;
40
        wire [25:0] IMMD2,IMMD1;
41
        wire [4:0] source_addrD2,target_addrD2;
42
        wire [4:0] source_addrD1,target_addrD1,Shift_amountD2;
43
        wire [4:0] RF_input_addr;
44
        wire [2:0] PC_commandD1;
45
        wire [7:0] uread_port;
46
        wire takenD2;//
47
 
48
`ifdef RAM4K
49
        wire [11:0] DAddress;//
50
        wire [11:0] PC;
51
        reg [11:0] int_address;//interim
52
        reg [11:0] PCD1,PCD2;
53
        reg [15:0] IRD2;
54
        reg [11:0] DAddrD;
55
        wire [11:0] PCCDD;
56
`else
57
        wire [25:0] PC;
58
        wire [25:0] DAddress;//
59
        reg [25:0] int_address;//interim
60
        reg [25:0] PCD1,PCD2;
61
        reg [25:0] IRD2;
62
        reg [25:0] DAddrD;
63
        wire [25:0] PCCDD;
64
`endif
65
 
66
        wire [31:0] memory_indata;//
67
        wire memory_sign;
68
        wire [1:0] memory_access_mode;
69
 
70
        wire [31:0] ea_reg_out;
71
        wire [31:0] regfile_indata,regfile_indata_temp;//
72
        wire reg_compare;
73
        wire beqQ,bneQ,blezQ,bgtzQ;
74
        wire [25:0] IMM;
75
        wire clear_int;
76
        wire jumpQ,branchQQ;
77
        wire [31:0] memory_wdata;
78
        wire [31:0] alu_source,alu_target;
79
        wire [1:0] RRegSelD1;
80
        wire A_Left_SELD1;
81
        wire [1:0] mul_alu_selD2;
82
        wire [3:0] mul_div_funcD2;
83
//registers
84
        reg sync_reset;
85
        wire [31:0] forward_source_reg,forward_target_reg;
86
//      reg [31:0] MOUT_ff;
87
        reg takenD3;
88
        reg int_req;
89
 
90
 
91
        reg beqQQ,bneQQ,blezQQ,bgtzQQ;
92
        reg bgezQQ,bltzQQ;
93
        reg MWriteFF;
94
        wire MWriteD2,MWriteD1;
95
        reg [31:0] MemoryWData;
96
        wire NOP_Signal;
97
 
98
        wire [7:0] control_state;
99
        wire [15:0] data_port_address=DAddrD;
100
        wire [3:0] mult_func;
101
        wire pause_out;
102
        wire Shift_Amount_selD2;
103
        wire source_zero;//Jun.30.2004
104
        wire int_req_uport;
105
        wire uart_write_req;
106
        wire uart_write_done,uart_write_busy;
107
        wire int_stateD1;
108
        wire bgezQ,bltzQ;
109
 
110
decoder d1(.clock(clock),.sync_reset(sync_reset),.MWriteD1(MWriteD1),
111
            .RegWriteD2(RegWriteD2),.A_Right_SELD1(A_Right_SELD1),.RF_inputD2(RF_inputD2),
112
            .RF_input_addr(RF_input_addr),.M_signD1( M_signD1),.M_signD2(M_signD2),
113
            .M_access_modeD1(M_access_modeD1),.M_access_modeD2(M_access_modeD2),
114
            .ALU_FuncD2(ALU_FuncD2),.Shift_FuncD2(Shift_FuncD2),
115
            .source_addrD1(source_addrD1),.target_addrD1(target_addrD1),.IMMD2(IMMD2),
116
            .source_addrD2(source_addrD2),.target_addrD2(target_addrD2),
117
            .Shift_amountD2(Shift_amountD2),.PC_commandD1(PC_commandD1),.IMMD1(IMMD1),.IRD1(IRD1),.takenD3(takenD3),.takenD2(takenD2),.beqQ(beqQ),.bneQ(bneQ),.blezQ(blezQ),.bgtzQ(bgtzQ),
118
            .DAddress(DAddress),.PC(PC),.memory_indata(memory_indata),.MOUT(MOUT),.IMM(IMM),
119
            .branchQQ(branchQQ),.jumpQ(jumpQ),.int_req(int_req),.clear_int(clear_int),
120
            .int_address(int_address),.A_Left_SELD1(A_Left_SELD1),.RRegSelD1(RRegSelD1),
121
            .MWriteD2(MWriteD2),.NOP_Signal(NOP_Signal),.mul_alu_selD2(mul_alu_selD2),
122
            .mul_div_funcD2(mul_div_funcD2),.pause_out(pause_out),.control_state(control_state),
123
            .Shift_Amount_selD2(Shift_Amount_selD2),
124
            .uread_port(uread_port),.int_stateD1(int_stateD1),.bgezQ(bgezQ),.bltzQ(bltzQ),.write_busy(uart_write_busy));
125
 
126
 
127
 
128
pc_module pc1(.clock(clock),.sync_reset(sync_reset),.pc_commandD1(PC_commandD1),.PCC(PC),
129
               .imm(IMM),.ea_reg_source(alu_source),.takenD2(takenD2),.takenD3(takenD3),
130
               .branchQQ(branchQQ),.jumpQ(jumpQ),.NOP_Signal(NOP_Signal),
131
                 .control_state(control_state),.IMMD1(IMMD1),.PCCDD(PCCDD));
132
 
133
 
134
 
135
Pipelined_RegFile pipe(.clock(clock),.sync_reset(sync_reset),
136
        .dest_addrD2(RF_input_addr),.source_addr(IMM[25:21]),.target_addr(IMM[20:16]),
137
        .wren(RegWriteD2),.memory_wdata(memory_wdata),
138
      .A_Right_SELD1(A_Right_SELD1),.A_Left_SELD1(A_Left_SELD1),.PCD1(PCD1),
139
        .IMMD1(IMMD1[15:0]),.ALU_FuncD2(ALU_FuncD2),.Shift_FuncD2(Shift_FuncD2),
140
        .Shift_amountD2(Shift_amountD2),.RRegSelD1(RRegSelD1),.MOUT(MOUT),
141
        .RF_inputD2(RF_inputD2),.alu_source(alu_source),.alu_target(alu_target),
142
        .MWriteD2(MWriteD2),.MWriteD1(MWriteD1),.mul_alu_selD2(mul_alu_selD2),
143
        .mul_div_funcD2(mul_div_funcD2),.pause_out(pause_out),
144
        .Shift_Amount_selD2(Shift_Amount_selD2),.int_stateD1(int_stateD1),.PCCDD(PCCDD));
145
 
146
//sync_reset
147
        always @(posedge clock , negedge Async_Reset) begin
148
                if (!Async_Reset) sync_reset <=1'b1;
149
                else  sync_reset <=!Async_Reset;
150
        end
151
 
152
 
153
//PCD1,PCD2
154
        always @(posedge clock) begin
155
        //      if (sync_reset) PCD1<=26'h000_0000;
156
        /*      else*/  PCD1 <=PC+4;
157
        end
158
 
159
        always @(posedge clock) begin
160
                PCD2 <=PCD1;
161
        end
162
 
163
//
164
        always @(posedge clock) begin
165
        IRD2 <=IRD1;
166
        end
167
 
168
        always @(posedge clock) begin
169
                if (sync_reset) MWriteFF<=1'b0;
170
                else    MWriteFF <=MWriteD2;
171
        end
172
 
173
        assign memory_access_mode=M_access_modeD1;
174
        assign memory_sign=M_signD1;
175
 
176
        assign DAddress=alu_source[25:0]+{ {6{IRD2[15]}},IRD2[15:0]};
177
 
178
//
179
        always @(posedge clock) begin
180
        DAddrD <=DAddress;
181
        end
182
//
183
always @(posedge clock) begin
184
        MemoryWData <=memory_wdata;
185
        end
186
 
187
        assign memory_indata=memory_wdata;
188
 
189
 
190
 
191
 
192
        assign reg_compare=( alu_source==alu_target);
193
 
194
 
195
 
196
        always @(posedge clock) begin
197
           if (!NOP_Signal) begin//Jun.29.2004
198
                              beqQQ<=beqQ;
199
                        bneQQ<=bneQ;
200
                        bgtzQQ<=bgtzQ;
201
                        blezQQ<=blezQ;
202
                              bgezQQ<=bgezQ;//Jul.11.2004
203
                        bltzQQ<=bltzQ;//Jul.11.2004
204
                end
205
        end
206
 
207
        always @( beqQQ ,bneQQ,bgtzQQ,blezQQ,bgezQQ,bltzQQ,reg_compare,alu_source) begin//Jul.11.2004
208
                takenD3=        ( beqQQ   && reg_compare) ||
209
                                ( bneQQ   && !reg_compare) ||
210
                                ( bgtzQQ  && !alu_source[31] && !reg_compare) || //Apr.3.2005 bug fix $s >0 Jun.30.2004
211
                                ( blezQQ  && (alu_source[31]  || reg_compare )) ||
212
                                      ( bgezQQ  && (!alu_source[31] || reg_compare )) || //Jul.11.2004 
213
                                      ( bltzQQ  && (alu_source[31]  )); //Jul.11.2004//$s <0=Jun.30.2004
214
        end
215
 
216
 
217
 
218
 
219
 
220
        uart_read  uread( .sync_reset(sync_reset),.clk(clock), .rxd(RXD),
221
        .buffer_reg(uread_port),.int_req(int_req_uport));
222
 
223
        uart_write uwite( .sync_reset(sync_reset), .clk(clock), .txd(TXD),.data_in(MemoryWData[7:0]) ,
224
        .write_request(uart_write_req),.write_done(uart_write_done),.write_busy(uart_write_busy));
225
 
226
`ifdef RAM4K
227
        assign uart_write_req= DAddrD[11:0]==12'hfff && MWriteFF;//`UART_WRITE_PORT_ADDRESS ;
228
        always @ (posedge clock) begin
229
                if (sync_reset) int_address<=0;
230
                else if (DAddrD[11:0]==12'h0ff8 & MWriteFF) int_address<=MemoryWData;
231
        end
232
`endif
233
 
234
`ifdef RAM16K
235
        assign uart_write_req= DAddrD==`UART_PORT_ADDRESS && MWriteFF  ;//`UART_WRITE_PORT_ADDRESS ;
236
      always @ (posedge clock) begin
237
                if (sync_reset) int_address<=0;
238
                else if (DAddrD==`INTERUPPT_ADDRESS & MWriteFF) int_address<=MemoryWData;
239
        end
240
`endif
241
 
242
`ifdef RAM32K
243
        assign uart_write_req= DAddrD[15:0]==16'h07fff && MWriteFF ;//`UART_WRITE_PORT_ADDRESS ;
244
     always @ (posedge clock) begin
245
                if (sync_reset) int_address<=0;
246
                else if (DAddrD==16'h7ff8 & MWriteFF) int_address<=MemoryWData;
247
        end
248
`endif
249
 
250
//state machine
251
//latch with one shot pulse 
252
//clear by clear_int
253
        always @(posedge clock) begin
254
                if (sync_reset) int_req <=1'b0;
255
                else if (clear_int) int_req <=1'b0;// assume one shot(1clk) pulse
256
                else if ( int_req_uport) int_req<=1'b1;//                       
257
        end
258
 
259
endmodule
260
 
261
 

powered by: WebSVN 2.1.0

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