Skip to content

Commit

Permalink
memory and peripheral power domains and fast interrupts (#122)
Browse files Browse the repository at this point in the history
* Solved issue #96. Added 2 timers into the ao_peripheral_subsystem and 2 timers into the peripheral_subsystem.

* Solved issues #16 and #95. Connected each interrupt to the assigned destination.

* Fixed code after review.

* Done a parse with Verible.

* Solved issue #120. Added wake-up events to power_manager.

* Fixed a bug in the interrupt mapping.

* Added peripheral_subsystem power domain.

* Fixed a bug in power_manager.sv.

* Added ram power domains.

* Fixed code after review.

* Added automatic generation of ram blocks support.

* Done a parse with Verible.

* Fixed code after review.

* Updated .gitignore.

* Updated interrupt assignments as previously discussed.

* Added core-v-mini-mcu.upf to .gitignore.

* Modified .gitignore.

* UP template comments and multilines commands.

* Solved multi-lines and comments problems during tpl files generation.

* Removed automatic generation for power_manager.c.

* Updated sw to support fast interrupts.

* Added CSR registers saving during core power-gating.

* Updated Makefile.

* Added example_power_gating_periph and example_power_gating_ram_blocks.

* Done a parse with Verible.

* Updated .gitignore.

* Added plic wake-up event to power_manager.

* Added initial version of fast_intr_ctrl module.

* Improved fast_intr_ctrl module.

* Fixed a bug in spi_host_example.c.

* Added interrupt array to power_manager input.

* Updated example_power_gating_core.c app.

* Ordered interrupts in power_manager.

* Added clear fast interrupt in power_manager.c.

* Done a parse with Verible.

* Solved issue #148.

* Fixed a bug in power_manager.hjson.tpl.

* Fixed a bug in power_manager.hjson.tpl.

* Added iso counters.

* Added other iso counters.

* Done a parse with Verible.

* minor SW updates

* update fast interrupt

* remove reset mem domain

* Fixed a non-functional bug in interrupt handlers.

* Improved power_manager.c.

* Updated vertors.S.

* Updated Makefile.

Co-authored-by: Machetti Simone <machetti@eslsrv13.intranet.epfl.ch>
Co-authored-by: Benoît Denkinger <benoit.denkinger@epfl.ch>
Co-authored-by: davide schiavone <davide@openhwgroup.org>
  • Loading branch information
4 people authored Oct 13, 2022
1 parent 2651a44 commit cfa86b2
Show file tree
Hide file tree
Showing 59 changed files with 4,698 additions and 4,271 deletions.
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ build/
*.map
*.do

# ignore core-v-mini-mcu pkg that is automatically generated by Makefile
# ignore the following hw automatically generated files
core-v-mini-mcu.upf
tb/tb_util.svh
hw/core-v-mini-mcu/include/core_v_mini_mcu_pkg.sv
hw/core-v-mini-mcu/system_bus.sv
hw/core-v-mini-mcu/pad_ring.sv
tb/tb_util.svh
# same for the C header file and linker scripts
hw/ip/power_manager/data/power_manager.hjson
hw/ip/power_manager/rtl/power_manager.sv
hw/ip/power_manager/rtl/power_manager_reg_top.sv
hw/ip/power_manager/rtl/power_manager_reg_pkg.sv

# ignore the following sw automatically generated files
sw/device/lib/runtime/core_v_mini_mcu.h
sw/linker/link.ld
sw/linker/link_spiflash.ld
sw/linker/link_spihost.ld
sw/linker/link_flash_exec.ld
sw/linker/link_flash_load.ld
sw/device/lib/drivers/power_manager/power_manager_regs.h
sw/device/lib/drivers/power_manager/power_manager.h
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@

.PHONY: clean help

TARGET ?= sim
TARGET ?= sim

# Generates mcu files
mcu-gen:
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir hw/core-v-mini-mcu/include --cpu $(CPU) --bus $(BUS) --memorybanks $(MEMORY_BANKS) --pkg-sv hw/core-v-mini-mcu/include/core_v_mini_mcu_pkg.sv.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir hw/core-v-mini-mcu/ --memorybanks $(MEMORY_BANKS) --tpl-sv hw/core-v-mini-mcu/system_bus.sv.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir tb/ --memorybanks $(MEMORY_BANKS) --tpl-sv tb/tb_util.svh.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir hw/core-v-mini-mcu/ --tpl-sv hw/core-v-mini-mcu/pad_ring.sv.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir sw/device/lib/runtime --cpu $(CPU) --header-c sw/device/lib/runtime/core_v_mini_mcu.h.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir sw/device/lib/runtime --cpu $(CPU) --memorybanks $(MEMORY_BANKS) --header-c sw/device/lib/runtime/core_v_mini_mcu.h.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir sw/linker --memorybanks $(MEMORY_BANKS) --linker_script sw/linker/link.ld.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir . --memorybanks $(MEMORY_BANKS) --pkg-sv ./core-v-mini-mcu.upf.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir hw/ip/power_manager/rtl --memorybanks $(MEMORY_BANKS) --pkg-sv hw/ip/power_manager/data/power_manager.sv.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir hw/ip/power_manager/data --memorybanks $(MEMORY_BANKS) --pkg-sv hw/ip/power_manager/data/power_manager.hjson.tpl
bash -c "cd hw/ip/power_manager; source power_manager_gen.sh; cd ../../../"
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir sw/device/lib/drivers/power_manager --memorybanks $(MEMORY_BANKS) --pkg-sv sw/device/lib/drivers/power_manager/data/power_manager.h.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir sw/linker --memorybanks $(MEMORY_BANKS) --linker_script sw/linker/link_flash_exec.ld.tpl
python util/mcu_gen.py --cfg mcu_cfg.hjson --outdir sw/linker --memorybanks $(MEMORY_BANKS) --linker_script sw/linker/link_flash_load.ld.tpl
$(MAKE) verible

# Display mcu_gen.py help
mcu-gen-help:
python util/mcu_gen.py -h
Expand Down
2 changes: 2 additions & 0 deletions core-v-mini-mcu.core
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ filesets:
- x-heep:ip:boot_rom
- x-heep:ip:dma
- x-heep:ip:power_manager
- x-heep:ip:fast_intr_ctrl
- x-heep:ip:pad_attribute
files:
- hw/core-v-mini-mcu/core_v_mini_mcu.sv
Expand Down Expand Up @@ -70,6 +71,7 @@ filesets:
- hw/ip/obi_spimemio/obi_spimemio.vlt
- hw/ip/dma/dma.vlt
- hw/ip/power_manager/power_manager.vlt
- hw/ip/fast_intr_ctrl/fast_intr_ctrl.vlt
- hw/ip/pad_attribute/pad_attribute.vlt
file_type: vlt

Expand Down
75 changes: 0 additions & 75 deletions core-v-mini-mcu.upf

This file was deleted.

156 changes: 156 additions & 0 deletions core-v-mini-mcu.upf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
upf_version 2.1

set_design_top core_v_mini_mcu
set_scope .


<%text>
#####################
## POWER DOMAINS ##
#####################
</%text>\

create_power_domain PD_TOP -include_scope
create_power_domain PD_CPU -elements {cpu_subsystem_i}
create_power_domain PD_PERIP_SUBS -elements {peripheral_subsystem_i}
% for bank in range(ram_numbanks):
create_power_domain PD_MEM_BANK_${bank} -elements {memory_subsystem_i/gen_sram[${bank}].ram_i}
% endfor


<%text>
####################
## POWER STATES ##
####################
</%text>\

add_power_state PD_TOP.primary -state TOP_ON <%text>\</%text>
{-supply_expr {power == `{FULL_ON, 1.2} && ground == `{FULL_ON, 0.0}}}

add_power_state PD_CPU.primary -state CPU_ON <%text>\</%text>
{-supply_expr {power == `{FULL_ON, 1.2} && ground == `{FULL_ON, 0.0}}}

add_power_state PD_CPU.primary -state CPU_OFF <%text>\</%text>
{-supply_expr {power == `{OFF} && ground == `{FULL_ON, 0.0}}} -simstate CORRUPT

add_power_state PD_PERIP_SUBS.primary -state PERIP_SUBS_ON <%text>\</%text>
{-supply_expr {power == `{FULL_ON, 1.2} && ground == `{FULL_ON, 0.0}}}

add_power_state PD_PERIP_SUBS.primary -state PERIP_SUBS_OFF <%text>\</%text>
{-supply_expr {power == `{OFF} && ground == `{FULL_ON, 0.0}}} -simstate CORRUPT

% for bank in range(ram_numbanks):
add_power_state PD_MEM_BANK_${bank}.primary -state MEM_BANK_${bank}_ON <%text>\</%text>
{-supply_expr {power == `{FULL_ON, 1.2} && ground == `{FULL_ON, 0.0}}}

add_power_state PD_MEM_BANK_${bank}.primary -state MEM_BANK_${bank}_OFF <%text>\</%text>
{-supply_expr {power == `{OFF} && ground == `{FULL_ON, 0.0}}} -simstate CORRUPT

% endfor

<%text>
###################
## SUPPLY NETS ##
###################
</%text>\

create_supply_port VDD -direction in
create_supply_port VSS -direction in

create_supply_net VDD
create_supply_net VSS

connect_supply_net VDD -ports VDD
connect_supply_net VSS -ports VSS

create_supply_set PD_TOP.primary -function {power VDD} -function {ground VSS} -update

create_supply_net VDD_CPU
create_supply_set PD_CPU.primary -function {power VDD_CPU} -function {ground VSS} -update

create_supply_net VDD_PERIP_SUBS
create_supply_set PD_PERIP_SUBS.primary -function {power VDD_PERIP_SUBS} -function {ground VSS} -update

% for bank in range(ram_numbanks):
create_supply_net VDD_MEM_BANK_${bank}
create_supply_set PD_MEM_BANK_${bank}.primary -function {power VDD_MEM_BANK_${bank}} -function {ground VSS} -update

% endfor

<%text>
################
## SWITCHES ##
################
</%text>\

create_power_switch switch_PD_CPU <%text>\</%text>
-supply_set PD_TOP.primary <%text>\</%text>
-domain PD_CPU <%text>\</%text>
-input_supply_port {sw_in VDD} <%text>\</%text>
-output_supply_port {sw_out VDD_CPU} <%text>\</%text>
-control_port {sw_ctrl cpu_subsystem_powergate_switch} <%text>\</%text>
-on_state {on_state sw_in {sw_ctrl}} <%text>\</%text>
-off_state {off_state {!sw_ctrl}}

create_power_switch switch_PD_PERIP_SUBS <%text>\</%text>
-supply_set PD_TOP.primary <%text>\</%text>
-domain PD_PERIP_SUBS <%text>\</%text>
-input_supply_port {sw_in VDD} <%text>\</%text>
-output_supply_port {sw_out VDD_PERIP_SUBS} <%text>\</%text>
-control_port {sw_ctrl peripheral_subsystem_powergate_switch} <%text>\</%text>
-on_state {on_state sw_in {sw_ctrl}} <%text>\</%text>
-off_state {off_state {!sw_ctrl}}

% for bank in range(ram_numbanks):
create_power_switch switch_PD_MEM_BANK_${bank} <%text>\</%text>
-supply_set PD_TOP.primary <%text>\</%text>
-domain PD_MEM_BANK_${bank} <%text>\</%text>
-input_supply_port {sw_in VDD} <%text>\</%text>
-output_supply_port {sw_out VDD_MEM_BANK_${bank}} <%text>\</%text>
-control_port {sw_ctrl memory_subsystem_banks_powergate_switch[${bank}]} <%text>\</%text>
-on_state {on_state sw_in {sw_ctrl}} <%text>\</%text>
-off_state {off_state {!sw_ctrl}}

% endfor

<%text>
#################
## ISOLATION ##
#################
</%text>\

set_isolation cpu_iso <%text>\</%text>
-domain PD_CPU <%text>\</%text>
-isolation_power_net VDD <%text>\</%text>
-isolation_ground_net VSS <%text>\</%text>
-isolation_signal cpu_subsystem_powergate_iso <%text>\</%text>
-isolation_sense low <%text>\</%text>
-clamp_value 0 <%text>\</%text>
-applies_to both <%text>\</%text>
-name_prefix cpu_iso_cell <%text>\</%text>
-location parent

set_isolation perip_subs_iso <%text>\</%text>
-domain PD_PERIP_SUBS <%text>\</%text>
-isolation_power_net VDD <%text>\</%text>
-isolation_ground_net VSS <%text>\</%text>
-isolation_signal peripheral_subsystem_powergate_iso <%text>\</%text>
-isolation_sense low <%text>\</%text>
-clamp_value 0 <%text>\</%text>
-applies_to both <%text>\</%text>
-name_prefix cpu_iso_cell <%text>\</%text>
-location parent

% for bank in range(ram_numbanks):
set_isolation mem_bank_${bank}_iso <%text>\</%text>
-domain PD_MEM_BANK_${bank} <%text>\</%text>
-isolation_power_net VDD <%text>\</%text>
-isolation_ground_net VSS <%text>\</%text>
-isolation_signal memory_subsystem_banks_powergate_iso[${bank}] <%text>\</%text>
-isolation_sense low <%text>\</%text>
-clamp_value 0 <%text>\</%text>
-applies_to both <%text>\</%text>
-name_prefix cpu_iso_cell <%text>\</%text>
-location parent

% endfor
Loading

0 comments on commit cfa86b2

Please sign in to comment.