Software APIs
retention_sram_unittest.cc
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
6 
7 #include "gtest/gtest.h"
9 #include "sw/device/lib/base/mock_abs_mmio.h"
10 #include "sw/device/silicon_creator/testing/rom_test.h"
11 
13 #include "sram_ctrl_regs.h" // Generated.
14 
15 namespace retention_sram_unittest {
16 namespace {
18  protected:
20  rom_test::MockAbsMmio mmio_;
21 };
22 
23 class ScrambleTest : public RetentionSramTest {};
24 
25 TEST_F(ScrambleTest, Ok) {
26  EXPECT_ABS_WRITE32(base_ + SRAM_CTRL_CTRL_REG_OFFSET,
27  {
28  {SRAM_CTRL_CTRL_RENEW_SCR_KEY_BIT, 1},
29  {SRAM_CTRL_CTRL_INIT_BIT, 1},
30  });
31 
32  retention_sram_scramble();
33 }
34 
35 class InitTest : public RetentionSramTest {};
36 
37 TEST_F(InitTest, Ok) {
38  EXPECT_ABS_WRITE32(base_ + SRAM_CTRL_CTRL_REG_OFFSET,
39  {
40  {SRAM_CTRL_CTRL_INIT_BIT, 1},
41  });
42 
43  retention_sram_init();
44 }
45 
46 } // namespace
47 } // namespace retention_sram_unittest