Line 1... |
Line 1... |
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
// ============================================================================
|
// ============================================================================
|
// __
|
// __
|
// \\__/ o\ (C) 2013-2018 Robert Finch, Waterloo
|
// \\__/ o\ (C) 2013-2019 Robert Finch, Waterloo
|
// \ __ / All rights reserved.
|
// \ __ / All rights reserved.
|
// \/_// robfinch<remove>@finitron.ca
|
// \/_// robfinch<remove>@finitron.ca
|
// ||
|
// ||
|
//
|
//
|
// This source file is free software: you can redistribute it and/or modify
|
// This source file is free software: you can redistribute it and/or modify
|
Line 53... |
Line 53... |
//
|
//
|
// 0x14 - write only
|
// 0x14 - write only
|
// This register resets the edge sense circuitry
|
// This register resets the edge sense circuitry
|
// indicated by the low order five bits of the input data.
|
// indicated by the low order five bits of the input data.
|
//
|
//
|
|
// 0x18 - write only
|
|
// This register triggers the interrupt indicated by the low
|
|
// order five bits of the input data.
|
|
//
|
// 0x80 - irq control for irq #0
|
// 0x80 - irq control for irq #0
|
// 0x84 - irq control for irq #1
|
// 0x84 - irq control for irq #1
|
// bits 0 to 7 = cause code to issue
|
// bits 0 to 7 = cause code to issue
|
// bits 8 to 11 = irq level to issue
|
// bits 8 to 11 = irq level to issue
|
// bit 16 = irq enable
|
// bit 16 = irq enable
|
Line 80... |
Line 84... |
i16, i17, i18, i19, i20, i21, i22, i23,
|
i16, i17, i18, i19, i20, i21, i22, i23,
|
i24, i25, i26, i27, i28, i29, i30, i31,
|
i24, i25, i26, i27, i28, i29, i30, i31,
|
output [3:0] irqo, // normally connected to the processor irq
|
output [3:0] irqo, // normally connected to the processor irq
|
input nmii, // nmi input connected to nmi requester
|
input nmii, // nmi input connected to nmi requester
|
output nmio, // normally connected to the nmi of cpu
|
output nmio, // normally connected to the nmi of cpu
|
output [6:0] causeo
|
output [7:0] causeo
|
);
|
);
|
parameter pIOAddress = 32'hFFDC_0F00;
|
parameter pIOAddress = 32'hFFDC_0F00;
|
|
|
|
reg [31:0] trig;
|
reg [31:0] ie; // interrupt enable register
|
reg [31:0] ie; // interrupt enable register
|
reg rdy1;
|
reg rdy1;
|
reg [4:0] irqenc;
|
reg [4:0] irqenc;
|
wire [31:0] i = { i31,i30,i29,i28,i27,i26,i25,i24,i23,i22,i21,i20,i19,i18,i17,i16,
|
wire [31:0] i = { i31,i30,i29,i28,i27,i26,i25,i24,i23,i22,i21,i20,i19,i18,i17,i16,
|
i15,i14,i13,i12,i11,i10,i9,i8,i7,i6,i5,i4,i3,i2,i1,nmii};
|
i15,i14,i13,i12,i11,i10,i9,i8,i7,i6,i5,i4,i3,i2,i1,nmii};
|
Line 119... |
Line 124... |
// write registers
|
// write registers
|
always @(posedge clk_i)
|
always @(posedge clk_i)
|
if (rst_i) begin
|
if (rst_i) begin
|
ie <= 32'h0;
|
ie <= 32'h0;
|
rste <= 32'h0;
|
rste <= 32'h0;
|
|
trig <= 32'h0;
|
end
|
end
|
else begin
|
else begin
|
rste <= 32'h0;
|
rste <= 32'h0;
|
|
trig <= 32'h0;
|
if (cs & wr_i) begin
|
if (cs & wr_i) begin
|
casez (adr_i[7:2])
|
casez (adr_i[7:2])
|
6'd0: ;
|
6'd0: ;
|
6'd1:
|
6'd1:
|
begin
|
begin
|
Line 133... |
Line 140... |
end
|
end
|
6'd2,6'd3:
|
6'd2,6'd3:
|
ie[dat_i[4:0]] <= adr_i[2];
|
ie[dat_i[4:0]] <= adr_i[2];
|
6'd4: es <= dat_i[31:0];
|
6'd4: es <= dat_i[31:0];
|
6'd5: rste[dat_i[4:0]] <= 1'b1;
|
6'd5: rste[dat_i[4:0]] <= 1'b1;
|
|
6'd6: trig[dat_i[4:0]] <= 1'b1;
|
6'b1?????:
|
6'b1?????:
|
begin
|
begin
|
cause[adr_i[6:2]] <= dat_i[7:0];
|
cause[adr_i[6:2]] <= dat_i[7:0];
|
irq[adr_i[6:2]] <= dat_i[11:8];
|
irq[adr_i[6:2]] <= dat_i[11:8];
|
ie[adr_i[6:2]] <= dat_i[16];
|
ie[adr_i[6:2]] <= dat_i[16];
|
Line 159... |
Line 167... |
endcase
|
endcase
|
else
|
else
|
dat_o <= 32'h0000;
|
dat_o <= 32'h0000;
|
end
|
end
|
|
|
assign irqo = (irqenc == 5'h0) ? 4'd0 : irq[irqenc];
|
assign irqo = (irqenc == 5'h0) ? 4'd0 : irq[irqenc] & {4{ie[irqenc]}};
|
assign causeo = (irqenc == 5'h0) ? 8'd0 : cause[irqenc];
|
assign causeo = (irqenc == 5'h0) ? 8'd0 : cause[irqenc];
|
assign nmio = nmii & ie[0];
|
assign nmio = nmii & ie[0];
|
|
|
// Edge detect circuit
|
// Edge detect circuit
|
always @(posedge clk_i)
|
always @(posedge clk_i)
|
begin
|
begin
|
for (n = 1; n < 32; n = n + 1)
|
for (n = 1; n < 32; n = n + 1)
|
begin
|
begin
|
ib[n] <= i[n];
|
ib[n] <= i[n];
|
|
if (trig[n]) iedge[n] <= 1'b1;
|
if (i[n] & !ib[n]) iedge[n] <= 1'b1;
|
if (i[n] & !ib[n]) iedge[n] <= 1'b1;
|
if (rste[n]) iedge[n] <= 1'b0;
|
if (rste[n]) iedge[n] <= 1'b0;
|
end
|
end
|
end
|
end
|
|
|
Line 181... |
Line 190... |
// nmi is not encoded
|
// nmi is not encoded
|
always @(posedge clk_i)
|
always @(posedge clk_i)
|
begin
|
begin
|
irqenc <= 5'd0;
|
irqenc <= 5'd0;
|
for (n = 31; n > 0; n = n - 1)
|
for (n = 31; n > 0; n = n - 1)
|
if (ie[n] & (es[n] ? iedge[n] : i[n])) irqenc <= n;
|
if ((es[n] ? iedge[n] : i[n])) irqenc <= n;
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|