[rv_plic] Change PRIO number starting from 1

As discussed in #1823, this PR is to match the PRIO* registers name to
the ID read in CC register.

Previously, ID read from CC register is not matched with the offset of
PRIO0, IS, IE, IP. For example, if the software read 0x3 value from CC
register, its corresponding bit in IS is IS[2].

PLIC now generates ID w.r.t the interrupt source bit position. RISC-V
PLIC spec requires to return ID value 0 when no interrupt. So, topgen
ties bit0 of interrupt source signal to 0. By doing in this way, reggen
doesn't have to support arithmetic operation to the parameter.

Signed-off-by: Eunchan Kim <eunchan@opentitan.org>
diff --git a/hw/top_earlgrey/data/top_earlgrey.sv.tpl b/hw/top_earlgrey/data/top_earlgrey.sv.tpl
index 9af5960..07f4ade 100644
--- a/hw/top_earlgrey/data/top_earlgrey.sv.tpl
+++ b/hw/top_earlgrey/data/top_earlgrey.sv.tpl
@@ -158,7 +158,9 @@
 
 
 <%
-  interrupt_num = sum([x["width"] if "width" in x else 1 for x in top["interrupt"]])
+  # Interrupt source 0 is tied to 0 to conform RISC-V PLIC spec.
+  # So, total number of interrupts are the number of entries in the list + 1
+  interrupt_num = sum([x["width"] if "width" in x else 1 for x in top["interrupt"]]) + 1
 %>\
   logic [${interrupt_num-1}:0]  intr_vector;
   // Interrupt source list
@@ -173,11 +175,11 @@
 % endfor
 
 
-  <% add_spaces = " " * len(str((interrupt_num).bit_length()-1)) %>
+  <% add_spaces = " " * len(str((interrupt_num-1).bit_length()-1)) %>
   logic [0:0]${add_spaces}irq_plic;
   logic [0:0]${add_spaces}msip;
-  logic [${(interrupt_num).bit_length()-1}:0] irq_id[1];
-  logic [${(interrupt_num).bit_length()-1}:0] unused_irq_id[1];
+  logic [${(interrupt_num-1).bit_length()-1}:0] irq_id[1];
+  logic [${(interrupt_num-1).bit_length()-1}:0] unused_irq_id[1];
 
   // this avoids lint errors
   assign unused_irq_id = irq_id;
@@ -675,8 +677,9 @@
   // interrupt assignments
   assign intr_vector = {
   % for intr in top["interrupt"][::-1]:
-      intr_${intr["name"]}${"," if not loop.last else ""}
+      intr_${intr["name"]},
   % endfor
+      1'b 0 // For ID 0.
   };
 
   // TL-UL Crossbar