[topgen] Don't copy data from block into instances
There's no need to do this, as long as we can look up the block
quickly. The nicest way to do that would be to add a "block" field to
the instance dictionary, but that would be enormous when we dumped
top_earlgrey.gen.hjson (I tried it - it added 32k lines!), so we just
pass around a dictionary mapping block name to the IpBlock object
instead.
Note that we do still have to copy inter_signal_list, because that
gets annotated (through references; it's not very easy to trace) by
the code in intermodule.py.
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
index 134b964..c73a645 100644
--- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
+++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
@@ -493,74 +493,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list:
- [
- {
- name: rx
- width: 1
- type: input
- }
- ]
- available_output_list:
- [
- {
- name: tx
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: tx_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_frame_err
- width: 1
- type: interrupt
- }
- {
- name: rx_break_err
- width: 1
- type: interrupt
- }
- {
- name: rx_timeout
- width: 1
- type: interrupt
- }
- {
- name: rx_parity_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -597,74 +530,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list:
- [
- {
- name: rx
- width: 1
- type: input
- }
- ]
- available_output_list:
- [
- {
- name: tx
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: tx_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_frame_err
- width: 1
- type: interrupt
- }
- {
- name: rx_break_err
- width: 1
- type: interrupt
- }
- {
- name: rx_timeout
- width: 1
- type: interrupt
- }
- {
- name: rx_parity_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -701,74 +567,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list:
- [
- {
- name: rx
- width: 1
- type: input
- }
- ]
- available_output_list:
- [
- {
- name: tx
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: tx_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_frame_err
- width: 1
- type: interrupt
- }
- {
- name: rx_break_err
- width: 1
- type: interrupt
- }
- {
- name: rx_timeout
- width: 1
- type: interrupt
- }
- {
- name: rx_parity_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -805,74 +604,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list:
- [
- {
- name: rx
- width: 1
- type: input
- }
- ]
- available_output_list:
- [
- {
- name: tx
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: tx_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_frame_err
- width: 1
- type: interrupt
- }
- {
- name: rx_break_err
- width: 1
- type: interrupt
- }
- {
- name: rx_timeout
- width: 1
- type: interrupt
- }
- {
- name: rx_parity_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -909,32 +641,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: gpio
- width: 32
- type: inout
- }
- ]
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: gpio
- width: 32
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -973,69 +680,7 @@
}
domain: "0"
size: 0x2000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: sd
- width: 4
- type: inout
- }
- ]
- available_input_list:
- [
- {
- name: sck
- width: 1
- type: input
- }
- {
- name: csb
- width: 1
- type: input
- }
- ]
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: rxf
- width: 1
- type: interrupt
- }
- {
- name: rxlvl
- width: 1
- type: interrupt
- }
- {
- name: txlvl
- width: 1
- type: interrupt
- }
- {
- name: rxerr
- width: 1
- type: interrupt
- }
- {
- name: rxoverflow
- width: 1
- type: interrupt
- }
- {
- name: txunderflow
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "true"
- scan_reset: "true"
inter_signal_list:
[
{
@@ -1075,49 +720,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: sd
- width: 4
- type: inout
- }
- ]
- available_input_list: []
- available_output_list:
- [
- {
- name: sck
- width: 1
- type: output
- }
- {
- name: csb
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: error
- width: 1
- type: interrupt
- }
- {
- name: spi_event
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1157,49 +760,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: sd
- width: 4
- type: inout
- }
- ]
- available_input_list: []
- available_output_list:
- [
- {
- name: sck
- width: 1
- type: output
- }
- {
- name: csb
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: error
- width: 1
- type: interrupt
- }
- {
- name: spi_event
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1236,112 +797,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: sda
- width: 1
- type: inout
- }
- {
- name: scl
- width: 1
- type: inout
- }
- ]
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: fmt_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: fmt_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: nak
- width: 1
- type: interrupt
- }
- {
- name: scl_interference
- width: 1
- type: interrupt
- }
- {
- name: sda_interference
- width: 1
- type: interrupt
- }
- {
- name: stretch_timeout
- width: 1
- type: interrupt
- }
- {
- name: sda_unstable
- width: 1
- type: interrupt
- }
- {
- name: trans_complete
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: tx_nonempty
- width: 1
- type: interrupt
- }
- {
- name: tx_overflow
- width: 1
- type: interrupt
- }
- {
- name: acq_overflow
- width: 1
- type: interrupt
- }
- {
- name: ack_stop
- width: 1
- type: interrupt
- }
- {
- name: host_timeout
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1378,112 +834,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: sda
- width: 1
- type: inout
- }
- {
- name: scl
- width: 1
- type: inout
- }
- ]
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: fmt_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: fmt_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: nak
- width: 1
- type: interrupt
- }
- {
- name: scl_interference
- width: 1
- type: interrupt
- }
- {
- name: sda_interference
- width: 1
- type: interrupt
- }
- {
- name: stretch_timeout
- width: 1
- type: interrupt
- }
- {
- name: sda_unstable
- width: 1
- type: interrupt
- }
- {
- name: trans_complete
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: tx_nonempty
- width: 1
- type: interrupt
- }
- {
- name: tx_overflow
- width: 1
- type: interrupt
- }
- {
- name: acq_overflow
- width: 1
- type: interrupt
- }
- {
- name: ack_stop
- width: 1
- type: interrupt
- }
- {
- name: host_timeout
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1520,112 +871,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: sda
- width: 1
- type: inout
- }
- {
- name: scl
- width: 1
- type: inout
- }
- ]
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: fmt_watermark
- width: 1
- type: interrupt
- }
- {
- name: rx_watermark
- width: 1
- type: interrupt
- }
- {
- name: fmt_overflow
- width: 1
- type: interrupt
- }
- {
- name: rx_overflow
- width: 1
- type: interrupt
- }
- {
- name: nak
- width: 1
- type: interrupt
- }
- {
- name: scl_interference
- width: 1
- type: interrupt
- }
- {
- name: sda_interference
- width: 1
- type: interrupt
- }
- {
- name: stretch_timeout
- width: 1
- type: interrupt
- }
- {
- name: sda_unstable
- width: 1
- type: interrupt
- }
- {
- name: trans_complete
- width: 1
- type: interrupt
- }
- {
- name: tx_empty
- width: 1
- type: interrupt
- }
- {
- name: tx_nonempty
- width: 1
- type: interrupt
- }
- {
- name: tx_overflow
- width: 1
- type: interrupt
- }
- {
- name: acq_overflow
- width: 1
- type: interrupt
- }
- {
- name: ack_stop
- width: 1
- type: interrupt
- }
- {
- name: host_timeout
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1662,52 +908,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list:
- [
- {
- name: pda0_tx
- width: 1
- type: output
- }
- {
- name: pcl0_tx
- width: 1
- type: output
- }
- {
- name: pda1_tx
- width: 1
- type: output
- }
- {
- name: pcl1_tx
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: done_ch0
- width: 1
- type: interrupt
- }
- {
- name: done_ch1
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1744,25 +945,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: timer_expired_0_0
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -1809,156 +992,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list:
- [
- {
- name: d
- width: 1
- type: inout
- }
- {
- name: dp
- width: 1
- type: inout
- }
- {
- name: dn
- width: 1
- type: inout
- }
- ]
- available_input_list:
- [
- {
- name: sense
- width: 1
- type: input
- }
- ]
- available_output_list:
- [
- {
- name: se0
- width: 1
- type: output
- }
- {
- name: dp_pullup
- width: 1
- type: output
- }
- {
- name: dn_pullup
- width: 1
- type: output
- }
- {
- name: tx_mode_se
- width: 1
- type: output
- }
- {
- name: suspend
- width: 1
- type: output
- }
- ]
param_list: []
- interrupt_list:
- [
- {
- name: pkt_received
- width: 1
- type: interrupt
- }
- {
- name: pkt_sent
- width: 1
- type: interrupt
- }
- {
- name: disconnected
- width: 1
- type: interrupt
- }
- {
- name: host_lost
- width: 1
- type: interrupt
- }
- {
- name: link_reset
- width: 1
- type: interrupt
- }
- {
- name: link_suspend
- width: 1
- type: interrupt
- }
- {
- name: link_resume
- width: 1
- type: interrupt
- }
- {
- name: av_empty
- width: 1
- type: interrupt
- }
- {
- name: rx_full
- width: 1
- type: interrupt
- }
- {
- name: av_overflow
- width: 1
- type: interrupt
- }
- {
- name: link_in_err
- width: 1
- type: interrupt
- }
- {
- name: rx_crc_err
- width: 1
- type: interrupt
- }
- {
- name: rx_pid_err
- width: 1
- type: interrupt
- }
- {
- name: rx_bitstuff_err
- width: 1
- type: interrupt
- }
- {
- name: frame
- width: 1
- type: interrupt
- }
- {
- name: connected
- width: 1
- type: interrupt
- }
- {
- name: link_out_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -2086,11 +1120,6 @@
}
domain: "0"
size: 0x4000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -2122,38 +1151,6 @@
randwidth: 240
}
]
- interrupt_list:
- [
- {
- name: otp_operation_done
- width: 1
- type: interrupt
- }
- {
- name: otp_error
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: fatal_macro_error
- type: alert
- width: 1
- async: "0"
- }
- {
- name: fatal_check_error
- type: alert
- width: 1
- async: "0"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -2403,11 +1400,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -2441,26 +1433,6 @@
randwidth: 64
}
]
- interrupt_list: []
- alert_list:
- [
- {
- name: fatal_prog_error
- type: alert
- width: 1
- async: "0"
- }
- {
- name: fatal_state_error
- type: alert
- width: 1
- async: "0"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "true"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -2874,11 +1846,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -2902,34 +1869,6 @@
randwidth: 160
}
]
- interrupt_list:
- [
- {
- name: classa
- width: 1
- type: interrupt
- }
- {
- name: classb
- width: 1
- type: interrupt
- }
- {
- name: classc
- width: 1
- type: interrupt
- }
- {
- name: classd
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -3024,25 +1963,7 @@
clk_slow_i: clkmgr_aon_clocks.clk_aon_powerup
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: wakeup
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -3258,18 +2179,7 @@
clk_io_div4_i: clkmgr_aon_clocks.clk_io_div4_powerup
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list: []
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "true"
- scan_reset: "true"
inter_signal_list:
[
{
@@ -3385,18 +2295,7 @@
clk_i: clkmgr_aon_clocks.clk_io_div4_powerup
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list: []
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "true"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -3572,28 +2471,7 @@
clk_aon_i: clkmgr_aon_clocks.clk_aon_powerup
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list: []
- alert_list: []
- wakeup_list:
- [
- {
- name: aon_wkup_req
- width: "1"
- }
- {
- name: usb_wkup_req
- width: "1"
- }
- ]
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -3812,42 +2690,7 @@
clk_aon_i: clkmgr_aon_clocks.clk_aon_timers
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: wkup_timer_expired
- width: 1
- type: interrupt
- }
- {
- name: wdog_timer_bark
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list:
- [
- {
- name: aon_timer_wkup_req
- width: "1"
- }
- ]
- reset_request_list:
- [
- {
- name: aon_timer_rst_req
- width: "1"
- }
- ]
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -3937,18 +2780,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list: []
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -3987,62 +2819,7 @@
clk_i: clkmgr_aon_clocks.clk_io_div4_secure
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list: []
- alert_list:
- [
- {
- name: recov_as
- type: alert
- width: 1
- async: "0"
- }
- {
- name: recov_cg
- type: alert
- width: 1
- async: "0"
- }
- {
- name: recov_gd
- type: alert
- width: 1
- async: "0"
- }
- {
- name: recov_ts_hi
- type: alert
- width: 1
- async: "0"
- }
- {
- name: recov_ts_lo
- type: alert
- width: 1
- async: "0"
- }
- {
- name: recov_ls
- type: alert
- width: 1
- async: "0"
- }
- {
- name: recov_ot
- type: alert
- width: 1
- async: "0"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -4108,11 +2885,6 @@
clk_otp_i: clkmgr_aon_clocks.clk_io_div4_peri
}
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -4144,26 +2916,6 @@
name_top: SramCtrlRetAonInstrExec
}
]
- interrupt_list: []
- alert_list:
- [
- {
- name: fatal_intg_error
- type: alert
- width: 1
- async: "0"
- }
- {
- name: fatal_parity_error
- type: alert
- width: 1
- async: "0"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -4291,35 +3043,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list:
- [
- {
- name: tck
- width: 1
- type: input
- }
- {
- name: tms
- width: 1
- type: input
- }
- {
- name: tdi
- width: 1
- type: input
- }
- ]
- available_output_list:
- [
- {
- name: tdo
- width: 1
- type: output
- }
- ]
param_list:
[
{
@@ -4363,59 +3086,6 @@
randwidth: 160
}
]
- interrupt_list:
- [
- {
- name: prog_empty
- width: 1
- type: interrupt
- }
- {
- name: prog_lvl
- width: 1
- type: interrupt
- }
- {
- name: rd_full
- width: 1
- type: interrupt
- }
- {
- name: rd_lvl
- width: 1
- type: interrupt
- }
- {
- name: op_done
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: recov_err
- type: alert
- width: 1
- async: "1"
- }
- {
- name: recov_mp_err
- type: alert
- width: 1
- async: "1"
- }
- {
- name: recov_ecc_err
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -4607,18 +3277,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list: []
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -4658,11 +3317,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -4780,26 +3434,6 @@
randwidth: 160
}
]
- interrupt_list: []
- alert_list:
- [
- {
- name: recov_ctrl_update_err
- type: alert
- width: 1
- async: "1"
- }
- {
- name: fatal_fault
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -4872,35 +3506,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: hmac_done
- width: 1
- type: interrupt
- }
- {
- name: fifo_empty
- width: 1
- type: interrupt
- }
- {
- name: hmac_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -4952,11 +3558,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -4989,29 +3590,6 @@
name_top: KmacReuseShare
}
]
- interrupt_list:
- [
- {
- name: kmac_done
- width: 1
- type: interrupt
- }
- {
- name: fifo_empty
- width: 1
- type: interrupt
- }
- {
- name: kmac_err
- width: 1
- type: interrupt
- }
- ]
- alert_list: []
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -5099,11 +3677,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -5237,33 +3810,6 @@
randwidth: 256
}
]
- interrupt_list:
- [
- {
- name: op_done
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: fatal_fault_err
- type: alert
- width: 1
- async: "1"
- }
- {
- name: recov_operation_err
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -5419,11 +3965,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -5435,42 +3976,6 @@
name_top: CsrngSBoxImpl
}
]
- interrupt_list:
- [
- {
- name: cs_cmd_req_done
- width: 1
- type: interrupt
- }
- {
- name: cs_entropy_req
- width: 1
- type: interrupt
- }
- {
- name: cs_hw_inst_exc
- width: 1
- type: interrupt
- }
- {
- name: cs_fatal_err
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: fatal_alert
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -5558,49 +4063,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: es_entropy_valid
- width: 1
- type: interrupt
- }
- {
- name: es_health_test_failed
- width: 1
- type: interrupt
- }
- {
- name: es_fatal_err
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: recov_alert
- type: alert
- width: 1
- async: "1"
- }
- {
- name: fatal_alert
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -5685,38 +4148,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: edn_cmd_req_done
- width: 1
- type: interrupt
- }
- {
- name: edn_fatal_err
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: fatal_alert
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -5788,38 +4220,7 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list: []
- interrupt_list:
- [
- {
- name: edn_cmd_req_done
- width: 1
- type: interrupt
- }
- {
- name: edn_fatal_err
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: fatal_alert
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -5894,11 +4295,6 @@
}
domain: "0"
size: 0x1000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -5930,26 +4326,6 @@
name_top: SramCtrlMainInstrExec
}
]
- interrupt_list: []
- alert_list:
- [
- {
- name: fatal_intg_error
- type: alert
- width: 1
- async: "1"
- }
- {
- name: fatal_parity_error
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -6076,11 +4452,6 @@
}
domain: "0"
size: 0x10000
- bus_device: tlul
- bus_host: none
- available_inout_list: []
- available_input_list: []
- available_output_list: []
param_list:
[
{
@@ -6092,33 +4463,6 @@
name_top: OtbnRegFile
}
]
- interrupt_list:
- [
- {
- name: done
- width: 1
- type: interrupt
- }
- ]
- alert_list:
- [
- {
- name: fatal
- type: alert
- width: 1
- async: "1"
- }
- {
- name: recov
- type: alert
- width: 1
- async: "1"
- }
- ]
- wakeup_list: []
- reset_request_list: []
- scan: "false"
- scan_reset: "false"
inter_signal_list:
[
{
@@ -9394,204 +7738,204 @@
[
{
name: aes_recov_ctrl_update_err
- type: alert
width: 1
+ type: alert
async: "1"
module_name: aes
}
{
name: aes_fatal_fault
- type: alert
width: 1
+ type: alert
async: "1"
module_name: aes
}
{
name: otbn_fatal
- type: alert
width: 1
+ type: alert
async: "1"
module_name: otbn
}
{
name: otbn_recov
- type: alert
width: 1
+ type: alert
async: "1"
module_name: otbn
}
{
name: sensor_ctrl_aon_recov_as
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: sensor_ctrl_aon_recov_cg
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: sensor_ctrl_aon_recov_gd
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: sensor_ctrl_aon_recov_ts_hi
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: sensor_ctrl_aon_recov_ts_lo
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: sensor_ctrl_aon_recov_ls
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: sensor_ctrl_aon_recov_ot
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sensor_ctrl_aon
}
{
name: keymgr_fatal_fault_err
- type: alert
width: 1
+ type: alert
async: "1"
module_name: keymgr
}
{
name: keymgr_recov_operation_err
- type: alert
width: 1
+ type: alert
async: "1"
module_name: keymgr
}
{
name: otp_ctrl_fatal_macro_error
- type: alert
width: 1
+ type: alert
async: "0"
module_name: otp_ctrl
}
{
name: otp_ctrl_fatal_check_error
- type: alert
width: 1
+ type: alert
async: "0"
module_name: otp_ctrl
}
{
name: lc_ctrl_fatal_prog_error
- type: alert
width: 1
+ type: alert
async: "0"
module_name: lc_ctrl
}
{
name: lc_ctrl_fatal_state_error
- type: alert
width: 1
+ type: alert
async: "0"
module_name: lc_ctrl
}
{
name: entropy_src_recov_alert
- type: alert
width: 1
+ type: alert
async: "1"
module_name: entropy_src
}
{
name: entropy_src_fatal_alert
- type: alert
width: 1
+ type: alert
async: "1"
module_name: entropy_src
}
{
name: csrng_fatal_alert
- type: alert
width: 1
+ type: alert
async: "1"
module_name: csrng
}
{
name: edn0_fatal_alert
- type: alert
width: 1
+ type: alert
async: "1"
module_name: edn0
}
{
name: edn1_fatal_alert
- type: alert
width: 1
+ type: alert
async: "1"
module_name: edn1
}
{
name: sram_ctrl_main_fatal_intg_error
- type: alert
width: 1
+ type: alert
async: "1"
module_name: sram_ctrl_main
}
{
name: sram_ctrl_main_fatal_parity_error
- type: alert
width: 1
+ type: alert
async: "1"
module_name: sram_ctrl_main
}
{
name: sram_ctrl_ret_aon_fatal_intg_error
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sram_ctrl_ret_aon
}
{
name: sram_ctrl_ret_aon_fatal_parity_error
- type: alert
width: 1
+ type: alert
async: "0"
module_name: sram_ctrl_ret_aon
}
{
name: flash_ctrl_recov_err
- type: alert
width: 1
+ type: alert
async: "1"
module_name: flash_ctrl
}
{
name: flash_ctrl_recov_mp_err
- type: alert
width: 1
+ type: alert
async: "1"
module_name: flash_ctrl
}
{
name: flash_ctrl_recov_ecc_err
- type: alert
width: 1
+ type: alert
async: "1"
module_name: flash_ctrl
}
diff --git a/hw/top_earlgrey/data/top_earlgrey.sv.tpl b/hw/top_earlgrey/data/top_earlgrey.sv.tpl
index 0a762fd..38e1357 100644
--- a/hw/top_earlgrey/data/top_earlgrey.sv.tpl
+++ b/hw/top_earlgrey/data/top_earlgrey.sv.tpl
@@ -123,24 +123,17 @@
% if not lib.is_inst(m):
<% continue %>
% endif
+<%
+ block = name_to_block[m['type']]
+ inouts, inputs, outputs = block.xputs
+%>\
// ${m["name"]}
- % for p_in in m["available_input_list"] + m["available_inout_list"]:
- ## assume it passed validate and have available input list always
- % if "width" in p_in:
- logic ${lib.bitarray(int(p_in["width"]), max_sigwidth)} cio_${m["name"]}_${p_in["name"]}_p2d;
- % else:
- logic ${lib.bitarray(1, max_sigwidth)} cio_${m["name"]}_${p_in["name"]}_p2d;
- % endif
+ % for p_in in inputs + inouts:
+ logic ${lib.bitarray(p_in.bits.width(), max_sigwidth)} cio_${m["name"]}_${p_in.name}_p2d;
% endfor
- % for p_out in m["available_output_list"] + m["available_inout_list"]:
- ## assume it passed validate and have available output list always
- % if "width" in p_out:
- logic ${lib.bitarray(int(p_out["width"]), max_sigwidth)} cio_${m["name"]}_${p_out["name"]}_d2p;
- logic ${lib.bitarray(int(p_out["width"]), max_sigwidth)} cio_${m["name"]}_${p_out["name"]}_en_d2p;
- % else:
- logic ${lib.bitarray(1, max_sigwidth)} cio_${m["name"]}_${p_out["name"]}_d2p;
- logic ${lib.bitarray(1, max_sigwidth)} cio_${m["name"]}_${p_out["name"]}_en_d2p;
- % endif
+ % for p_out in outputs + inouts:
+ logic ${lib.bitarray(p_out.bits.width(), max_sigwidth)} cio_${m["name"]}_${p_out.name}_d2p;
+ logic ${lib.bitarray(p_out.bits.width(), max_sigwidth)} cio_${m["name"]}_${p_out.name}_en_d2p;
% endfor
% endfor
@@ -153,14 +146,17 @@
logic [${interrupt_num-1}:0] intr_vector;
// Interrupt source list
% for m in top["module"]:
+<%
+ block = name_to_block[m['type']]
+%>\
% if not lib.is_inst(m):
<% continue %>
% endif
- % for intr in m["interrupt_list"] if "interrupt_list" in m else []:
- % if "width" in intr and int(intr["width"]) != 1:
- logic [${int(intr["width"])-1}:0] intr_${m["name"]}_${intr["name"]};
+ % for intr in block.interrupts:
+ % if intr.bits.width() != 1:
+ logic [${intr.bits.width()-1}:0] intr_${m["name"]}_${intr.name};
% else:
- logic intr_${m["name"]}_${intr["name"]};
+ logic intr_${m["name"]}_${intr.name};
% endif
% endfor
% endfor
@@ -576,18 +572,13 @@
if not lib.is_inst(m):
continue
-port_list = m["available_input_list"] + m["available_output_list"] + m["available_inout_list"]
-if len(port_list) == 0:
- max_sigwidth = 0
-else:
- max_sigwidth = max([len(x["name"]) for x
- in m["available_input_list"] + m["available_inout_list"] + m["available_output_list"]])
+block = name_to_block[m['type']]
+inouts, inputs, outputs = block.xputs
-if len(m["interrupt_list"]) == 0:
- max_intrwidth = 0
-else:
- max_intrwidth = max([len(x["name"]) for x
- in m["interrupt_list"]])
+port_list = inputs + outputs + inouts
+max_sigwidth = max(len(x.name) for x in port_list) if port_list else 0
+max_intrwidth = (max(len(x.name) for x in block.interrupts)
+ if block.interrupts else 0)
%>\
% if m["param_list"]:
${m["type"]} #(
@@ -598,46 +589,44 @@
% else:
${m["type"]} u_${m["name"]} (
% endif
- % for p_in in m["available_input_list"] + m["available_inout_list"]:
+ % for p_in in inputs + inouts:
% if loop.first:
// Input
% endif
- .${lib.ljust("cio_"+p_in["name"]+"_i",max_sigwidth+9)} (cio_${m["name"]}_${p_in["name"]}_p2d),
+ .${lib.ljust("cio_"+p_in.name+"_i",max_sigwidth+9)} (cio_${m["name"]}_${p_in.name}_p2d),
% endfor
- % for p_out in m["available_output_list"] + m["available_inout_list"]:
+ % for p_out in outputs + inouts:
% if loop.first:
// Output
% endif
- .${lib.ljust("cio_"+p_out["name"]+"_o", max_sigwidth+9)} (cio_${m["name"]}_${p_out["name"]}_d2p),
- .${lib.ljust("cio_"+p_out["name"]+"_en_o",max_sigwidth+9)} (cio_${m["name"]}_${p_out["name"]}_en_d2p),
+ .${lib.ljust("cio_"+p_out.name+"_o", max_sigwidth+9)} (cio_${m["name"]}_${p_out.name}_d2p),
+ .${lib.ljust("cio_"+p_out.name+"_en_o",max_sigwidth+9)} (cio_${m["name"]}_${p_out.name}_en_d2p),
% endfor
- % for intr in m["interrupt_list"] if "interrupt_list" in m else []:
+ % for intr in block.interrupts:
% if loop.first:
// Interrupt
% endif
- .${lib.ljust("intr_"+intr["name"]+"_o",max_intrwidth+7)} (intr_${m["name"]}_${intr["name"]}),
+ .${lib.ljust("intr_"+intr.name+"_o",max_intrwidth+7)} (intr_${m["name"]}_${intr.name}),
% endfor
- % if m["alert_list"]:
+ % if block.alerts:
<%
-w = sum([x["width"] if "width" in x else 1 for x in m["alert_list"]])
+w = len(block.alerts)
slice = str(alert_idx+w-1) + ":" + str(alert_idx)
%>
- % for alert in m["alert_list"] if "alert_list" in m else []:
- % for i in range(alert["width"]):
- // [${alert_idx}]: ${alert["name"]}<% alert_idx += 1 %>
- % endfor
+ % for alert in block.alerts:
+ // [${alert_idx}]: ${alert.name}<% alert_idx += 1 %>
% endfor
.alert_tx_o ( alert_tx[${slice}] ),
.alert_rx_i ( alert_rx[${slice}] ),
% endif
## TODO: Inter-module Connection
- % if "inter_signal_list" in m:
+ % if m.get('inter_signal_list'):
// Inter-module signals
- % for sig in m["inter_signal_list"]:
+ % for sig in m['inter_signal_list']:
## TODO: handle below condition in lib.py
% if sig['type'] == "req_rsp":
.${lib.im_portname(sig,"req")}(${lib.im_netname(sig, "req")}),
@@ -682,10 +671,10 @@
.alert_rx_o ( alert_rx ),
.alert_tx_i ( alert_tx ),
% endif
- % if m["scan"] == "true":
+ % if block.scan:
.scanmode_i,
% endif
- % if m["scan_reset"] == "true":
+ % if block.scan_reset:
.scan_rst_ni (scan_rst_ni),
% endif
diff --git a/util/reggen/signal.py b/util/reggen/signal.py
index 4494871..bd4d6a3 100644
--- a/util/reggen/signal.py
+++ b/util/reggen/signal.py
@@ -49,3 +49,15 @@
'desc': self.desc,
'width': str(self.bits.width())
}
+
+ def as_nwt_dict(self, type_field: str) -> Dict[str, object]:
+ '''Return a view of the signal as a dictionary
+
+ The dictionary has fields "name", "width" and "type", the last
+ of which comes from the type_field argument. Used for topgen
+ integration.
+
+ '''
+ return {'name': self.name,
+ 'width': self.bits.width(),
+ 'type': type_field}
diff --git a/util/topgen.py b/util/topgen.py
index 21f4544..a42f6ea 100755
--- a/util/topgen.py
+++ b/util/topgen.py
@@ -44,11 +44,11 @@
SRCTREE_TOP = Path(__file__).parent.parent.resolve()
-def generate_top(top, tpl_filename, **kwargs):
+def generate_top(top, name_to_block, tpl_filename, **kwargs):
top_tpl = Template(filename=tpl_filename)
try:
- return top_tpl.render(top=top, **kwargs)
+ return top_tpl.render(top=top, name_to_block=name_to_block, **kwargs)
except: # noqa: E722
log.error(exceptions.text_error_template().render())
return ""
@@ -926,7 +926,13 @@
if error != 0:
raise SystemExit("Error occured while validating top.hjson")
- completecfg = merge_top(topcfg, ip_objs, xbar_objs)
+ name_to_block = {} # type: Dict[str, IpBlock]
+ for block in ip_objs:
+ lblock = block.name.lower()
+ assert lblock not in name_to_block
+ name_to_block[lblock] = block
+
+ completecfg = merge_top(topcfg, name_to_block, xbar_objs)
# Generate flash controller and flash memory
generate_flash(topcfg, out_path)
@@ -962,7 +968,7 @@
generate_top_ral(completecfg, ip_objs, args.dv_base_prefix, out_path)
sys.exit()
- return completecfg
+ return completecfg, name_to_block
def main():
@@ -1108,7 +1114,7 @@
cfg_copy = deepcopy(topcfg)
_process_top(cfg_copy, args, cfg_path, out_path, pass_idx)
else:
- completecfg = _process_top(topcfg, args, cfg_path, out_path, pass_idx)
+ completecfg, name_to_block = _process_top(topcfg, args, cfg_path, out_path, pass_idx)
topname = topcfg["name"]
@@ -1146,8 +1152,8 @@
def render_template(out_name_tpl, out_dir, **other_info):
top_tplpath = tpl_path / ((out_name_tpl + '.tpl') % (top_name))
- template_contents = generate_top(completecfg, str(top_tplpath),
- **other_info)
+ template_contents = generate_top(completecfg, name_to_block,
+ str(top_tplpath), **other_info)
rendered_dir = out_path / out_dir
rendered_dir.mkdir(parents=True, exist_ok=True)
@@ -1244,7 +1250,7 @@
for fname in tb_files:
tpl_fname = "%s.tpl" % (fname)
xbar_chip_data_path = tpl_path / tpl_fname
- template_contents = generate_top(completecfg,
+ template_contents = generate_top(completecfg, name_to_block,
str(xbar_chip_data_path))
rendered_dir = Path(out_path) / 'dv/autogen'
@@ -1257,7 +1263,7 @@
# generate parameters for chip-level environment package
tpl_fname = 'chip_env_pkg__params.sv.tpl'
alert_handler_chip_data_path = tpl_path / tpl_fname
- template_contents = generate_top(completecfg,
+ template_contents = generate_top(completecfg, name_to_block,
str(alert_handler_chip_data_path))
rendered_dir = Path(out_path) / 'dv/env/autogen'
diff --git a/util/topgen/intermodule.py b/util/topgen/intermodule.py
index 27df67a..1d3e083 100644
--- a/util/topgen/intermodule.py
+++ b/util/topgen/intermodule.py
@@ -6,7 +6,7 @@
import re
from collections import OrderedDict
from enum import Enum
-from typing import Dict, List, Tuple, Union
+from typing import Dict, List, Tuple
from reggen.validate import check_int
from reggen.inter_signal import InterSignal
@@ -144,15 +144,7 @@
continue
ip = ips[0]
-
- # Depending on whether ip came from reggen or topgen, it might be an
- # InterSignal object or it might be a dict. Extract the fields we need
- # so that the code below can treat it as a dict.
- isl = ip['inter_signal_list']
- if not isl or isinstance(isl[0], InterSignal):
- inter_signal_list = [signal.as_dict() for signal in isl]
- else:
- inter_signal_list = isl
+ inter_signal_list = ip['inter_signal_list']
# get the port name
def get_signame(act: str) -> OrderedDict:
@@ -208,23 +200,22 @@
instances = topcfg["module"] + topcfg["memory"] + topcfg["xbar"] + \
topcfg["host"] + topcfg["port"]
- intermodule_instances = [x for x in instances if "inter_signal_list" in x]
+ for x in instances:
+ old_isl = x.get('inter_signal_list')
+ if old_isl is None:
+ continue
- # Collect up all intermodule signals, operating in place on each of the
- # instances and converting back from an InterSignal object to a dict if
- # necessary.
- for x in intermodule_instances:
new_isl = []
- for sig in x["inter_signal_list"]:
- if isinstance(sig, InterSignal):
- sig_dict = sig.as_dict()
- else:
- sig_dict = sig
+ for entry in old_isl:
+ # Convert any InterSignal objects to the expected dictionary format.
+ sig = (entry.as_dict()
+ if isinstance(entry, InterSignal)
+ else entry.copy())
# Add instance name to the entry and add to list_of_intersignals
- sig_dict["inst_name"] = x["name"]
- list_of_intersignals.append(sig_dict)
- new_isl.append(sig_dict)
+ sig["inst_name"] = x["name"]
+ list_of_intersignals.append(sig)
+ new_isl.append(sig)
x['inter_signal_list'] = new_isl
@@ -511,15 +502,10 @@
# Validation
-def check_intermodule_field(obj: Union[InterSignal, OrderedDict],
+def check_intermodule_field(sig: OrderedDict,
prefix: str = "") -> Tuple[int, OrderedDict]:
error = 0
- if isinstance(obj, InterSignal):
- sig = obj.as_dict()
- else:
- sig = obj
-
# type check
if sig["type"] not in IM_TYPES:
log.error("{prefix} Inter_signal {name} "
@@ -792,7 +778,7 @@
struct=obj["struct"])
-def im_netname(sig: Union[InterSignal, OrderedDict],
+def im_netname(sig: OrderedDict,
suffix: str = "", default_name=False) -> str:
"""return top signal name with index
@@ -869,19 +855,22 @@
index=lib.index(obj["index"]))
-def im_portname(obj: InterSignal, suffix: str = "") -> str:
+def im_portname(obj: OrderedDict, suffix: str = "") -> str:
"""return IP's port name
e.g signame_o for requester req signal
"""
- if suffix == "":
- suffix_s = "_o" if obj['act'] == "req" else "_i"
- elif suffix == "req":
- suffix_s = "_o" if obj['act'] == "req" else "_i"
- else:
- suffix_s = "_o" if obj['act'] == "rsp" else "_i"
+ act = obj['act']
+ name = obj['name']
- return "{signame}{suffix}".format(signame=obj['name'], suffix=suffix_s)
+ if suffix == "":
+ suffix_s = "_o" if act == "req" else "_i"
+ elif suffix == "req":
+ suffix_s = "_o" if act == "req" else "_i"
+ else:
+ suffix_s = "_o" if act == "rsp" else "_i"
+
+ return name + suffix_s
def get_dangling_im_def(objs: OrderedDict) -> str:
diff --git a/util/topgen/merge.py b/util/topgen/merge.py
index 3ff5ef4..5fab49e 100644
--- a/util/topgen/merge.py
+++ b/util/topgen/merge.py
@@ -8,7 +8,7 @@
from copy import deepcopy
from functools import partial
from math import ceil, log2
-from typing import Dict, List
+from typing import Dict
from topgen import c, lib
from reggen.ip_block import IpBlock
@@ -37,7 +37,7 @@
return literal_str
-def elaborate_instances(top, blocks: List[IpBlock]):
+def elaborate_instances(top, name_to_block: Dict[str, IpBlock]):
'''Add additional fields to the elements of top['module']
These elements represent instantiations of IP blocks. This function adds
@@ -46,46 +46,24 @@
more details of what gets added.
'''
- name_to_block = {} # type: Dict[str, IpBlock]
- for block in blocks:
- lblock = block.name.lower()
- assert lblock not in name_to_block
- name_to_block[lblock] = block
-
# Initialize RNG for compile-time netlist constants.
random.seed(int(top['rnd_cnst_seed']))
- # Find the alert handler and extract the name of its clock
- alert_clock = None
- for instance in top['module']:
- if instance['type'].lower() == 'alert_handler':
- alert_clock = instance['clock_srcs']['clk_i']
- break
- assert alert_clock is not None
-
for instance in top['module']:
block = name_to_block[instance['type']]
- elaborate_instance(instance, block, alert_clock)
+ elaborate_instance(instance, block)
-def elaborate_instance(instance, block: IpBlock, alert_clock: str):
+def elaborate_instance(instance, block: IpBlock):
"""Add additional fields to a single instance of a module.
instance is the instance to be filled in. block is the block that it's
- instantiating. alert_clock is the name of the clock signal used for the
- alert handler.
+ instantiating.
Amended fields:
- - size: register space
- - bus_device
- - bus_host: none if doesn't exist
- - available_input_list: empty list if doesn't exist
- - available_output_list: empty list if doesn't exist
- - available_inout_list: empty list if doesn't exist
- - param_list: empty list if doesn't exist
- - interrupt_list: empty list if doesn't exist
- - alert_list: empty list if doesn't exist
- - wakeup_list: empty list if doesn't exist
+ - size (the number of bytes taken up in the address space)
+ - param_list (list of parameters for the instance)
+ - inter_signal_list (list of inter-module signals)
"""
mod_name = instance["name"]
@@ -103,29 +81,6 @@
"the block needs at least {} bytes."
.format(mod_name, block.name, decl_size, min_size))
- instance["bus_device"] = block.bus_device or 'none'
- instance["bus_host"] = block.bus_host or 'none'
-
- inouts, inputs, outputs = block.xputs
- instance['available_inout_list'] = [
- {'name': signal.name,
- 'width': signal.bits.width(),
- 'type': 'inout'}
- for signal in inouts
- ]
- instance['available_input_list'] = [
- {'name': signal.name,
- 'width': signal.bits.width(),
- 'type': 'input'}
- for signal in inputs
- ]
- instance['available_output_list'] = [
- {'name': signal.name,
- 'width': signal.bits.width(),
- 'type': 'output'}
- for signal in outputs
- ]
-
# param_list
new_params = []
for param in block.params.by_name.values():
@@ -175,49 +130,9 @@
instance["param_list"] = new_params
- # interrupt_list
- instance["interrupt_list"] = [
- {'name': i.name,
- 'width': i.bits.width(),
- 'type': 'interrupt'}
- for i in block.interrupts
- ]
-
- # alert_list. An alert is considered asynchronous if the clock name for the
- # instance's clk_i doesn't match alert_clock (which is the clock name for
- # the alert handler's clk_i).
- async_alerts = (instance["clock_srcs"]["clk_i"] != alert_clock)
- instance["alert_list"] = [
- {'name': i.name,
- 'type': 'alert',
- 'width': 1,
- 'async': '1' if async_alerts else '0'}
- for i in block.alerts
- ]
-
- # wkup_list
- instance["wakeup_list"] = [
- {'name': signal.name,
- 'width': str(signal.bits.width())}
- for signal in block.wakeups
- ]
-
- # reset request
- instance["reset_request_list"] = [
- {'name': signal.name,
- 'width': str(signal.bits.width())}
- for signal in block.reset_requests
- ]
-
- # scan
- instance['scan'] = 'true' if block.scan else 'false'
-
- # scan_reset
- instance['scan_reset'] = 'true' if block.scan_reset else 'false'
-
- # inter-module
- instance["inter_signal_list"] = block.inter_signals.copy()
- # TODO: validate
+ # These objects get added-to in place by code in intermodule.py, so we have
+ # to convert and copy them here.
+ instance["inter_signal_list"] = [s.as_dict() for s in block.inter_signals]
# TODO: Replace this part to be configurable from Hjson or template
@@ -723,7 +638,7 @@
return
-def amend_interrupt(top):
+def amend_interrupt(top: OrderedDict, name_to_block: Dict[str, IpBlock]):
"""Check interrupt_module if exists, or just use all modules
"""
if "interrupt_module" not in top:
@@ -733,19 +648,24 @@
top["interrupt"] = []
for m in top["interrupt_module"]:
- ip = list(filter(lambda module: module["name"] == m, top["module"]))
- if len(ip) == 0:
+ ips = list(filter(lambda module: module["name"] == m, top["module"]))
+ if len(ips) == 0:
log.warning(
"Cannot find IP %s which is used in the interrupt_module" % m)
continue
- log.info("Adding interrupts from module %s" % ip[0]["name"])
- top["interrupt"] += list(
- map(partial(lib.add_module_prefix_to_signal, module=m.lower()),
- ip[0]["interrupt_list"]))
+ ip = ips[0]
+ block = name_to_block[ip['type']]
+
+ log.info("Adding interrupts from module %s" % ip["name"])
+ for signal in block.interrupts:
+ sig_dict = signal.as_nwt_dict('interrupt')
+ qual = lib.add_module_prefix_to_signal(sig_dict,
+ module=m.lower())
+ top["interrupt"].append(qual)
-def amend_alert(top):
+def amend_alert(top: OrderedDict, name_to_block: Dict[str, IpBlock]):
"""Check interrupt_module if exists, or just use all modules
"""
if "alert_module" not in top:
@@ -754,20 +674,35 @@
if "alert" not in top or top["alert"] == "":
top["alert"] = []
+ # Find the alert handler and extract the name of its clock
+ alert_clock = None
+ for instance in top['module']:
+ if instance['type'].lower() == 'alert_handler':
+ alert_clock = instance['clock_srcs']['clk_i']
+ break
+ assert alert_clock is not None
+
for m in top["alert_module"]:
- ip = list(filter(lambda module: module["name"] == m, top["module"]))
- if len(ip) == 0:
+ ips = list(filter(lambda module: module["name"] == m, top["module"]))
+ if len(ips) == 0:
log.warning("Cannot find IP %s which is used in the alert_module" %
m)
continue
- log.info("Adding alert from module %s" % ip[0]["name"])
- top["alert"] += list(
- map(partial(lib.add_module_prefix_to_signal, module=m.lower()),
- ip[0]["alert_list"]))
+ ip = ips[0]
+ block = name_to_block[ip['type']]
+
+ log.info("Adding alert from module %s" % ip["name"])
+ has_async_alerts = ip['clock_srcs']['clk_i'] != alert_clock
+ for alert in block.alerts:
+ alert_dict = alert.as_nwt_dict('alert')
+ alert_dict['async'] = '1' if has_async_alerts else '0'
+ qual_sig = lib.add_module_prefix_to_signal(alert_dict,
+ module=m.lower())
+ top["alert"].append(qual_sig)
-def amend_wkup(topcfg: OrderedDict):
+def amend_wkup(topcfg: OrderedDict, name_to_block: Dict[str, IpBlock]):
pwrmgr_name = _find_module_name(topcfg['module'], 'pwrmgr')
@@ -777,11 +712,14 @@
# create list of wakeup signals
for m in topcfg["module"]:
log.info("Adding wakeup from module %s" % m["name"])
- for entry in m["wakeup_list"]:
- log.info("Adding singal %s" % entry["name"])
- signal = deepcopy(entry)
- signal["module"] = m["name"]
- topcfg["wakeups"].append(signal)
+ block = name_to_block[m['type']]
+ for signal in block.wakeups:
+ log.info("Adding signal %s" % signal.name)
+ topcfg["wakeups"].append({
+ 'name': signal.name,
+ 'width': str(signal.bits.width()),
+ 'module': m["name"]
+ })
# add wakeup signals to pwrmgr connections
signal_names = [
@@ -795,7 +733,8 @@
# Handle reset requests from modules
-def amend_reset_request(topcfg: OrderedDict):
+def amend_reset_request(topcfg: OrderedDict,
+ name_to_block: Dict[str, IpBlock]):
pwrmgr_name = _find_module_name(topcfg['module'], 'pwrmgr')
@@ -805,11 +744,14 @@
# create list of reset signals
for m in topcfg["module"]:
log.info("Adding reset requests from module %s" % m["name"])
- for entry in m["reset_request_list"]:
- log.info("Adding singal %s" % entry["name"])
- signal = deepcopy(entry)
- signal["module"] = m["name"]
- topcfg["reset_requests"].append(signal)
+ block = name_to_block[m['type']]
+ for signal in block.reset_requests:
+ log.info("Adding signal %s" % signal.name)
+ topcfg["reset_requests"].append({
+ 'name': signal.name,
+ 'width': str(signal.bits.width()),
+ 'module': m["name"]
+ })
# add reset requests to pwrmgr connections
signal_names = [
@@ -822,7 +764,7 @@
topcfg["inter_module"]["connect"]))
-def amend_pinmux_io(top):
+def amend_pinmux_io(top: OrderedDict, name_to_block: Dict[str, IpBlock]):
""" Check dio_modules/ mio_modules. If not exists, add all modules to mio
"""
pinmux = top["pinmux"]
@@ -847,9 +789,11 @@
signals = deepcopy([lib.get_signal_by_name(m, sname)])
else:
# Get all module signals
- signals = deepcopy(m["available_input_list"] +
- m["available_output_list"] +
- m["available_inout_list"])
+ block = name_to_block[m['type']]
+ inouts, inputs, outputs = block.xputs
+ signals = ([s.as_nwt_dict('input') for s in inputs] +
+ [s.as_nwt_dict('output') for s in outputs] +
+ [s.as_nwt_dict('inout') for s in inouts])
sig_width = sum([s["width"] for s in signals])
@@ -911,36 +855,29 @@
if m is None:
raise SystemExit("Module {} doesn't exist".format(tokens[0]))
- if len(tokens) == 1:
- pinmux["inputs"] += list(
- filter(
- lambda x: x["name"] not in dio_names,
- map(
- partial(lib.add_module_prefix_to_signal,
- module=m["name"].lower()),
- m["available_inout_list"])))
- pinmux["inputs"] += list(
- filter(
- lambda x: x["name"] not in dio_names,
- map(
- partial(lib.add_module_prefix_to_signal,
- module=m["name"].lower()),
- m["available_input_list"])))
+ mod_name = m['name'].lower()
- pinmux["outputs"] += list(
- filter(
- lambda x: x["name"] not in dio_names,
- map(
- partial(lib.add_module_prefix_to_signal,
- module=m["name"].lower()),
- m["available_inout_list"])))
- pinmux["outputs"] += list(
- filter(
- lambda x: x["name"] not in dio_names,
- map(
- partial(lib.add_module_prefix_to_signal,
- module=m["name"].lower()),
- m["available_output_list"])))
+ if len(tokens) == 1:
+ block = name_to_block[m['type']]
+ inouts, inputs, outputs = block.xputs
+ for signal in inouts:
+ rel = signal.as_nwt_dict('inout')
+ qual = lib.add_module_prefix_to_signal(rel, mod_name)
+ if qual['name'] not in dio_names:
+ pinmux['inputs'].append(qual)
+ pinmux['outputs'].append(qual)
+
+ for signal in inputs:
+ rel = signal.as_nwt_dict('input')
+ qual = lib.add_module_prefix_to_signal(rel, mod_name)
+ if qual['name'] not in dio_names:
+ pinmux['inputs'].append(qual)
+
+ for signal in outputs:
+ rel = signal.as_nwt_dict('output')
+ qual = lib.add_module_prefix_to_signal(rel, mod_name)
+ if qual['name'] not in dio_names:
+ pinmux['outputs'].append(qual)
elif len(tokens) == 2:
# Current version doesn't consider signal in mio_modules
@@ -951,11 +888,11 @@
def merge_top(topcfg: OrderedDict,
- blocks: List[IpBlock],
+ name_to_block: Dict[str, IpBlock],
xbarobjs: OrderedDict) -> OrderedDict:
# Combine ip cfg into topcfg
- elaborate_instances(topcfg, blocks)
+ elaborate_instances(topcfg, name_to_block)
# Create clock connections for each block
# Assign clocks into appropriate groups
@@ -964,18 +901,18 @@
# amend_clocks(topcfg)
# Combine the wakeups
- amend_wkup(topcfg)
- amend_reset_request(topcfg)
+ amend_wkup(topcfg, name_to_block)
+ amend_reset_request(topcfg, name_to_block)
# Combine the interrupt (should be processed prior to xbar)
- amend_interrupt(topcfg)
+ amend_interrupt(topcfg, name_to_block)
# Combine the alert (should be processed prior to xbar)
- amend_alert(topcfg)
+ amend_alert(topcfg, name_to_block)
# Creates input/output list in the pinmux
log.info("Processing PINMUX")
- amend_pinmux_io(topcfg)
+ amend_pinmux_io(topcfg, name_to_block)
# Combine xbar into topcfg
for xbar in xbarobjs: