core.v
资源名称:_8259A.zip [点击查看]
上传用户:tzxuweilin
上传日期:2022-08-10
资源大小:747k
文件大小:3k
源码类别:
VHDL/FPGA/Verilog
开发平台:
VHDL
- module core(cs, rd, wr, inta, a0, reset, isrset, code, datain, busdatain, ltim, sm, rd_isr, rd_imr, wr_imr, clr_imr, rd_irr, eor, setzero, sp, dataout, busdataout);
- input cs;
- input rd, wr;
- input inta;
- input a0;
- input reset;
- input[7:0] isrset;
- input[2:0] code;
- input[7:0] datain, busdatain;
- output ltim;
- output sm;
- output rd_isr;
- output rd_imr, wr_imr, clr_imr;
- output rd_irr;
- output[7:0] eor;
- output[7:0] setzero;
- output[2:0] sp;
- output[7:0] dataout;
- output[7:0] busdataout;
- reg[2:0] state;
- wire write1, write2, clk;
- wire[7:0] icw1, icw2, icw3, icw4, ocw1, ocw2, ocw3;
- wire o1;
- wire[5:0] codeocw2, erocw2;
- //reg[1:0] edge1;
- initial begin state = 3'd1; end
- assign write1 = (~cs && ~wr && rd && ~a0) ? 1 : 0;
- assign write2 = (~cs && ~wr && rd && a0) ? 1 : 0;
- assign clk = write1 | write2;
- assign icw1 = reset ? 8'h00 : (state == 1 && write1 ? datain : icw1);
- assign icw2 = reset ? 8'h00 : (state == 2 && write1 ? datain : icw2);
- assign icw3 = reset ? 8'h00 : (state == 3 && write1 ? datain : icw3);
- assign icw4 = reset ? 8'h00 : (state == 4 && write1 ? datain : icw4);
- assign ocw1 = reset ? 8'h00 : (state == 5 && write2 ? datain : ocw1);
- assign ocw2 = reset ? 8'h00 : (state == 5 && write1 && datain[4:3] == 2'b00 ? datain : ocw2);
- assign ocw3 = reset ? 8'h00 : (state == 5 && write1 && datain[4:3] == 2'b01 ? datain : ocw3);
- assign ltim = icw1[3];
- assign read1 = (~cs && wr && ~rd && a0) ? 1 : 0;
- assign read1 = (~cs && wr && ~rd && ~a0) ? 1 : 0;
- assign dataout = (read2 || (read1 && ocw3[1] == 1)) ? busdatain : ((flag2 == 0 && flag1 == 1) ? {icw2[7:3], code[2:0]} : 8'b0);
- assign o1 = (state==5 && write2);
- assign busdataout = o1 ? ocw1 : 8'b0;
- assign sm = (ocw3[6:5] == 2'b10) ? 1 : 0;
- assign rd_irr = (read1 && ocw3[1:0] == 2'b10) ? 1 : 0;
- assign rd_isr = (read1 && ocw3[1:0] == 2'b11) ? 1 : 0;
- always @(posedge clk or posedge reset)
- begin
- if (reset) state <= 1;
- else
- begin
- case (state)
- 1:
- if (write2)
- begin
- state <= 2;
- //edge1 = 2'b01;
- end
- 2:
- begin
- if (~icw1[1])
- state <= 3;
- else if (icw1[0])
- state <= 4;
- else
- state <= 5;
- end
- 3:
- begin
- if (icw1[0])
- state <= 4;
- else
- state <= 5;
- end
- 4:
- //if (edge1 == 2'b11)
- state <= 5;
- 5:
- if (write1 && datain[4])
- state <= 1;
- end
- end
- assign codeocw2 = {code, ocw2[2:0]};
- always @(codeocw2)
- begin
- if (reset || mclr)
- er <= 8'hff;
- else if (icw4[1])
- begin
- if (flag2)
- begin
- case (code)
- 3'd0: er <=
- end
- end
- end
- endmodule