1 |
2 |
bsa |
/*******************************************************************************************/
|
2 |
|
|
/** **/
|
3 |
6 |
bsa |
/** ORIGINAL COPYRIGHT (C) 2011, SYSTEMYDE INTERNATIONAL CORPORATION, ALL RIGHTS RESERVED **/
|
4 |
|
|
/** COPYRIGHT (C) 2012, SERGEY BELYASHOV **/
|
5 |
2 |
bsa |
/** **/
|
6 |
6 |
bsa |
/** processor top level Rev 0.0 06/13/2012 **/
|
7 |
2 |
bsa |
/** **/
|
8 |
|
|
/*******************************************************************************************/
|
9 |
|
|
module y80_top (dma_ack, halt_tran, iack_tran, io_addr_out, io_data_out, io_read, io_strobe,
|
10 |
|
|
io_tran, ivec_rd, mem_addr_out, mem_data_out, mem_rd, mem_tran, mem_wr,
|
11 |
|
|
reti_tran, t1, clearb, clkc, dma_req, int_req, io_data_in, ivec_data_in,
|
12 |
|
|
mem_data_in, nmi_req, resetb, wait_req);
|
13 |
|
|
|
14 |
|
|
input clearb; /* master (test) reset */
|
15 |
|
|
input clkc; /* main cpu clock */
|
16 |
|
|
input dma_req; /* dma request */
|
17 |
|
|
input int_req; /* interrupt request */
|
18 |
|
|
input nmi_req; /* nmi request */
|
19 |
|
|
input resetb; /* internal (user) reset */
|
20 |
|
|
input wait_req; /* wait request */
|
21 |
|
|
input [7:0] io_data_in; /* i/o input data bus */
|
22 |
|
|
input [7:0] ivec_data_in; /* interrupt vector bus */
|
23 |
|
|
input [7:0] mem_data_in; /* memory input bus */
|
24 |
|
|
output dma_ack; /* dma acknowledge */
|
25 |
|
|
output halt_tran; /* halt transaction */
|
26 |
|
|
output iack_tran; /* interrupt acknowledge transaction */
|
27 |
|
|
output io_read; /* i/o read enable */
|
28 |
|
|
output io_tran; /* i/o transaction */
|
29 |
|
|
output io_strobe; /* i/o data strobe */
|
30 |
|
|
output ivec_rd; /* interrupt vector enable */
|
31 |
|
|
output mem_rd; /* memory read enable */
|
32 |
|
|
output mem_tran; /* memory transaction */
|
33 |
|
|
output mem_wr; /* memory write enable */
|
34 |
|
|
output reti_tran; /* return from interrupt transaction */
|
35 |
|
|
output t1; /* first clock of transaction */
|
36 |
|
|
output [7:0] io_data_out; /* i/o output data bus */
|
37 |
|
|
output [7:0] mem_data_out; /* memory output data bus */
|
38 |
|
|
output [15:0] io_addr_out; /* i/o address bus */
|
39 |
|
|
output [15:0] mem_addr_out; /* memory address bus */
|
40 |
|
|
|
41 |
|
|
/*****************************************************************************************/
|
42 |
|
|
/* */
|
43 |
|
|
/* signal declarations */
|
44 |
|
|
/* */
|
45 |
|
|
/*****************************************************************************************/
|
46 |
|
|
wire burst_done; /* burst/mlt done */
|
47 |
|
|
wire cflg_en; /* carry flag control */
|
48 |
|
|
wire carry_bit; /* carry flag */
|
49 |
|
|
wire dma_ack; /* dma acknowledge */
|
50 |
|
|
wire dmar_reg; /* latched dma request */
|
51 |
|
|
wire ex_af_pls; /* exchange af,af' */
|
52 |
|
|
wire ex_bank_pls; /* exchange register bank */
|
53 |
|
|
wire ex_dehl_inst; /* exchange de,hl */
|
54 |
|
|
wire ftch_tran; /* inst fetch transaction */
|
55 |
|
|
wire halt_nxt, halt_tran; /* halt transaction */
|
56 |
|
|
wire iack_tran; /* int ack transaction */
|
57 |
|
|
wire if_frst; /* first clock if ifetch */
|
58 |
|
|
wire inta_frst; /* first clock of intack */
|
59 |
|
|
wire intr_reg; /* latched interrupt request */
|
60 |
|
|
wire io_read; /* i/o read enable */
|
61 |
|
|
wire io_tran; /* i/o transaction */
|
62 |
|
|
wire io_strobe; /* i/o data strobe */
|
63 |
|
|
wire ivec_rd; /* interrupt vector enable */
|
64 |
|
|
wire ld_ctrl; /* load control register */
|
65 |
|
|
wire ld_dmaa; /* load dma request */
|
66 |
|
|
wire ld_inst; /* load instruction register */
|
67 |
|
|
wire ld_inta; /* sample latched int */
|
68 |
|
|
wire ld_page; /* load page register */
|
69 |
|
|
wire ld_wait; /* sample wait input */
|
70 |
|
|
wire mem_rd; /* memory read enable */
|
71 |
|
|
wire mem_tran; /* memory transaction */
|
72 |
|
|
wire mem_wr; /* memory write enable */
|
73 |
|
|
wire output_inh; /* disable cpu outputs */
|
74 |
|
|
wire par_bit; /* parity flag */
|
75 |
|
|
wire rd_brst; /* burst read */
|
76 |
|
|
wire rd_frst; /* first clock of read */
|
77 |
|
|
wire rd_nxt; /* read trans next */
|
78 |
|
|
wire reti_nxt, reti_tran; /* reti transaction */
|
79 |
4 |
bsa |
wire rreg_en; /* update refresh register */
|
80 |
2 |
bsa |
wire sflg_en; /* sign flag control */
|
81 |
|
|
wire sign_bit; /* sign flag */
|
82 |
|
|
wire tflg_reg; /* temporary flag */
|
83 |
|
|
wire t1; /* first clock of transaction */
|
84 |
|
|
wire vector_int; /* int vector enable */
|
85 |
|
|
wire wait_st; /* wait state identifier */
|
86 |
|
|
wire wr_brst; /* burst write */
|
87 |
|
|
wire wr_frst; /* first clock of write */
|
88 |
|
|
wire xhlt_reg; /* halt exit */
|
89 |
|
|
wire zero_bit; /* zero flag */
|
90 |
|
|
wire zflg_en; /* zero flag control */
|
91 |
|
|
wire [3:0] page_sel; /* inst decode page control */
|
92 |
|
|
wire [3:0] page_reg; /* instruction decode "page" */
|
93 |
|
|
wire [7:0] inst_reg; /* instruction register */
|
94 |
|
|
wire [7:0] data_in; /* read data bus */
|
95 |
|
|
wire [7:0] dout_io_reg, dout_mem_reg; /* write data bus */
|
96 |
|
|
wire [15:0] addr_reg_in; /* processor logical address */
|
97 |
|
|
wire [7:0] io_data_out; /* i/o output data bus */
|
98 |
|
|
wire [7:0] mem_data_out; /* memory output data bus */
|
99 |
|
|
wire [15:0] io_addr_out; /* i/o address bus */
|
100 |
|
|
wire [15:0] mem_addr_out; /* memory address bus */
|
101 |
|
|
wire [`ADCTL_IDX:0] add_sel; /* address output mux control */
|
102 |
|
|
wire [`ALUA_IDX:0] alua_sel; /* alu input a mux control */
|
103 |
|
|
wire [`ALUB_IDX:0] alub_sel; /* alu input b mux control */
|
104 |
|
|
wire [`ALUOP_IDX:0] aluop_sel; /* alu operation control */
|
105 |
|
|
wire [`DI_IDX:0] di_ctl; /* data input control */
|
106 |
|
|
wire [`DO_IDX:0] do_ctl; /* data output control */
|
107 |
|
|
wire [`HFLG_IDX:0] hflg_ctl; /* half-carry flag control */
|
108 |
|
|
wire [`IEF_IDX:0] ief_ctl; /* interrupt enable control */
|
109 |
|
|
wire [`IMD_IDX:0] imd_ctl; /* interrupt mode control */
|
110 |
|
|
wire [`NFLG_IDX:0] nflg_ctl; /* negate flag control */
|
111 |
|
|
wire [`PCCTL_IDX:0] pc_sel; /* pc source control */
|
112 |
|
|
wire [`PFLG_IDX:0] pflg_ctl; /* parity/overflow flag control */
|
113 |
|
|
wire [`STATE_IDX:0] state_nxt, state_reg; /* machine state */
|
114 |
|
|
wire [`TFLG_IDX:0] tflg_ctl; /* temp flag control */
|
115 |
|
|
wire [`TTYPE_IDX:0] tran_sel; /* transaction type */
|
116 |
|
|
wire [`WREG_IDX:0] wr_addr; /* register write address bus */
|
117 |
|
|
|
118 |
|
|
/*****************************************************************************************/
|
119 |
|
|
/* */
|
120 |
|
|
/* interface module */
|
121 |
|
|
/* */
|
122 |
|
|
/*****************************************************************************************/
|
123 |
|
|
extint EXTINT ( .data_in(data_in), .dma_ack(dma_ack), .ftch_tran(ftch_tran),
|
124 |
|
|
.halt_tran(halt_tran), .iack_tran(iack_tran),
|
125 |
|
|
.io_addr_out(io_addr_out), .io_data_out(io_data_out),
|
126 |
|
|
.io_read(io_read), .io_strobe(io_strobe), .io_tran(io_tran),
|
127 |
|
|
.ivec_rd(ivec_rd), .mem_addr_out(mem_addr_out),
|
128 |
|
|
.mem_data_out(mem_data_out), .mem_rd(mem_rd), .mem_tran(mem_tran),
|
129 |
|
|
.mem_wr(mem_wr), .reti_tran(reti_tran), .t1(t1),
|
130 |
|
|
.addr_reg_in(addr_reg_in), .clkc(clkc), .dmar_reg(dmar_reg),
|
131 |
|
|
.dout_io_reg(dout_io_reg), .dout_mem_reg(dout_mem_reg),
|
132 |
|
|
.halt_nxt(halt_nxt), .if_frst(if_frst), .inta_frst(inta_frst),
|
133 |
|
|
.io_data_in(io_data_in), .ivec_data_in(ivec_data_in),
|
134 |
|
|
.ld_dmaa(ld_dmaa), .ld_wait(ld_wait), .mem_data_in(mem_data_in),
|
135 |
|
|
.output_inh(output_inh), .rd_frst(rd_frst), .rd_nxt(rd_nxt),
|
136 |
|
|
.resetb(resetb), .reti_nxt(reti_nxt), .tran_sel(tran_sel),
|
137 |
|
|
.wr_frst(wr_frst) );
|
138 |
|
|
|
139 |
|
|
/*****************************************************************************************/
|
140 |
|
|
/* */
|
141 |
|
|
/* state machine module */
|
142 |
|
|
/* */
|
143 |
|
|
/*****************************************************************************************/
|
144 |
|
|
machine MACHINE ( .ld_ctrl(ld_ctrl), .state_reg(state_reg), .wait_st(wait_st),
|
145 |
|
|
.clkc(clkc), .dmar_reg(dmar_reg), .intr_reg(intr_reg),
|
146 |
|
|
.ld_inta(ld_inta), .ld_wait(ld_wait), .resetb(resetb),
|
147 |
|
|
.state_nxt(state_nxt), .wait_req(wait_req) );
|
148 |
|
|
|
149 |
|
|
/*****************************************************************************************/
|
150 |
|
|
/* */
|
151 |
|
|
/* control module */
|
152 |
|
|
/* */
|
153 |
|
|
/*****************************************************************************************/
|
154 |
|
|
control CONTROL ( .add_sel(add_sel), .alua_sel(alua_sel), .alub_sel(alub_sel),
|
155 |
|
|
.aluop_sel(aluop_sel), .cflg_en(cflg_en), .di_ctl(di_ctl),
|
156 |
|
|
.do_ctl(do_ctl), .ex_af_pls(ex_af_pls), .ex_bank_pls(ex_bank_pls),
|
157 |
|
|
.ex_dehl_inst(ex_dehl_inst), .halt_nxt(halt_nxt), .hflg_ctl(hflg_ctl),
|
158 |
|
|
.ief_ctl(ief_ctl), .if_frst(if_frst), .inta_frst(inta_frst),
|
159 |
|
|
.imd_ctl(imd_ctl), .ld_dmaa(ld_dmaa), .ld_inst(ld_inst),
|
160 |
|
|
.ld_inta(ld_inta), .ld_page(ld_page), .ld_wait(ld_wait),
|
161 |
|
|
.nflg_ctl(nflg_ctl), .output_inh(output_inh), .page_sel(page_sel),
|
162 |
|
|
.pc_sel(pc_sel), .pflg_ctl(pflg_ctl), .rd_frst(rd_frst),
|
163 |
4 |
bsa |
.rd_nxt(rd_nxt), .reti_nxt(reti_nxt), .rreg_en(rreg_en), .sflg_en(sflg_en),
|
164 |
2 |
bsa |
.state_nxt(state_nxt), .tflg_ctl(tflg_ctl), .tran_sel(tran_sel),
|
165 |
|
|
.wr_addr(wr_addr), .wr_frst(wr_frst), .zflg_en(zflg_en),
|
166 |
|
|
.carry_bit(carry_bit), .dmar_reg(dmar_reg), .inst_reg(inst_reg),
|
167 |
|
|
.intr_reg(intr_reg), .page_reg(page_reg), .par_bit(par_bit),
|
168 |
|
|
.sign_bit(sign_bit), .state_reg(state_reg), .tflg_reg(tflg_reg),
|
169 |
6 |
bsa |
.vector_int(vector_int), .xhlt_reg(xhlt_reg), .zero_bit(zero_bit),
|
170 |
|
|
.int_req(int_req) );
|
171 |
2 |
bsa |
|
172 |
|
|
/*****************************************************************************************/
|
173 |
|
|
/* */
|
174 |
|
|
/* data path module */
|
175 |
|
|
/* */
|
176 |
|
|
/*****************************************************************************************/
|
177 |
|
|
datapath DATAPATH ( .addr_reg_in(addr_reg_in), .carry_bit(carry_bit), .dmar_reg(dmar_reg),
|
178 |
|
|
.dout_io_reg(dout_io_reg), .dout_mem_reg(dout_mem_reg),
|
179 |
|
|
.inst_reg(inst_reg), .intr_reg(intr_reg), .page_reg(page_reg),
|
180 |
|
|
.par_bit(par_bit), .sign_bit(sign_bit), .tflg_reg(tflg_reg),
|
181 |
|
|
.vector_int(vector_int), .xhlt_reg(xhlt_reg), .zero_bit(zero_bit),
|
182 |
|
|
.add_sel(add_sel), .alua_sel(alua_sel), .alub_sel(alub_sel),
|
183 |
|
|
.aluop_sel(aluop_sel), .clearb(clearb), .clkc(clkc), .cflg_en(cflg_en),
|
184 |
|
|
.data_in(data_in), .di_ctl(di_ctl), .dma_req(dma_req), .do_ctl(do_ctl),
|
185 |
|
|
.ex_af_pls(ex_af_pls), .ex_bank_pls(ex_bank_pls),
|
186 |
|
|
.ex_dehl_inst(ex_dehl_inst), .hflg_ctl(hflg_ctl), .ief_ctl(ief_ctl),
|
187 |
|
|
.imd_ctl(imd_ctl), .int_req(int_req), .ivec_rd(ivec_rd),
|
188 |
|
|
.ld_ctrl(ld_ctrl), .ld_inst(ld_inst), .ld_page(ld_page),
|
189 |
|
|
.nflg_ctl(nflg_ctl), .nmi_req(nmi_req), .page_sel(page_sel),
|
190 |
4 |
bsa |
.pc_sel(pc_sel), .pflg_ctl(pflg_ctl), .resetb(resetb), .rreg_en(rreg_en),
|
191 |
2 |
bsa |
.sflg_en(sflg_en), .tflg_ctl(tflg_ctl), .wait_st(wait_st),
|
192 |
|
|
.wr_addr(wr_addr), .zflg_en(zflg_en) );
|
193 |
|
|
|
194 |
|
|
endmodule
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|