diff --git a/backend/api/peripherals.py b/backend/api/peripherals.py index dfbf5fd7..5dabef0e 100644 --- a/backend/api/peripherals.py +++ b/backend/api/peripherals.py @@ -118,13 +118,19 @@ def get_schema(cls, peripheral_type) -> Type: elif peripheral_type == PeripheralType.FPGA_COMPLEX: return FpgaComplexSchema else: - return PeripheralSchema + return DefaultPeripheralSchema @classmethod def create_schema(cls, peripheral_type): schema_ctor = cls.get_schema(peripheral_type) return schema_ctor() +class DummyOutputSchema(Schema): + pass + +class DefaultPeripheralSchema(PeripheralSchema): + output = fields.Nested(DummyOutputSchema, data_key="consumption") + class SpiSchema(PeripheralSchema): enable = fields.Bool() usage = fields.Enum(Peripherals_Usage, by_value=True) @@ -190,9 +196,6 @@ class MemorySchema(PeripheralSchema): width = fields.Int() output = fields.Nested(MemoryOutputSchema, data_key="consumption") -class DummyOutputSchema(Schema): - pass - class ChannelOutputSchema(Schema): calculated_bandwidth = fields.Number() noc_power = fields.Number() diff --git a/backend/etc/devices/mpw1/clocking.json b/backend/etc/devices/mpw1/clocking.json index cf3c63a2..967a587d 100644 --- a/backend/etc/devices/mpw1/clocking.json +++ b/backend/etc/devices/mpw1/clocking.json @@ -5,5 +5,17 @@ { "name": "CLK_INT_CAP", "value": 0.00000003 }, { "name": "PLL_INT" , "value": 0.0009 }, { "name": "PLL_AUX" , "value": 0.01 } + ], + "static_power": [ + { + "rail_type": "Vcc_aux", + "domain": "SOC", + "scenarios": [ + { "type": "worse", "coeffs": [0.00000001, -0.0000003, 0.00004, 0.0332], "factor": 0.555555555555556 }, + { "type": "worse", "coeffs": [0.000000002, 0.0000004, 0.00002, 0.0133], "factor": 0.555555555555556 }, + { "type": "typical", "coeffs": [0.000000003, 0.0000002, 0.00004, 0.0224], "factor": 0.555555555555556 }, + { "type": "typical", "coeffs": [0.0000000004, 0.0000001, 0.000005, 0.0033], "factor": 0.555555555555556 } + ] + } ] } diff --git a/backend/etc/devices/mpw1/gearbox_hp.json b/backend/etc/devices/mpw1/gearbox_hp.json new file mode 100644 index 00000000..8966b36a --- /dev/null +++ b/backend/etc/devices/mpw1/gearbox_hp.json @@ -0,0 +1,53 @@ +{ + "type": "gearbox_hp", + "static_power": [ + { + "rail_type": "Vcc_core (Gearbox HP)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.00000000003, -0.0000000006, 0.000000001, 0.000006, 0.0002], "factor": 1.0 }, + { "type": "typical", "coeffs": [0.00000000002, -0.000000001, 0.00000001, 0.000004, 0.00005], "factor": 1.0 } + ] + }, + { + "rail_type": "Vcc_core (HP I/O)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.0001], "factor": 1.0 }, + { "type": "typical", "coeffs": [0.00005], "factor": 1.0 } + ] + }, + { + "rail_type": "Vcc_hv_aux", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], "factor": 1.0 }, + { "type": "typical", "coeffs": [0.000000001, 0.0000002, 0.00021, 0.0003], "factor": 1.0 } + ] + }, + { + "rail_type": "Vcc_hp_io (1.2V)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], "factor": 1.25 }, + { "type": "typical", "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], "factor": 1.25 } + ] + }, + { + "rail_type": "Vcc_hp_io (1.5V)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], "factor": 1.25 }, + { "type": "typical", "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], "factor": 1.25 } + ] + }, + { + "rail_type": "Vcc_hp_io (1.8V)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], "factor": 1.25 }, + { "type": "typical", "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], "factor": 1.25 } + ] + } + ] +} diff --git a/backend/etc/devices/mpw1/gearbox_hr.json b/backend/etc/devices/mpw1/gearbox_hr.json new file mode 100644 index 00000000..d9f02525 --- /dev/null +++ b/backend/etc/devices/mpw1/gearbox_hr.json @@ -0,0 +1,53 @@ +{ + "type": "gearbox_hr", + "static_power": [ + { + "rail_type": "Vcc_core (Gearbox HR)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.00000000003, -0.0000000007, 0.000000001, 0.000007, 0.0002], "factor": 1.0 }, + { "type": "typical", "coeffs": [0.00000000003, -0.0000000008, 0.000000001, 0.000008, 0.0002], "factor": 1.0 } + ] + }, + { + "rail_type": "Vcc_core (HR I/O)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.00005], "factor": 1.0 }, + { "type": "typical", "coeffs": [0.00001], "factor": 1.0 } + ] + }, + { + "rail_type": "Vcc_hr_aux", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], "factor": 1.0 }, + { "type": "typical", "coeffs": [0.000000001, 0.0000002, 0.00021, 0.0003], "factor": 1.0 } + ] + }, + { + "rail_type": "Vcc_hr_io (1.8V)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.00001], "factor": 1.25 }, + { "type": "typical", "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], "factor": 1.25 } + ] + }, + { + "rail_type": "Vcc_hr_io (2.5V)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], "factor": 1.25 }, + { "type": "typical", "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], "factor": 1.25 } + ] + }, + { + "rail_type": "Vcc_hr_io (3.3V)", + "domain": "Core", + "scenarios": [ + { "type": "worse", "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], "factor": 1.25 }, + { "type": "typical", "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], "factor": 1.25 } + ] + } + ] +} diff --git a/backend/etc/devices/mpw1/power_data.json b/backend/etc/devices/mpw1/power_data.json index 1d9f13eb..a3ce584c 100644 --- a/backend/etc/devices/mpw1/power_data.json +++ b/backend/etc/devices/mpw1/power_data.json @@ -20,6 +20,8 @@ { "$ref": "noc.json" }, { "$ref": "puffcc.json" }, { "$ref": "rc_osc.json" }, + { "$ref": "gearbox_hp.json" }, + { "$ref": "gearbox_hr.json" }, { "$ref": "regulator.json" } ] } diff --git a/backend/etc/devices/mpw1/static_power_data.json b/backend/etc/devices/mpw1/static_power_data.json deleted file mode 100644 index e3d78f86..00000000 --- a/backend/etc/devices/mpw1/static_power_data.json +++ /dev/null @@ -1,787 +0,0 @@ -[ - { - "type": "clb", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 6, - "coeffs": [0.000000000000002, -0.0000000000001, 0.00000000001, 0.0000000008, 0.00000006, 0.000002], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.0000000000003, -0.00000000001, 0.0000000001, 0.00000006, 0.0000007], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "bram", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000004, 0.00001], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "dsp", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000002, -0.00000000004, 0.00000000008, 0.0000005, 0.00001], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000002, -0.00000000008, 0.0000000007, 0.0000003, 0.000004], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "aux", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.00000001, -0.0000003, 0.00004, 0.0332], - "factor": 0.555555555555556 - }, - { - "length": 4, - "coeffs": [0.000000002, 0.0000004, 0.00002, 0.0133], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.000000003, 0.0000002, 0.00004, 0.0224], - "factor": 0.555555555555556 - }, - { - "length": 4, - "coeffs": [0.0000000004, 0.0000001, 0.000005, 0.0033], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "noc", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.00000000005, -0.000000001, 0.000000002, 0.00001, 0.0003], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.00000000003, -0.000000001, 0.00000001, 0.000005, 0.00006], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "mem_ss", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.0000000001, -0.000000003, 0.000000005, 0.00003, 0.0009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.0000000001, -0.000000006, 0.00000005, 0.00002, 0.0003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "acpu", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 6, - "coeffs": [0.00000000000008, -0.000000000004, 0.0000000004, 0.00000003, 0.000002, 0.00008], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000006, -0.000000000006, -0.000000005, 0.0000007, 0.00002], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "config", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.0000000001, -0.000000002, 0.000000004, 0.00002, 0.0007], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 6, - "coeffs": [0.0000000000005, -0.00000000002, 0.000000003, 0.0000002, 0.00001, 0.0013], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "vcc_boot_io", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "vcc_ddr_io", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "vcc_soc_io", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "vcc_gige_io", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "vcc_usb_io", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "vcc_boot_aux", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "vcc_soc_aux", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "vcc_gige_aux", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "vcc_usb_aux", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.000000001, 0.0000002, 0.00021, 0.0003], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "vcc_puf", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 1, - "coeffs": [0.001], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 1, - "coeffs": [0.0005], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "vcc_rc_osc", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 1, - "coeffs": [0.0005], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 1, - "coeffs": [0.0001], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "gearbox_io_hp", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.00000000003, -0.0000000006, 0.000000001, 0.000006, 0.0002], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.00000000002, -0.000000001, 0.00000001, 0.000004, 0.00005], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "gearbox_io_hr", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.00000000003, -0.0000000007, 0.000000001, 0.000007, 0.0002], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.00000000003, -0.0000000008, 0.000000001, 0.000008, 0.0002], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hp", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 1, - "coeffs": [0.0001], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 1, - "coeffs": [0.00005], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hr", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 1, - "coeffs": [0.00005], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 1, - "coeffs": [0.00001], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "aux_hp", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.000000001, 0.0000002, 0.00021, 0.0003], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "aux_hr", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 4, - "coeffs": [0.0000000008, 0.0000002, 0.00001, 0.007], - "factor": 0.555555555555556 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 4, - "coeffs": [0.000000001, 0.0000002, 0.00021, 0.0003], - "factor": 0.555555555555556 - } - ] - } - ] - }, - { - "type": "io_hp_1_2v", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hp_1_5v", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hp_1_8v", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hr_1_8v", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.00001], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hr_2_5v", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - }, - { - "type": "io_hr_3_3v", - "scenarios": [ - { - "type": "worse", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000003, 0.00000000006, 0.0000003, 0.000009], - "factor": 1.25 - } - ] - }, - { - "type": "typical", - "polynomials": [ - { - "length": 5, - "coeffs": [0.000000000001, -0.00000000006, 0.0000000005, 0.0000002, 0.000003], - "factor": 1.25 - } - ] - } - ] - } -] diff --git a/backend/submodule/clock.py b/backend/submodule/clock.py index 2615b8e3..49aac29f 100644 --- a/backend/submodule/clock.py +++ b/backend/submodule/clock.py @@ -4,11 +4,13 @@ # from dataclasses import dataclass, field from typing import List +import numpy as np from utilities.common_utils import RsEnum, update_attributes -from .rs_device_resources import ModuleType, ClockNotFoundException, \ - ClockDescriptionPortValidationException, \ - ClockMaxCountReachedException +from .rs_device_resources import ModuleType, ClockNotFoundException, ClockDescriptionPortValidationException, \ + ClockMaxCountReachedException, RsDeviceResources from .rs_message import RsMessage, RsMessageManager +from .rs_power_config import ElementType, PowerValue, ScenarioType +from .rs_logger import RsLogLevel, log class Clock_State(RsEnum): ACTIVE = 1, "Active" @@ -65,7 +67,7 @@ def compute_dynamic_power(self, fan_out, CLK_CAP, CLK_INT_CAP): class Clock_SubModule: - def __init__(self, resources, itemlist: List[Clock] = None): + def __init__(self, resources: RsDeviceResources, itemlist: List[Clock] = None): self.resources = resources self.total_clock_available = resources.get_num_Clocks() self.total_pll_available = resources.get_num_PLLs() @@ -191,3 +193,25 @@ def compute_output_power(self): total_power = self.total_block_power + self.total_interconnect_power + self.total_pll_power for item in self.itemlist: item.compute_percentage(total_power) + + def compute_static_power(self, temperature: float, scenario: ScenarioType) -> float: + VCC_AUX = self.resources.get_VCC_AUX() + mylist = [] + + for rail_type, scene_list in self.resources.powercfg.get_polynomial(ElementType.CLOCKING, scenario): + total_power = 0.0 + for s in scene_list: + power = np.polyval(s.coeffs, temperature) * s.factor * VCC_AUX + total_power += power + # debug info + log(f'[CLOCK] {rail_type = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {temperature = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {scenario = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {s.coeffs = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {s.factor = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {VCC_AUX = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {power = }', RsLogLevel.DEBUG) + log(f'[CLOCK] {total_power = }', RsLogLevel.DEBUG) + mylist.append(PowerValue(type=rail_type, value=total_power)) + + return mylist diff --git a/backend/submodule/peripherals.py b/backend/submodule/peripherals.py index c564fda8..8950e6ac 100644 --- a/backend/submodule/peripherals.py +++ b/backend/submodule/peripherals.py @@ -9,7 +9,7 @@ from enum import IntFlag from typing import Any, List, Dict, Tuple from utilities.common_utils import RsEnum, update_attributes -from .rs_device_resources import IO_Standard, IO_Standard_Coeff, ModuleType, PeripheralPortNotFoundException, RsDeviceResources, PeripheralNotFoundException, PeripheralType +from .rs_device_resources import IO_BankType, IO_Standard, IO_Standard_Coeff, ModuleType, PeripheralPortNotFoundException, RsDeviceResources, PeripheralNotFoundException, PeripheralType from .rs_power_config import ElementType, PowerValue, ScenarioType from .rs_message import RsMessage, RsMessageManager from .rs_logger import log, RsLogLevel @@ -216,6 +216,8 @@ def initialize_peripherals(self) -> List['Peripheral']: peripherals += self.create_peripherals(1, 'N22 RISC-V', PeripheralType.BCPU) peripherals += self.create_peripherals(1, 'Fabric', PeripheralType.FPGA_COMPLEX) peripherals += self.create_peripherals(1, 'GPIO', PeripheralType.GPIO) + peripherals += self.create_peripherals(1, 'Gearbox HP', PeripheralType.GEARBOX_HP) + peripherals += self.create_peripherals(1, 'Gearbox HR', PeripheralType.GEARBOX_HR) peripherals += self.create_peripherals(1, 'PUFFcc', PeripheralType.PUFFCC) peripherals += self.create_peripherals(1, 'RC Oscillator', PeripheralType.RC_OSC) peripherals += self.create_peripherals(1, 'NOC', PeripheralType.NOC) @@ -464,6 +466,10 @@ def get_compute_object(cls, type: PeripheralType, context: IPeripheral) -> 'Comp return RCOsc0(context=context) elif type == PeripheralType.NOC: return Noc0(context=context) + elif type == PeripheralType.GEARBOX_HP: + return Gearbox_HP_0(context=context) + elif type == PeripheralType.GEARBOX_HR: + return Gearbox_HR_0(context=context) return None @dataclass @@ -1695,6 +1701,94 @@ def compute_static_power(self, temperature: float, scenario: ScenarioType) -> Li return mylist +@dataclass +class Gearbox_HP_0(ComputeObject): + def get_hp_io_banks_used(self, voltage: float = None) -> int: + num_banks = 0 + io = self.get_context().get_device_resources().get_module(ModuleType.IO) + for elem in io.io_usage: + if elem.type == IO_BankType.HP: + for item in elem.usage: + if voltage is None or item.voltage == voltage: + num_banks += item.banks_used + break + return num_banks + + def compute_static_power(self, temperature: float, scenario: ScenarioType) -> List[PowerValue]: + resources = self.get_context().get_device_resources() + IO_BANKS = resources.get_num_HP_Banks() + io_banks_voltages = { + "Vcc_core (Gearbox HP)": IO_BANKS, + "Vcc_core (HP I/O)" : IO_BANKS, + "Vcc_hv_aux" : self.get_hp_io_banks_used(), + "Vcc_hp_io (1.2V)" : self.get_hp_io_banks_used(1.2) * 20 * 1.2, + "Vcc_hp_io (1.5V)" : self.get_hp_io_banks_used(1.5) * 20 * 1.5, + "Vcc_hp_io (1.8V)" : self.get_hp_io_banks_used(1.8) * 20 * 1.8 + } + mylist = [] + + for rail_type, scene_list in resources.powercfg.get_polynomial(ElementType.GEARBOX_HP, scenario): + total_power = 0.0 + for s in scene_list: + power = np.polyval(s.coeffs, temperature) * s.factor * io_banks_voltages.get(rail_type, 0) + total_power += power + # debug info + log(f'[GEARBOX_HP] {rail_type = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {temperature = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {scenario = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {s.coeffs = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {s.factor = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {io_banks_voltages = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {power = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HP] {total_power = }', RsLogLevel.DEBUG) + mylist.append(PowerValue(type=rail_type, value=total_power)) + + return mylist + +@dataclass +class Gearbox_HR_0(ComputeObject): + def get_hr_io_banks_used(self, voltage: float = None) -> int: + num_banks = 0 + io = self.get_context().get_device_resources().get_module(ModuleType.IO) + for elem in io.io_usage: + if elem.type == IO_BankType.HR: + for item in elem.usage: + if voltage is None or item.voltage == voltage: + num_banks += item.banks_used + break + return num_banks + + def compute_static_power(self, temperature: float, scenario: ScenarioType) -> List[PowerValue]: + resources = self.get_context().get_device_resources() + IO_BANKS = resources.get_num_HR_Banks() + io_banks_voltages = { + "Vcc_core (Gearbox HR)": IO_BANKS, + "Vcc_core (HR I/O)" : IO_BANKS, + "Vcc_hr_aux" : self.get_hr_io_banks_used(), + "Vcc_hr_io (1.8V)" : self.get_hr_io_banks_used(1.8) * 20 * 1.8, + "Vcc_hr_io (2.5V)" : self.get_hr_io_banks_used(2.5) * 20 * 2.5, + "Vcc_hr_io (3.3V)" : self.get_hr_io_banks_used(3.3) * 20 * 3.3 + } + mylist = [] + + for rail_type, scene_list in resources.powercfg.get_polynomial(ElementType.GEARBOX_HR, scenario): + total_power = 0.0 + for s in scene_list: + power = np.polyval(s.coeffs, temperature) * s.factor * io_banks_voltages.get(rail_type, 0) + total_power += power + # debug info + log(f'[GEARBOX_HR] {rail_type = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {temperature = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {scenario = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {s.coeffs = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {s.factor = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {io_banks_voltages = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {power = }', RsLogLevel.DEBUG) + log(f'[GEARBOX_HR] {total_power = }', RsLogLevel.DEBUG) + mylist.append(PowerValue(type=rail_type, value=total_power)) + + return mylist + @dataclass class Noc0(ComputeObject): def compute_static_power(self, temperature: float, scenario: ScenarioType) -> List[PowerValue]: diff --git a/backend/submodule/rs_device.py b/backend/submodule/rs_device.py index ab8df260..9d429524 100644 --- a/backend/submodule/rs_device.py +++ b/backend/submodule/rs_device.py @@ -276,104 +276,10 @@ def get_power_consumption(self): def update_spec(self, data): return update_attributes(self.specification, data) - def get_io_banks_used(self, bank_type : IO_BankType, voltage : float = None) -> int: - num_banks = 0 - iomod = self.get_module(ModuleType.IO) - for elem in iomod.io_usage: - if elem.type == bank_type: - for item in elem.usage: - if voltage is None or item.voltage == voltage: - num_banks += item.banks_used - break - return num_banks - - def get_io_banks(self, bank_type : IO_BankType) -> int: - if bank_type == IO_BankType.HP: - return self.resources.get_num_HP_Banks() - else: - return self.resources.get_num_HR_Banks() - - def calculate(self, temperature : float, coeffs : List[List[float]], factor : float = 1.0) -> float: - total = 0.0 - for co in coeffs: - values = np.polyval(co, [temperature]) - total += values[0] - return total * factor - - def compute_Gearbox_IO_bank_type(self, temperature : float, bank_type : IO_BankType, worsecase : bool) -> float: - divfactor, coeff = self.resources.get_divfactor_coeff_GEARBOX_IO_bank_type(bank_type.value, worsecase) - power = self.calculate(temperature, coeff) - num_banks = self.get_io_banks(bank_type) - total_power = num_banks * power - return total_power - - def compute_IO_bank_type(self, temperature : float, bank_type : IO_BankType, worsecase : bool) -> float: - divfactor, coeff = self.resources.get_divfactor_coeff_IO_bank_type(bank_type.value, worsecase) - power = self.calculate(temperature, coeff) - num_banks = self.get_io_banks(bank_type) - total_power = num_banks * power - return total_power - - def compute_Aux(self, temperature : float, worsecase : bool) -> float: - divfactor, coeff = self.resources.get_divfactor_coeff_AUX(worsecase) - power = self.calculate(temperature, coeff, self.resources.get_VCC_AUX() / divfactor) - return power - - def compute_Aux_IO_bank_type(self, temperature : float, bank_type : IO_BankType, worsecase : bool) -> float: - divfactor, coeff = self.resources.get_divfactor_coeff_Aux_bank_type(bank_type.value, worsecase) - power = self.calculate(temperature, coeff) - num_io_banks_used = self.get_io_banks_used(bank_type) - total_power = power * num_io_banks_used - return total_power - - def compute_IO_bank_type_voltage(self, temperature : float, bank_type : IO_BankType, voltage : float, worsecase : bool) -> float: - divfactor, coeff = self.resources.get_divfactor_coeff_IO_bank_type_voltage(bank_type.value, voltage, worsecase) - power = self.calculate(temperature, coeff) - num_io_banks_used = self.get_io_banks_used(bank_type, voltage) - total_power = power * num_io_banks_used * 20 * voltage / divfactor - return total_power - - def compute_OBSOLETE(self, temperature : float, worsecase : bool = True) -> StaticPowerResult: - result = StaticPowerResult( - temperature = temperature, - # NOC = self.compute_NOC(temperature, worsecase), - # Mem_SS = self.compute_Mem_SS(temperature, worsecase), - # A45 = self.compute_A45(temperature, worsecase), - # Config = self.compute_Config(temperature, worsecase), - # CLB = self.compute_CLB(temperature, worsecase), - # BRAM = self.compute_BRAM(temperature, worsecase), - # DSP = self.compute_DSP(temperature, worsecase), - Gearbox_HP = self.compute_Gearbox_IO_bank_type(temperature, IO_BankType.HP, worsecase), - Gearbox_HR = self.compute_Gearbox_IO_bank_type(temperature, IO_BankType.HR, worsecase), - HP_IO = self.compute_IO_bank_type(temperature, IO_BankType.HP, worsecase), - HR_IO = self.compute_IO_bank_type(temperature, IO_BankType.HR, worsecase), - Aux = self.compute_Aux(temperature, worsecase), - HP_Aux = self.compute_Aux_IO_bank_type(temperature, IO_BankType.HP, worsecase), - HR_Aux = self.compute_Aux_IO_bank_type(temperature, IO_BankType.HR, worsecase), - HR_IO_1_8V = self.compute_IO_bank_type_voltage(temperature, IO_BankType.HR, 1.8, worsecase), - HR_IO_2_5V = self.compute_IO_bank_type_voltage(temperature, IO_BankType.HR, 2.5, worsecase), - HR_IO_3_3V = self.compute_IO_bank_type_voltage(temperature, IO_BankType.HR, 3.3, worsecase), - HP_IO_1_2V = self.compute_IO_bank_type_voltage(temperature, IO_BankType.HP, 1.2, worsecase), - HP_IO_1_5V = self.compute_IO_bank_type_voltage(temperature, IO_BankType.HP, 1.5, worsecase), - HP_IO_1_8V = self.compute_IO_bank_type_voltage(temperature, IO_BankType.HP, 1.8, worsecase), - # VCC_BOOT_IO = self.compute_VCC_BOOT_IO(temperature, worsecase), - # VCC_DDR_IO = self.compute_VCC_DDR_IO(temperature, worsecase), - # VCC_SOC_IO = self.compute_VCC_SOC_IO(temperature, worsecase), - # VCC_GIGE_IO = self.compute_VCC_GIGE_IO(temperature, worsecase), - # VCC_USB_IO = self.compute_VCC_USB_IO(temperature, worsecase), - # VCC_BOOT_AUX = self.compute_VCC_BOOT_AUX(temperature, worsecase), - # VCC_SOC_AUX = self.compute_VCC_SOC_AUX(temperature, worsecase), - # VCC_GIGE_AUX = self.compute_VCC_GIGE_AUX(temperature, worsecase), - # VCC_USB_AUX = self.compute_VCC_USB_AUX(temperature, worsecase), - # VCC_RC_OSC = self.compute_VCC_RC_OSC(temperature, worsecase), - # VCC_PUF = self.compute_VCC_PUF(temperature, worsecase) - ) - return result - def compute(self, temperature: float, scenerio: ScenarioType) -> StaticPowerResult: # compute fabric/fpga static power power = StaticPowerResult() - for modtype in (ModuleType.FABRIC_LE, ModuleType.BRAM, ModuleType.DSP): + for modtype in (ModuleType.FABRIC_LE, ModuleType.BRAM, ModuleType.DSP, ModuleType.CLOCKING): power.add(self.get_module(modtype).compute_static_power(temperature, scenerio)) # compute processin/peripheral static power diff --git a/backend/submodule/rs_device_resources.py b/backend/submodule/rs_device_resources.py index dcf97a20..250b8c43 100644 --- a/backend/submodule/rs_device_resources.py +++ b/backend/submodule/rs_device_resources.py @@ -103,6 +103,8 @@ class PeripheralType(Enum): PUFFCC = 'puffcc' RC_OSC = 'rc_osc' NOC = 'noc' + GEARBOX_HP = 'gearbox_hp' + GEARBOX_HR = 'gearbox_hr' class IO_BankType(RsEnum): HP = 0, "HP" @@ -531,39 +533,6 @@ def get_SRAM_READ_FACTOR(self) -> float: def get_SRAM_ACLK_FACTOR(self) -> float: return self.powercfg.get_coeff(ElementType.SRAM, 'SRAM_ACLK_FACTOR') - def get_polynomial_coeff(self, type: ElementType, worse: bool): - polynomials = self.powercfg.get_polynomial_coeff(type, ScenarioType.WORSE if worse else ScenarioType.TYPICAL) - coeffs = [c.coeffs[:c.length] for c in polynomials] - return 1/polynomials[0].factor, coeffs - - def get_divfactor_coeff_GEARBOX_IO_bank_type(self, bank_type : int, worsecase : bool): - return self.get_polynomial_coeff(ElementType.GEARBOX_IO_HP if bank_type == 0 else ElementType.GEARBOX_IO_HR, worsecase) - - def get_divfactor_coeff_IO_bank_type(self, bank_type : int, worsecase : bool): - return self.get_polynomial_coeff(ElementType.IO_HP if bank_type == 0 else ElementType.IO_HR, worsecase) - - def get_divfactor_coeff_AUX(self, worsecase : bool): - return self.get_polynomial_coeff(ElementType.AUX, worsecase) - - def get_divfactor_coeff_Aux_bank_type(self, bank_type: int, worsecase: bool): - return self.get_polynomial_coeff(ElementType.AUX_HP if bank_type == 0 else ElementType.AUX_HR, worsecase) - - def get_divfactor_coeff_IO_bank_type_voltage(self, bank_type : int, voltage : float, worsecase : bool = True): - if bank_type == 1: # HR - if voltage == 1.8: - return self.get_polynomial_coeff(ElementType.IO_HR_1_8V, worsecase) - elif voltage == 2.5: - return self.get_polynomial_coeff(ElementType.IO_HR_2_5V, worsecase) - elif voltage == 3.3: - return self.get_polynomial_coeff(ElementType.IO_HR_3_3V, worsecase) - elif bank_type == 0: # HP - if voltage == 1.2: - return self.get_polynomial_coeff(ElementType.IO_HP_1_2V, worsecase) - elif voltage == 1.5: - return self.get_polynomial_coeff(ElementType.IO_HP_1_5V, worsecase) - elif voltage == 1.8: - return self.get_polynomial_coeff(ElementType.IO_HP_1_8V, worsecase) - def register_module(self, modtype, module): self.modules[modtype.value] = module return module diff --git a/backend/submodule/rs_power_config.py b/backend/submodule/rs_power_config.py index d87f0e34..79eb00f8 100644 --- a/backend/submodule/rs_power_config.py +++ b/backend/submodule/rs_power_config.py @@ -39,34 +39,7 @@ class ElementType(Enum): FABRIC_LE = 'fabric_le' IO = 'io' NOC = 'noc' - CLB = 'clb' - AUX = 'aux' - MEM_SS = 'mem_ss' ACPU = 'acpu' - CONFIG = 'config' - VCC_BOOT_IO = 'vcc_boot_io' - VCC_DDR_IO = 'vcc_ddr_io' - VCC_SOC_IO = 'vcc_soc_io' - VCC_GIGE_IO = 'vcc_gige_io' - VCC_USB_IO = 'vcc_usb_io' - VCC_BOOT_AUX = 'vcc_boot_aux' - VCC_SOC_AUX = 'vcc_soc_aux' - VCC_GIGE_AUX = 'vcc_gige_aux' - VCC_USB_AUX = 'vcc_usb_aux' - VCC_PUF = 'vcc_puf' - VCC_RC_OSC = 'vcc_rc_osc' - GEARBOX_IO_HP = 'gearbox_io_hp' - GEARBOX_IO_HR = 'gearbox_io_hr' - AUX_HP = 'aux_hp' - AUX_HR = 'aux_hr' - IO_HP = 'io_hp' - IO_HR = 'io_hr' - IO_HP_1_2V = 'io_hp_1_2v' - IO_HP_1_5V = 'io_hp_1_5v' - IO_HP_1_8V = 'io_hp_1_8v' - IO_HR_1_8V = 'io_hr_1_8v' - IO_HR_2_5V = 'io_hr_2_5v' - IO_HR_3_3V = 'io_hr_3_3v' UART = 'uart' SPI = 'spi' BCPU = 'bcpu' @@ -81,6 +54,8 @@ class ElementType(Enum): REGULATOR = 'regulator' PUFFCC = 'puffcc' RC_OSC = 'rc_osc' + GEARBOX_HP = 'gearbox_hp' + GEARBOX_HR = 'gearbox_hr' class ScenarioType(Enum): TYPICAL = 'typical'