Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change PWMTL base address and size? #8

Closed
ViccoYang opened this issue Apr 21, 2017 · 1 comment
Closed

How to change PWMTL base address and size? #8

ViccoYang opened this issue Apr 21, 2017 · 1 comment

Comments

@ViccoYang
Copy link

I have 3 questions about PWMTL. I'm new to this project so the questions may looks amateure but I really need your help. Thanks!

After
cd verisim
make PROJECT=pwm CONFIG=PWMTLConfig
I saw
pwm {
addr 0x2000;
size 0x1000;
}
on the screen.
But when I look in PWM.scala,Top.scala,TestHarness.scala,Configs.scala, I couldn't find out how to change these parameters. So what should I do if I want to change them?

Besides, in pwm.c, it define 3 registers
#define PWM_PERIOD 0x2000
#define PWM_DUTY 0x2008
#define PWM_ENABLE 0x2010
According to PWM.scala, the reg address can be distinguish by the lower 2bits of full_addr, but I'm still not sure what does the full_addr look like.Because the 3 regs are all end with 00, so how can we distinguish them by the lower 2bits?Or in another words, why the address of Reg PWM_DUTY is 0x2008?If I change it to 0x2018 and write something into this address, what should I do to make sure PWM find the right address and update the the register?

Last question, can we make sure the PWM is working well? In pwm.c we only write some data in the regs and enable the PWM, but I don't know if the module really works.

@zhemao
Copy link
Contributor

zhemao commented Apr 26, 2017

You can move the PWM base address by modifying this line

https://github.com/ucb-bar/project-template/blob/master/src/main/scala/pwm/PWM.scala#L157

If you change MemSize(4096, ... to MemRange(startAddr, 4096, ... it will move the base address to startAddr.

The full_addr is a (64-bit) word address and not a byte address. So byte addresses 00, 08, and 10 correspond to word addresses 0, 1, and 2, respectively. We use the lower two bits of this address because there are only 3 registers.

@zhemao zhemao closed this as completed Jul 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants