x393  1.0
FPGAcodeforElphelNC393camera
sim_soc_interrupts.v
Go to the documentation of this file.
1 
26 `timescale 1ns/1ps
27 
29  parameter NUM_INTERRUPTS = 8
30  )(
31  input clk,
32  input rst,
33  input irq_en, // automatically handled for the main thread
34  input [NUM_INTERRUPTS-1:0] irqm, // individual interrupts enable (bit = 1 - enable, 0 - disable)
35  input [NUM_INTERRUPTS-1:0] irq, // async interrupt requests
36  input [NUM_INTERRUPTS-1:0] irq_done, // end of ISR, turn off inta bit, re-enable arbitration
37  output [NUM_INTERRUPTS-1:0] irqs, // synchronized by clock masked interrupts
38  output [NUM_INTERRUPTS-1:0] inta, // interrupt acknowledge
39  output main_go // enable main thread to proceed
40 );
41 
46 
47  assign inta = inta_r;
48  assign irqs = irqs_r;
49  assign main_go = !(|inta_r) && !(irq_en && |irqs);
50 
51  generate
52  genvar i;
53  for (i=0; i < NUM_INTERRUPTS; i=i+1) begin: pri_enc_block
54  assign irqs_pri_w[i] = irqs_r[i] && !(|irqs_ext[i:0]);
55  end
56  endgenerate
57  always @ (posedge clk or posedge rst) begin
58  if (rst) inta_r <= 0;
59  else if (!(|inta_r)) inta_r <= irqs_pri_w;
60  else inta_r <= inta_r & ~irq_done;
61 
62  if (rst) irqs_r <= 0;
63  else irqs_r <= irq & irqm;
64 
65  end
66 
67 endmodule
68 
[NUM_INTERRUPTS-1:0] 8837irq
8844irqs_extwire[NUM_INTERRUPTS:0]
8842inta_rreg[NUM_INTERRUPTS-1:0]
[NUM_INTERRUPTS-1:0] 8836irqm
8843irqs_rreg[NUM_INTERRUPTS-1:0]
8845irqs_pri_wwire[NUM_INTERRUPTS-1:0]
[NUM_INTERRUPTS-1:0] 8839irqs
[NUM_INTERRUPTS-1:0] 8840inta
[NUM_INTERRUPTS-1:0] 8838irq_done