공부/Embedded

[Renode] .repl(Platform description format)

래울 2024. 12. 1. 23:16

.repl?

repl(Renode Platform)은 Platform description format 이다.

주변 장치를 쉽게 구성하여 완전한 플랫폼 정의를 만들 수 있게 yaml과 파일이 필요해서 만들어졌다.

 

기본적인 작성 규칙

- 의미 있는 들여쓰기가 사용되고 (), {}, 를 사용함(Python과 비슷)

- 들여쓰기는 공백만 허용하고, 공백 수는 반드시 4의 배수

- 중괄호 내부의 들여쓰기는 의미가 없음

- 의미 있는 들여쓰기가 사용되는 경우, 이를 indent mode라고 부름

- 비들여쓰기에서 구분하려면 세미콜론으로 구분함

- 주석은 /* */ 를 사용

 

### Ex1
line1
line2
    line3
    line4
        line5
    line6
    
### Ex2
line1
line2 { line3; line4 { line5 }; line 6 }

 

 

 

기본 구조

몇몇 platform description은 entry들을 포함하기도 한다.(entry는 주변장치 description의 기본 단위임)

# entry basic format
variableName: TypeName registrationInfo
    attribute1
    attribute2
    ...
    attributeN

 

 

TypeName, registrationInfo, attributes는 옵션이지만, 적어도 하나는 있어야 한다.

TypeName이 포함되어 있으면 생성 항목이고, 없다면 업데이트 항목이다.

→ 첫 번재 항목으로 있어야 함

# compliant
variable1: SomeType
    property: value

variable1:
    property: otherValue
    
    
# non-compliant
variable1:
    property: value

variable1: SomeType
    property: otherValue

 

TypeNmae에는 유형이 위치한 전체 namespace가 제공되어야 하지만, Antmicro.Renode.Peripherals로 시작하는 경우 생략 가능하다.

 

# local: 생성시에는 local을 붙일 수 있고 해당 파일 내에서만 참조할 수 있다.
local cpu: SomeCPU
    StringProp: "a"

cpu:
    IntProp: 32

 

 

using(다른 파일에 의존)

import~~ 와 비슷하다. 말 그대로 다른 description을 가져와 사용할 수 있고, 만약 사이클이 생기면 인터프리터가 감지해 오류가 난다.

using "path"
using "path" prefixed "prefix"

 

 

Value

1. simple values

  - 문자열: 이스케이프 된 큰 따옴표(\" \")

  - 다중 줄 문자열: 다중줄 문자열

  - bool(true, false)

  - 숫자: 10진수 또는 16진수(0x1a)

  - 범위: 아래 두 가지 방법으로 표현됨

    <begin, end> 또는 <begin, +size>로 나타내고, begin과 end는 10진수 또는 16진수임

 

2. reference values: 변수를 가리키고 변수의 이름과 동일 한 값(= 변수 값)

3. inline objects

 

 

Registration Info

주변장치들을 등록해야하는 레지스터 정보와 방법을 알려줌

주변장치는 하나 이상의 레지스터에 등록 가능

 

단일 등록

registrationPoint 옵션: 등록 포인트를 생성하거나 이미 존재하는 등록 포인트를 사용

등록 포인트가 없으면 기본적으로는 NullRegistrationPoint를 사용하거나, 생성자가 매개변수를 필요로 하지 않는 등록 포인트를 사용

as "alias" : 말 그대로 별칭, 변수 이름 대신 다른 이름으로 주변 장치를 등록할 때 사용

@ register registrationPoint as "alias"

 

다중 등록

주변 장치를 여러 레지스터에 등록

@ {
    register1 registrationPoint1;
    register2 registrationPoint2;
    ...
    registerN registrationPointN
} as "alias"

 

등록 정보는 생성 entry나 업데이트 entry에 지정할 수 있다.

동일 변수에 여러 등록 정보가 지정되는 경우는, 가장 마지막 항목이 유효하다.

등록 취소: variable: @none

 

 

Attributes

Constructor or property attributes

name: value

 

Property 이름:  첫 글자는 대문자

Constructor Parameter 이름: 첫 글자가 소문자

 

none과 empty 키워드

none: 속성 값을 설정하지 않음, 기존 속성 값이 유지 됨

empty: 속성을 기본 값으로 설정(0, null, enum[0], null)

 

 

Interrupt Atrributes

인터럽트 속성은 정의된 변수의 어떤 인터럽트가 연결되고 어디에 연결되는지 지정하는데 사용한다.

 

1. 기본 형식

-> destination@number

destination: IGPIOReceiver 인터페이스를 구현한 변수

number: 연결할 대상 인터럽트 번호

 

2. 특정 속성을 지정해서 연결

propertyName -> destination@number

propertyName: 연결할 GPIO 타입 속성 이름

INumberedGPIOOutput을 구현하면 속성 이름 대신 숫자 사용 가능

 

3. 여러 인터럽트를 동일 대상에 연결

[irq1, irq2 ... ] -> destination@[irqDest1, irqDest2 ...]

irq: 소스 인터럽트(속성 이름 또는 번호)

irqDest: 대상 인터럽트 번호(숫자)

소스와 대상의 개수가 일치해야 함

 

4. 하나의 소스를 여러 대상에 연결

-> destination@number | another_destination@number
propertyName -> destination@number | another_destination@number
[irq1, irq2, ...] -> destination@[irqDest1, irqDest2, ...] | another_destination@[irqDest1, irqDest2, ..., irqDestN]

| 기호를 사용하여 동일한 소스를 여러 대상에 연결할 수 있음

 

5. 로컬 인터럽트 연결

source -> destination#index@interrupt

destination: ILocalGPIOReceiver: 인터페이스를 구현한 변수

index: 로컬 GPIO 리시버의 인덱스

 

Init attribute

Init 속성은 특정 변수에 대해 모니터 명령어를 사용하기 위한 속성이다.

등록된 변수에만 사용가능하다.

# override(덮어쓰기)방식
init:
    monitorStatement1
    monitorStatement2
    ...
    monitorStatementN

# concatenate(추가)방식
init add:
    monitorStatement1
    monitorStatement2
    ...
    monitorStatementN

 

 

https://renode.readthedocs.io/en/latest/advanced/platform_description_format.html