1 |
2 |
bsa |
/*******************************************************************************************/
|
2 |
|
|
/** **/
|
3 |
|
|
/** COPYRIGHT (C) 2011, SYSTEMYDE INTERNATIONAL CORPORATION, ALL RIGHTS RESERVED **/
|
4 |
|
|
/** **/
|
5 |
|
|
/** external interface module Rev 0.0 07/21/2011 **/
|
6 |
|
|
/** **/
|
7 |
|
|
/*******************************************************************************************/
|
8 |
|
|
module extint (data_in, dma_ack, ftch_tran, halt_tran, iack_tran, io_addr_out, io_data_out,
|
9 |
|
|
io_read, io_strobe, io_tran, ivec_rd, mem_addr_out, mem_data_out, mem_rd,
|
10 |
|
|
mem_tran, mem_wr, reti_tran, t1, addr_reg_in, clkc, dmar_reg,
|
11 |
|
|
dout_io_reg, dout_mem_reg, halt_nxt, if_frst, inta_frst, io_data_in,
|
12 |
|
|
ivec_data_in, ld_dmaa, ld_wait, mem_data_in, output_inh, rd_frst, rd_nxt,
|
13 |
|
|
resetb, reti_nxt, tran_sel, wr_frst);
|
14 |
|
|
|
15 |
|
|
input clkc; /* main cpu clock */
|
16 |
|
|
input dmar_reg; /* latched dma request */
|
17 |
|
|
input halt_nxt; /* halt cycle identifier */
|
18 |
|
|
input if_frst; /* first part of fetch cycle identifier */
|
19 |
|
|
input inta_frst; /* first part of intack cycle identifier */
|
20 |
|
|
input ld_dmaa; /* load dma request */
|
21 |
|
|
input ld_wait; /* load wait request */
|
22 |
|
|
input output_inh; /* disable cpu outputs */
|
23 |
|
|
input rd_frst; /* first part of read cycle identifier */
|
24 |
|
|
input rd_nxt; /* read cycle identifier */
|
25 |
|
|
input resetb; /* internal reset */
|
26 |
|
|
input reti_nxt; /* reti cycle identifier */
|
27 |
|
|
input wr_frst; /* first part of write cycle identifier */
|
28 |
|
|
input [7:0] dout_io_reg; /* io data output */
|
29 |
|
|
input [7:0] dout_mem_reg; /* mem data output */
|
30 |
|
|
input [7:0] io_data_in; /* i/o input data bus */
|
31 |
|
|
input [7:0] ivec_data_in; /* interrupt vector bus */
|
32 |
|
|
input [7:0] mem_data_in; /* memory input bus */
|
33 |
|
|
input [15:0] addr_reg_in; /* processor logical address bus */
|
34 |
|
|
input [`TTYPE_IDX:0] tran_sel; /* transaction type select */
|
35 |
|
|
output dma_ack; /* dma acknowledge */
|
36 |
|
|
output ftch_tran; /* instruction fetch transaction */
|
37 |
|
|
output halt_tran; /* halt transaction */
|
38 |
|
|
output iack_tran; /* interrupt acknowledge transaction */
|
39 |
|
|
output io_read; /* i/o read enable */
|
40 |
|
|
output io_strobe; /* i/o data strobe */
|
41 |
|
|
output io_tran; /* i/o transaction */
|
42 |
|
|
output ivec_rd; /* interrupt vector enable */
|
43 |
|
|
output mem_rd; /* memory read enable */
|
44 |
|
|
output mem_tran; /* memory transaction */
|
45 |
|
|
output mem_wr; /* memory write enable */
|
46 |
|
|
output reti_tran; /* return from interrupt transaction */
|
47 |
|
|
output t1; /* first clock of transaction */
|
48 |
|
|
output [7:0] data_in; /* data input bus */
|
49 |
|
|
output [7:0] io_data_out; /* i/o output data bus */
|
50 |
|
|
output [7:0] mem_data_out; /* memory output data bus */
|
51 |
|
|
output [15:0] io_addr_out; /* i/o address bus */
|
52 |
|
|
output [15:0] mem_addr_out; /* memory address bus */
|
53 |
|
|
|
54 |
|
|
/*****************************************************************************************/
|
55 |
|
|
/* */
|
56 |
|
|
/* signal declarations */
|
57 |
|
|
/* */
|
58 |
|
|
/*****************************************************************************************/
|
59 |
|
|
wire ld_io_addr; /* update io address */
|
60 |
|
|
wire ld_mem_addr; /* update memory address */
|
61 |
|
|
wire [7:0] io_data_out; /* i/o output data bus */
|
62 |
|
|
wire [7:0] mem_data_out; /* memory output data bus */
|
63 |
|
|
|
64 |
|
|
reg dma_ack; /* dma acknowledge */
|
65 |
|
|
reg ftch_tran; /* inst fetch transaction */
|
66 |
|
|
reg halt_tran; /* halt transaction */
|
67 |
|
|
reg iack_tran; /* int ack transaction */
|
68 |
|
|
reg io_read; /* i/o read enable */
|
69 |
|
|
reg io_tran; /* i/o transaction */
|
70 |
|
|
reg io_strobe; /* i/o data strobe */
|
71 |
|
|
reg ivec_rd; /* interrupt vector enable */
|
72 |
|
|
reg mem_rd; /* memory read enable */
|
73 |
|
|
reg mem_tran; /* memory transaction */
|
74 |
|
|
reg mem_wr; /* memory write enable */
|
75 |
|
|
reg out_inh_reg; /* latched output inhibit */
|
76 |
|
|
reg reti_tran; /* reti transaction */
|
77 |
|
|
reg t1; /* first clock of transaction */
|
78 |
|
|
reg [7:0] data_in; /* data input bus */
|
79 |
|
|
reg [15:0] io_addr_out; /* i/o address bus */
|
80 |
|
|
reg [15:0] mem_addr_out; /* memory address bus */
|
81 |
|
|
|
82 |
|
|
/*****************************************************************************************/
|
83 |
|
|
/* */
|
84 |
|
|
/* misc signals & buses */
|
85 |
|
|
/* */
|
86 |
|
|
/*****************************************************************************************/
|
87 |
|
|
assign io_data_out = (out_inh_reg) ? 8'h00 : dout_io_reg;
|
88 |
|
|
assign mem_data_out = (out_inh_reg) ? 8'h00 : dout_mem_reg;
|
89 |
|
|
assign ld_io_addr = tran_sel[`TT_IO] || output_inh;
|
90 |
|
|
assign ld_mem_addr = tran_sel[`TT_IAK] || tran_sel[`TT_IDL] || tran_sel[`TT_IF] ||
|
91 |
|
|
tran_sel[`TT_MEM] || tran_sel[`TT_STK];
|
92 |
|
|
|
93 |
|
|
always @ (iack_tran or io_tran or io_data_in or ivec_data_in or mem_data_in) begin
|
94 |
|
|
case ({iack_tran, io_tran})
|
95 |
|
|
2'b01: data_in = io_data_in;
|
96 |
|
|
2'b10: data_in = ivec_data_in;
|
97 |
|
|
default: data_in = mem_data_in;
|
98 |
|
|
endcase
|
99 |
|
|
end
|
100 |
|
|
|
101 |
|
|
/*****************************************************************************************/
|
102 |
|
|
/* */
|
103 |
|
|
/* timing generation */
|
104 |
|
|
/* */
|
105 |
|
|
/*****************************************************************************************/
|
106 |
|
|
always @ (posedge clkc or negedge resetb) begin
|
107 |
|
|
if (!resetb) begin
|
108 |
|
|
dma_ack <= 1'b0;
|
109 |
|
|
ftch_tran <= 1'b0;
|
110 |
|
|
halt_tran <= 1'b0;
|
111 |
|
|
iack_tran <= 1'b0;
|
112 |
|
|
io_addr_out <= 16'h0000;
|
113 |
|
|
io_read <= 1'b0;
|
114 |
|
|
io_tran <= 1'b0;
|
115 |
|
|
mem_addr_out <= 16'h0000;
|
116 |
|
|
mem_tran <= 1'b0;
|
117 |
|
|
out_inh_reg <= 1'b0;
|
118 |
|
|
reti_tran <= 1'b0;
|
119 |
|
|
end
|
120 |
|
|
else if (|tran_sel) begin
|
121 |
|
|
dma_ack <= ld_dmaa && dmar_reg;
|
122 |
|
|
ftch_tran <= tran_sel[`TT_IF];
|
123 |
|
|
halt_tran <= halt_nxt;
|
124 |
|
|
iack_tran <= tran_sel[`TT_IAK];
|
125 |
|
|
if (ld_io_addr) io_addr_out <= (output_inh) ? 16'h0000 : addr_reg_in;
|
126 |
|
|
io_read <= tran_sel[`TT_IO] && rd_nxt;
|
127 |
|
|
io_tran <= tran_sel[`TT_IO];
|
128 |
|
|
if (ld_mem_addr) mem_addr_out <= (output_inh) ? 16'h0000 : addr_reg_in;
|
129 |
|
|
mem_tran <= (tran_sel[`TT_IDL] || tran_sel[`TT_IF] || tran_sel[`TT_MEM] ||
|
130 |
|
|
tran_sel[`TT_STK]) && !output_inh;
|
131 |
|
|
out_inh_reg <= output_inh;
|
132 |
|
|
reti_tran <= reti_nxt;
|
133 |
|
|
end
|
134 |
|
|
end
|
135 |
|
|
|
136 |
|
|
always @ (posedge clkc or negedge resetb) begin
|
137 |
|
|
if (!resetb) begin
|
138 |
|
|
io_strobe <= 1'b0;
|
139 |
|
|
ivec_rd <= 1'b0;
|
140 |
|
|
mem_rd <= 1'b0;
|
141 |
|
|
mem_wr <= 1'b0;
|
142 |
|
|
t1 <= 1'b0;
|
143 |
|
|
end
|
144 |
|
|
else begin
|
145 |
|
|
io_strobe <= io_tran && (rd_frst || wr_frst);
|
146 |
|
|
ivec_rd <= iack_tran && inta_frst;
|
147 |
|
|
mem_rd <= (if_frst || (mem_tran && rd_frst)) && ld_wait;
|
148 |
|
|
mem_wr <= mem_tran && wr_frst;
|
149 |
|
|
t1 <= |tran_sel && !(halt_nxt || dmar_reg);
|
150 |
|
|
end
|
151 |
|
|
end
|
152 |
|
|
|
153 |
|
|
endmodule
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|