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

Enabling __INTERACTIVE__ option when running make file #67

Open
jones6a9 opened this issue Nov 1, 2023 · 2 comments
Open

Enabling __INTERACTIVE__ option when running make file #67

jones6a9 opened this issue Nov 1, 2023 · 2 comments
Assignees

Comments

@jones6a9
Copy link

jones6a9 commented Nov 1, 2023

Hello,

I am using darkriscv in a project for school and am in the process of writing software testbenches. I would like to be able to include scanf functions in the main.c file, but it does not seem to be working. Is there a setting somewhere I could change to enable the interactive option/allow scanf function to be used?

Thank you

@samsoniuk
Copy link
Member

Unfortunately it was designed only to run w/ darkshell code: it prints a prompt "> , which triggers the simulation to stop on darkuart.v and wait for an input string, in a way that, you press enter, the simulation restarts and, eventually, the line is read char by char and processed by the gets() function.

A possible workaround is try use sscanf(), in a way that you print a prompt "> ", get a string w/ gets() and process this string with sscanf(). Of course, darklibc does not include scanf() or sscanf(), so you need provide your own code.

Eventually, I can in the future try re-code the darkuart.v to avoid the requirement for a prompt (the prompt is used to control some state machines on RX path of UART) and enable a more simplistic handshaking based only on getchar(), but I am very busy at the moment, so the workaround w/ sscanf() is probably the better way at the moment.

@samsoniuk samsoniuk self-assigned this Nov 1, 2023
@samsoniuk
Copy link
Member

ohh, a very important question: why you need use the interactive mode on your simulation? note that when the prompt is waiting for stdin input, the simulation is fully stopped because the stdin read operation is blocking the execution, so the use of interactive mode is very specific, that is why it is working only w/ gets() on darkshell.

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